MATLAB Chapter
MATLAB Chapter
net/publication/225363684
CITATIONS READS
132 15,534
1 author:
Stephen Lynch
Manchester Metropolitan University
72 PUBLICATIONS 1,317 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Stephen Lynch on 07 January 2014.
1.1 Introduction
One of the many ventures in the UK National Higher Education Science, Technology, Engineering
and Mathematics (HE STEM) programme is the Supporting MATLAB Automated assessment
to Reinforce Teaching (SMART) project. Some staff involved include the author (Manchester
Metropolitan University and the Open University), Professor Alan Irving (Liverpool University)
and Dr Adam Crawford (Loughborough University). Some of the aims include developing students
programming skills, engaging students in contextualised real world problems and developing a
broader STEM community where academics can share expertise. Some of the objectives include
developing an automated assessment system to give individual feedback to large cohorts of students
in a short space of time, to disseminate findings through the Institute for Maths and its Applications
(IMA) and Royal Academy of Engineers as HE STEM partners and to encourage input and feedback
from international colleagues by means of an open educational resource channel. It is hoped that
these resources will be freely available within the next few years.
It is assumed that the reader is familiar with either the Windows or UNIX platform. This
chapter was prepared using MATLAB (R2010b) but most programs should work under earlier and
later versions of the package.
A tutorial introduction to MATLAB can be downloaded from the MathWorks Central File
Exchange. The commands and programs listed have been chosen to allow the reader to become
1 School
of Computing, Mathematics and Digital Technology, Manchester Metropolitan University, Manchester
M1 5GD, UK
familiar with MATLAB and the Symbolic Math Toolbox within a few hours. They provide a
concise summary of the type of commands that will be used throughout this chapter. New users
should be able to start on their own problems after completing this tutorial, and experienced users
should find this chapter an excellent source of reference. Of course, there are many MATLAB
textbooks on the market for those who require further applications or more detail. Note that
Version 5 of the Symbolic Math Toolbox is powered by the MuPAD symbolic engine and nearly all
Symbolic Math Toolbox functions work the same way as in previous versions. The Symbolic Math
Toolbox provides tools for solving and manipulating symbolic math expressions and performing
variable-precision arithmetic. The toolbox contains hundreds of MATLAB symbolic functions that
leverage the MuPAD engine for tasks such as differentiation, integration, simplification, transforms,
and equation solving. See the online MATLAB help pages if you require further information.
If you experience any problems there are several options for you to take. There is an excellent
index within MATLAB, there are thousands of textbooks, see references [1], [4], [5], [9], [12], [13],
[15], and [17], for example, and MATLAB program files (or M-files) can be downloaded from the
MATLAB Central File Exchange at the link
http://www.mathworks.com/matlabcentral/fileexchange/.
Download the zipped M-files and Extract the relevant M-files from the archive onto your computer.
Since 2002, the authors files associated with his MATLAB book [12] have been downloaded over
20,000 times by users from all over the world.
To start MATLAB, simply double-click on the MATLAB icon. In the Unix environment, one
types matlab as a shell command. The author has used the Windows platform in the preparation
of this material. When MATLAB starts up, by default four windows are displayed entitled Current
Folder, Command Window, Workspace and Command History. Figure 1.1 shows a typical screen
when running MATLAB.
Each of the windows appearing in Figure 1.1 will now be described:
Current Folder. This window shows the current folder where files are listed. Note that when
typing in the Command Window, the command pwd also displays the MATLAB current folder.
Command Window. This is where the user types in MATLAB commands followed by the
RETURN or ENTER key on the keyboard. If you do not want to see the result (for example, you
would not want to see a list of numbers from 1 to 1000) then use the semi-colon delimeter.
Workspace. The workspace consists of the set of variables built up during a session of using the
MATLAB software and stored in memory.
Command History. The Command History window displays a log of the statements most
recently run in the Command Window
The Command Window is where the MATLAB commands are typed and executed and this is
where the user can use MATLAB just like a graphing calculator. When in the Command Window,
command lines may be returned to and edited using the up and down arrow keys. If you do make
a typing error, MATLAB will give an Error: message and even point to the mistake in the code.
Do not re-type the line, simply use the up arrow key and edit your mistake. In this chapter, each
MATLAB program is displayed between horizontal lines and kept short to aid in understanding;
Figure 1.1: The MATLAB user interface.
the output is also included. Take care, M-files will only run if they are in the current working
directory. To edit a file in MATLAB simply type edit filename.m in the Command Window or
select File, New or Open in the MATLAB desktop or any desktop tool. Ensure that the files
you are working with are in your Current Folder.
1. Array indices start with 1 and not zero. In some programs a translation may be required to
start indices with zero.
2. MATLAB allows use of variable names of pre-defined functions. For example, you can set
rand=1 which means that you can not subsequently use the rand command. Readers should
use the which command to check variable names.
4. Some functions such as max, min, sort, sum, mean etc behave differently for complex and
real data.
5. In MATLAB it is better (though not easier) to use matrix or vector operations instead of
loops in programs.
7. For advanced symbolic computation readers will need to purchase Maple or Mathematica.
The reader should also be aware that even when the programs run successfully the output may
not be correct. The following phenomena can greatly affect the results obtained for nonlinear
dynamical systems:
3. Feedback, especially in the case of the second iterative method which is defined later in this
chapter.
Any results obtained with MATLAB should be verified by experiment where possible.
The Chemical Law of Mass Action. The rates at which the concentrations of the various
chemical species change with time are proportional to their concentrations.
where β and γ are the stoichiometric coefficients, A and B are the reactants, C is the product,
and k1 is the rate constant of the equation. The rate of reaction, say, r, is given by
change in concentration
r= .
change in time
k2
αA −→ δD,
where k2 is the rate constant of the second equation and α and δ are the stoichiometric coefficients.
Two of the possible reaction rate equations for this system now become
d[A] d[D]
= −k1 β[A][B]β − k2 α[A]α , = k2 δ[A]α .
dt dt
Suppose that species A, B, C, and D have concentrations a(t), b(t), c(t), and d(t) at time t
and initial concentrations a0 , b0 , c0 , and d0 , respectively. Table 1.1 lists some reversible chemical
reactions and one of the corresponding reaction rate equations, where kf and kr are the forward
and reverse rate constants, respectively.
Table 1.1: One of the possible reaction rate equations for each chemical reaction.
kf
2A −⇀
↽− B ḃ = kf (a0 − 2b)2 − kr b
kr
kf
A −⇀ b
− kr b2
↽− 2B ḃ = kf a0 − 2
kr
kf
A −⇀
↽− B+C ċ = kf (a0 − c) − kr (b0 + c)(c0 + c)
kr
kf
A+B −⇀
↽− C ċ = kf (a0 − c)(b0 − c) − kr c
kr
kf
A+B −⇀
↽− C+D ċ = kf (a0 − c)(b0 − c) − kr (c0 + c)(d0 + c)
kr
Example 1. A reaction equation for sulphate and hydrogen ions to form bisulphite ions is given
by
kf
SO2−
3 +H
+ −⇀
↽− HSO−
3,
kr
where kf and kr are the forward and reverse rate constants, respectively. Denote the concentrations
by a = [SO2− + −
3 ], b = [H ], and c = [HSO3 ], and let the initial concentrations be a0 , b0 , and c0 .
Assume that there is much more of species H+ than the other two species, so that its concentration
b can be regarded as constant. The reaction rate equation for c(t) is given by
dc
= ċ = kf (a0 − c)b − kr (c0 + c).
dt
Find a general solution for c(t).
Example 2. The chemical equation for the reaction between nitrous oxide and oxygen to form
nitrogen dioxide at 25o C,
2NO + O2 → 2NO2
obeys the law of mass action. The rate equation is given by
dc c
= k(a0 − c)2 b0 − ,
dt 2
where c = [NO2 ] is the concentration of nitrogen dioxide, k is the rate constant, a0 is the initial
concentration of NO, and b0 is the initial concentration of O2 . Find the concentration of nitrogen
dioxide after time t given that k = 0.00713l2M −2 s−1 , a0 = 4M l−1 ,b0 = 1M l−1, and c(0) = 0M l−1 .
2.6
2.4
2.2
2
1.8
1.6
1.4
c(t)
1.2
1
0.8
0.6
0.4
0.2
0 100 200 300 400
t
Figure 1.2: The concentration of NO2 in moles per liter against time in seconds.
There may be a wide range of time scales involved in chemical reactions and this can lead to
stiff systems. Loosely speaking, a stiff system of differential equations is one in which the velocity
or magnitude of the vector field changes rapidly in phase space. The final example illustrates how
certain stiff systems can be solved using special solvers in MATLAB.
Example 3. The chemical rate equations for the Chapman cycle modeling the production of
ozone are
O2 + hv → O + O, Rate = k1 ,
O2 + O + M → O3 + M, Rate = k2 ,
O3 + hv → O2 + O, Rate = k3 ,
O + O3 → O2 + O2 , Rate = k4 ,
where O is a singlet, O2 is oxygen, and O3 is ozone. The reaction rate equations for species x = [O],
y = [O2 ], and z = [O3 ] are
This is a stiff system of differential equations. Given that [M] = 9e17, k1 = 3e−12, k2 = 1.22e−33,
k3 = 5.5e−4, k4 = 6.86e−16, x(0) = 4e16, y(0) = 2e16, and z(0) = 2e16, show that the steady-
state reached is [O] = 4.6806e7, [O2] = 6.999e16, and [O3 ] = 6.5396e12.
Solution. The MATLAB commands used for solving this system are listed below. The reader
should look at the Help pages in MATLAB for further information on stiff solvers.
Autocatalytic Chemical Reactions Autocatalytic chemical reactions are those in which at least
one of the reactants is also a product. One of the simplest autocatalytic reactions can be written
k1
A + 2B −→ 3B,
with rate equations
d[A] d[B]
= −2k1 [A][B]2 , = 3k1 [A][B]2 ,
dt dt
where k1 is the rate constant.
These rate equations are nonlinear and a richer variety of behaviour is possible including emer-
gent temporal order and oscillatory states, multiple steady states and hysteresis, emergent spatial
order and self-organization, and chaos. The following references contain a rich variety of examples
and applications in the real world [6], [8] and [16].
As a particular example of emergent temporal order, consider the Brusselator model charac-
terized by the chemical equations
A → X,
2X + Y → 3X,
B + X → Y + C,
X → D,
where the rate constants have all been scaled to one, and the amount of species A and B is
assumed much higher than species X and Y, so their concentrations can be regarded as constant.
For mathematical convenience, suppose that [X] = x, [Y ] = y, [A] = a, and [B] = b. Then the rate
equations become
ẋ = a + x2 y − bx − x, ẏ = bx − x2 y,
where a and b are constant. This is a system of ordinary differential equations and it is possible
to carry out a phase plane analysis.
The critical points of the system are found by solving the equations, ẋ = ẏ = 0. These equations
are easily solved and there is a unique critical point at a, ab . To determine the stability of the
critical point the Jacobian matrix is used to compute the eigenvalues.
MATLAB Commands Comments
>> syms a b % The parameters.
>> P=a+x^2*y-b*x-x;Q=b*x-x^2*y; % Define x dot and y dot.
>> J=[diff(P,x) diff(P,y);diff(Q,x) diff(Q,y)] % The Jacobian matrix.
>> x=a;y=b/a; % The critical point.
>> eig(J) % The eigenvalues.
The Jacobian matrix at the critical point a, ab is given by
b − 1 a2
A= .
−b −a2
The determinant of J is det(J) = a2 and the trace of J is trace(J) = b − a2 − 1. Thus the critical
point is stable when b < 1 + a2 and unstable when b > 1 + a2 . The critical point goes through a
bifurcation at b = 1 + a2 , and at this point the critiocal point has pure imaginary eigenvalues. A
Hopf bifurcation or more accuratley a Poincaré-Andronov-Hopf bifurcation arises when these two
eigenvalues cross the imaginary axis because of a variation of the system parameters. For a math-
ematical introduction to bifurcation theory the reader is directed to [11] and [12]. The MATLAB
program listed below can be used to produce an animation of a Hopf bifurcation for the Brusselator
model, and Figure 1.3 shows the limit cycle when a = 1 and b = 2.5. For an introduction to limit
cycles see reference [12]. When watching the animation, imagine the critical point blowing a smoke
ring.
Hopf Bifurcation
5
y(t) 3
0
0 1 2 3 4 5
x(t)
Figure 1.3: Limit cycle of the Brusselator model when a = 1 and b = 3. Note that the MATLAB
program produces an animation of a Hopf bifurcation which takes place when b = 1 + a2 .
As a particular example of multiple steady states and hysteresis, consider a simple autocatalytic
reaction in an isothermal continuously stirred tank reactor (CSTR). Select a volumetric control
V (t) as indicated in Figure 1.4. The autocatlaytic reaction is modeled by the following chemical
equation:
k1
A + 2B −→ 3B,
where the reaction is taken to be elementary and obeys the chemical law of mass action. Applying
rate equations and macroscopic balance equations, the differential equations modeling this system
are written as
da
V = Q (a0 − a) − V k1 ab2 ,
dt
db
V = Q (b0 − b) + V k1 ab2 , (1.1)
dt
where a and b are the concentrations of A and B, respectively, a0 and b0 are initial concentrations,
V is the control volume, k1 is the rate constant, and τ = VQ = k1f , is the residence time for the
reactor. The equations provide a simple model of an autocatalytic reaction in an isothermal CSTR
with perfect mixing. Interested readers should see reference [18] for an example of non-ideal mixing
in an isothermal CSTR with two unpremixed feeds. Adding the equations in (1.1) and noting that
conservation of mass gives a(t) + b(t) = a0 + b0 , the term b can be eliminated to give
da 2
= kf (a0 − a) − k1 a (a0 + b0 − a) . (1.2)
dt
The differential equation (1.2) can have one, two or three critical points. Critical points are found
by solving the equation
2
kf (a0 − a) = k1 a (a0 + b0 − a) .
Using a tangency condition, it is not difficult to show that this equation has more than one solution
if a0 > 8b0 . This is left as an exercise for the reader. Taking the transformations
b0 k1 2 a
γ =1+ , β= a , x= ,
a0 kf 0 a0
The First Iterative Method. A parameter is fixed and one or more initial points are iterated
forward. Transients are ignored and a number of the final iterates are plotted. The parameter
is then increased by a suitable step length and the process is repeated. There are many points
plotted for each value of the parameter.
The Second Iterative Method. A parameter is varied and the solution to the previous iterate is
used as the initial condition for the next iterate. In this way, a feedback mechanism is introduced.
In this case, there is a history associated with the process and only one point is plotted for each
value of the parameter.
The MATLAB program listed below uses the second iterative method to produce a bifurcation
diagram for equation (1.3) as the volumetric rate β is increased and then decreased.
0.8
0.6
x
0.4
0.2
0
1 2 3 4
β
Γ cos(ω t)
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0000
1111
0
1
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
x
Figure 1.6: A periodically driven pendulum.
Systems of the form (1.4) have been studied extensively in terms of, for example, stability, har-
monic solutions, subharmonic solutions, transients, chaotic output, chaotic control, and Poincaré
maps. The work here will be restricted to considering the Poincaré maps and bifurcation diagrams
for system (1.4) as the driving amplitude Γ varies when k = 0.3 and ω = 1.25 are fixed.
It is interesting to apply quasiperiodic forcing to nonlinear systems, as in [14], where nonchaotic
attractors appear for a quaiperiodically forced van der Pol system.
Any periodically forced nonautonomous differential equation can be represented in terms of
an autonomous flow in a torus. To achieve this transformation, simply introduce a third variable
θ = ωt. System (1.4) then becomes a three-dimensional autonomous system given by
ẋ = y, ẏ = x − ky − x3 + Γ cos(θ), θ̇ = ω. (1.5)
2π
A flow in this state space corresponds to a trajectory flowing around a torus with period ω .
This naturally leads to a Poincaré mapping of a θ = θ0 plane to itself.
When Γ = 0, system (1.4) becomes the autonomous system
ẋ = y, ẏ = x − ky − x3 . (1.6)
MATLAB can be used to compute the location and type of critical points for this system. Critical
points are determined by solving the equations ẋ = ẏ = 0.
MATLAB Commands Comments
>> syms x y % Symbolic objects.
>> [x,y]=solve(’y’,’x-k*y-x^3’) % Solve the simultaneous equations.
Thus there three critical points at M = (−1, 0), N = (1, 0), and O = (0, 0). The next step is to
determine the stability of these critical points using the Jacobian matrix.
MATLAB Commands Comments
>> P=y;Q=x-k*y-x^3; % Define x dot and y dot.
>> J=[diff(P,x) diff(P,y);diff(Q,x) diff(Q,y)] % The Jacobian matrix.
>> eig([0 1;1 -k]) % The eigenvalues for (0,0).
>> eig([0 1;-2 -k]) % The eigenvalues for (-1,0) and (1,0).
y 1
1
y
0
0 0.5 1 1.5 2
x
–1
–1
(a)
2
2
y 1
1
y
0
0 0.5 1 1.5 2
x
–1
–1
(b)
2
2
y 1
1
y
0
0 0.5 1 1.5 2
x
–1
–1
(c)
Figure 1.7: A gallery of phase portraits and Poincaré maps for system (1.4) when k = 0.3 and
ω = 1.25: (a) Γ = 0.2 (forced period one), (b) Γ = 0.3 (a period-two subharmonic), (c) Γ = 0.31
(a period-four subharmonic).
xdot(2)=x(1)-0.1*x(2)-(x(1))^3+Gamma*cos(1.25*t);
xdot=[xdot(1);xdot(2)];
% End of Duffing.
y 1
1
y
0
–2 –1 0 1 2
x
–1
–1
–2 –2 –1 0 1 2
x
(a)
2
2
y 1
1
y
0
–2 –1 0 1 2
x
–1
–1
–2 –2 –1 0 1 2
x
(b)
2
2
y 1
1
y
0
–2 –1 0 1 x 2
–1 –1
–2
–2 –1 0 1 2
x
(c)
Figure 1.8: A gallery of phase portraits and Poincaré maps for system (1.4) when k = 0.3 and
ω = 1.25: (a) Γ = 0.37 (a period-five subharmonic); (b) Γ = 0.5 (chaos), 4,000 points are plotted;
(c) Γ = 0.8 (forced period one).
clear
global Gamma;
Max=120;step=0.001;interval=Max*step;a=1;b=0;
% Ramp the amplitude up.
for n=1:Max
Gamma=step*n;
[t,x]=ode45(’Duffing’,[0:(2*pi/1.25):(4*pi/1.25)],[a,b]);
a=x(2,1);
b=x(2,2);
rup(n)=sqrt((x(2,1))^2+(x(2,2))^2);
end
% Ramp the amplitude down.
for n=1:Max
Gamma=interval-step*n;
[t,x]=ode45(’Duffing’,[0:(2*pi/1.25):(4*pi/1.25)],[a,b]);
a=x(2,1);
b=x(2,2);
rdown(n)=sqrt((x(2,1))^2+(x(2,2))^2);
end
% Plot the bifurcation diagram.
hold on
rr=step:step:interval;
plot(rr,rup)
plot(interval-rr,rdown)
hold off
fsize=15;
axis([0 .12 0 2])
xlabel(’\Gamma’,’FontSize’,fsize)
ylabel(’r’,’FontSize’,fsize)
title(’Bifurcation Diagram of the Duffing System’)
% End of Program.
Figure 1.9 shows a possible bifurcation diagram for system (1.4) for forcing amplitudes in the
range 0 < Γ < 0.4 near the critical point at N . The vertical
p axis labeled r represents the distance
of the point in the Poincaré map from the origin (r = x2 + y 2 ). The first iterative method was
employed in this case. For each value of Γ, the last 10 of 50 iterates were plotted, and the step
length used in this case was 0.01. The initial values were chosen close to one of the existing periodic
solutions. The diagram shows period-one behavior for 0 < Γ < 0.28, approximately. For values of
Γ > 0.28, there is period-two behavior, and then the results become a little obscure.
Figure 1.10 shows a possible bifurcation diagram produced using the second iterative method.
The parameter Γ is increased from zero to 0.4 and then decreased from Γ = 0.4 back to zero. There
were 2000 iterates used as Γ was increased and then decreased. The solid curve lying approximately
between 0 ≤ Γ < 0.32 represents steady-state behavior. As Γ increases beyond 0.32, the system
goes through a chaotic regime and returns to periodic behavior before Γ = 0.4. As the parameter
Γ is decreased, the system returns through the periodic paths, enters a chaotic region, and period
undoubles back to the steady-state solution at Γ ≈ 0.28. Note that on the ramp-up part of the
iterative scheme, the steady state overshoots into the region where the system is of period two,
roughly where 0.28 < Γ < 0.32.
Figure 1.11 shows a bifurcation diagram produced as Γ is increased from zero to 0.45 and then
decreased back to zero. Once more as Γ is increased, there is steady-state behavior for Γ lying
between zero and approximately 0.32. However, as the parameter is decreased a different steady
2
r1
0 0.2 0.4
Figure 1.9: A bifurcation diagram for system (1.4) produced using the first iterative method.
1.8
1.6
1.4
1.2
r1
0.8
0.6
0.4
0.2
Γ
0 0.1 0.2 0.3 0.4
Figure 1.10: A bifurcation diagram for system (1.4) produced using the second iterative method.
1.8
1.6
1.4
1.2
r1
0.8
0.6
0.4
0.2
Γ
0 0.1 0.2 0.3 0.4
Figure 1.11: A bifurcation diagram for system (1.4) produced using the second iterative method.
There is a large bistable region.
R iR
+
+ +
L v2 v1 vR NR
- -
C2 C1
-
i
Figure 1.12: Chua’s electronic circuit.
where a and b are dimensionless parameters. The function g(x) has the form
1
g(x) = cx + (d − c) (|x + 1| − |x − 1|) ,
2
where c and d are constants.
Time series
0.4
0.2
0
y
−0.2
−0.4
0 20 40 60 80 100
time
Figure 1.13: Chua’s electronic circuit: Chaotic time series plot for system (1.8) when a = 15, b =
25.58, c = −5/7, and d = −8/7. The initial conditions are x(0) = −1.6, y(0) = 0, and z(0) = 1.6.
To demonstrate that the output is chaotic one can use MATLAB to plot a time series plot for
one of the variables against time.
% Chua’s circuit.
Chua=inline(’[15*(x(2)-x(1)-(-(5/7)*x(1)+(1/2)*(-(8/7)-(-5/7))*(abs(x(1)+1)-abs(x(1)-1))));
x(1)-x(2)+x(3);-25.58*x(2)]’,’t’,’x’);
options = odeset(’RelTol’,1e-4,’AbsTol’,1e-4);
% Use the ode45 solver for 0<t<100 and initial conditions (-1.6,0,1.6).
[t,xb]=ode45(Chua,[0 100],[-1.6,0,1.6],options);
% Plot a time series, y against t. You could also plot x and z against t.
plot(t,xb(:,2),’k’)
fsize=15;
title(’Time series’,’FontSize’,fsize)
set(gca,’xtick’,[0:20:100],’FontSize’,fsize)
set(gca,’ytick’,[-0.6:0.2:0.6],’FontSize’,fsize)
xlabel(’time’,’FontSize’,fsize)
ylabel(’y’,’FontSize’,fsize)
Chua’s circuit is investigated in some detail in [10] and exhibits many interesting phenomena in-
cluding period-doubling cascades to chaos, intermittency routes to chaos, and quasi-periodic routes
to chaos, for example. For certain parameter values, the solutions lie on a double-scroll attractor,
as shown in Figure 1.14. The MATLAB program for the 3D plot is listed below.
1
z(t)
−1
−2
−3
−4
−3
−2
−1
−0.4
0 −0.3
−0.2
1 −0.1
0
0.1
2 0.2
0.3
x(t) 3 0.4
y(t)
Figure 1.14: Chua’s double-scroll attractor: Phase portrait for system (1.8) when a = 15, b =
25.58, c = −5/7, and d = −8/7. The initial conditions are x(0) = −1.6, y(0) = 0, and z(0) = 1.6.
Chua=inline(’[15*(x(2)-x(1)-(-(5/7)*x(1)+(1/2)*(-(8/7)-(-5/7))*(abs(x(1)+1)-abs(x(1)-1))));
x(1)-x(2)+x(3);-25.58*x(2)]’,’t’,’x’);
options = odeset(’RelTol’,1e-4,’AbsTol’,1e-4);
[t,xb]=ode45(Chua,[0 100],[-1.6,0,1.6],options);
% Plot a 3-D figure.
plot3(xb(:,1),xb(:,2),xb(:,3))
title(’Chua‘s Double Scroll Attractor’)
The Chua System
f(u)
1
Out1
xdot
1
u(1)−u(2)+u(3) Demux
s
ydot Integrator
Mux Demux XY Graph
−25.58*u(2)
zdot
fsize=15;
xlabel(’x(t)’,’Fontsize’,fsize);
ylabel(’y(t)’,’Fontsize’,fsize);
zlabel(’z(t)’,’FontSize’,fsize);
Click on the Rotate 3D icon at the top of the Figure plot to rotate the 3-dimensional image.
The dynamics are more complicated than those appearing in either the Rössler or Lorenz attractors.
Chua’s circuit has proved to be a very suitable subject for study since laboratory experiments
produce results which match very well with the results of the mathematical model. Recently, the
author and Borresen [3] have shown the existence of a bistable cycle for Chua’s electric circuit for
the first time. Power spectra for Chua’s circuit simulations are used to show how the qualitative
nature of the solutions depends on the history of the system.
The Simulink toolbox can be used to construct a Chua’s circuit simulation. In Figure 1.15, the
three blocks on the left represent the system of three differential equations, the outputs of which
are linked to a Mux block which combines its inputs into a single vector output. The Integrator
block (denoted by 1s ) outputs the integral of its input at the current time step. The vector then
feeds back to the system of differential equations and is also linked to the Demux block which
extracts the components of an input signal and outputs the components as separate signals. The
x and y outputs are then linked to the XY Graph block which shows how the solution evolves in
time. Note that the three-dimensional attractor is plotted in two dimensions.
Two Chua’s circuits can be connected to demonstrate synchronization of chaos which has been
well documented in the literature, see for example [2] and [7]. Note that the initial conditions for
both Chua systems are different (the top circuit has initial conditions (15, 20, 30) and the lower
circuit has initial conditions (10, 20, 20)). If the systems were not coupled they would be behaving
in an unsynchronized fashion. By taking the x output from the first Chua’s circuit and feeding it
in to the second Chua’s circuit, the circuits can be made to synchronize. If you click on the XY
Graph block you get the y = x line indicating that the y outputs from both circuits are identical.
Of course, the x and z outputs are also synchronized. For applications of chaos synchronization
please see the references listed above.
P ∝ I ∝ |E|2 .
If the electric field crosses the coupler, then a phase shift is induced which is represented by a
multiplication by j in the equations. Assume that there is no loss at the coupler. Then across the
coupler the complex field amplitudes satisfy the following equations:
√ √
E1 = κE2 + j 1 − κEin (1.9)
and
√ √
Eout = κEin + j 1 − κE2 , (1.10)
Chua Synchronization
f(u)
xdot
1
u(1)−u(2)+u(3) Demux
s
ydot Integrator 1
Mux
Out1
Demux
−25.58*u(2)
zdot
f(u) XY Graph
xdot1 4
3
Out4
Out3
1
u(1)−u(2)+u(3) Demux Demux
s
ydot1 Integrator1
Mux1
2
Demux2 Mux2 Out2
−25.58*u(2) Demux1
zdot1
where κ is the power-splitting ratio at the coupler. Consider the propagation from E1 to E2 . Then
E2 = E1 ejφ , (1.11)
where the total loss in the fiber is negligible (typically about 0.2 dB/km) and
φ = φL + φN L .
The linear phase shift is φL , and the nonlinear phase shift due to propagation is given by
2πr2 L
φN L = |E1 |2 ,
λ0 Aeff
where λ0 is the wavelength of propagating light in a vacuum, Aeff is the effective core area of the
fiber, L is the length of the fiber loop, and r2 is the nonlinear refractive index coefficient of the
E in κ:1−κ
E out
E2 E1
Figure 1.17: The SFR resonator. The electric field entering the fiber ring is labelled E1 and the
electric field leaving the fiber ring is labelled E2 . The coupler splits the power intensity in the ratio
κ : 1 − κ.
fiber. It is well known that when the optical intensity is large enough, the constant r2 satisfies the
equation
r2 r0 P
r = r0 + r2 I = r0 + |E1 |2 = r0 + r2 ,
2η0 Aeff
where r is the refractive index of the fiber, r0 is the linear value, I is the instantaneous optical
intensity, P is the power, and Aeff is the effective cross-sectional area of the fiber. If the nonlinearity
of the fiber is represented by this equation, then the fiber is said to be of Kerr type. In most
applications, it is assumed that the response time of the Kerr effect is much less than the time
taken for light to circulate once in the loop.
Substitute (1.11) into equations (1.9) and (1.10). Simplify to obtain
√ √
E1 (t) = j 1 − κEin (t) + κE1 (t − tR )ejφ(t−tR ) ,
where tR = rL c is the time taken for the light to complete one loop, r is the refractive index, and
c is the velocity of light in a vacuum. Note that this is an iterative formula for the electric field
amplitude inside the ring. Take time steps of length equal to tR . This expression can be written
more conveniently as an iterative equation of the form
2πr2 L 2
En+1 = A + BEn exp j |En | + φL , (1.12)
λ0 Aeff
√ √
where A = j 1 − κEin , B = κ, and Ei is the electric field amplitude at the ith circulation
around the fiber loop. Typical fiber parameters chosen for this system are λ0 = 1.55 × 10−6 m,
r2 = 3.2 × 10−20 m2 W −1 , Aeff = 30 µm2 , and L = 80 m.
Equation (1.12) may be scaled without loss of generality to the simplified equation
where |B| < 1. The Ikeda map can have fixed points of all periods. In this particular case, system
(1.14) can have many fixed points of period one depending on the parameter values A and B.
Example 4. Determine and classify the fixed points of period one for system (1.14) when B = 0.15
and
(i) A = 1;
(ii) A = 2.2.
Solution. MATLAB is used to solve the equations and to plot the implicit curves, however, you
have to be very careful here. The fixed points of period one (xn+1 = xn = x, yn+1 = yn = y) satisfy
the simultaneous equations
y = Bx sin(x2 + y 2 ) + By cos(x2 + y 2 ).
>> syms x y.
>> [x,y]=solve(’1+0.15*(x*cos(x^2+y^2)-y*sin(x^2+y^2))-x’,
’0.15*(x*sin(x^2+y^2)+y*cos(x^2+y^2))-y’)
The MATLAB commands above give one solution when A = 1, B = 0.15, namely, approximately
(1.048, 0.151), which in this case is the only solution. However, if you solve the same set of equa-
tions with A = 2.2, B = 0.15, then MATLAB again gives one solution, but this is incorrect. To
see that there is more than one solution plot the implicit curves defined by equations (1.14).
hold on
axis([0 4 -4 4])
ezplot(’2.2+0.15*(x*cos(x^2+y^2)-y*sin(x^2+y^2))-x’)
ezplot(’0.15*(x*sin(x^2+y^2)+y*cos(x^2+y^2))-y’)
hold off
(i) When A = 1 and B = 0.15, there is one solution at x1,1 ≈ 1.048, y1,1 ≈ 0.151. The solution
is given graphically in Figure 1.16(a). To classify the critical point P ∗ = (x1,1 , y1,1 ), consider the
Jacobian matrix
!
∂P ∂P
∂x ∂y
J(P ∗ ) = .
∂Q ∂Q
∂x ∂y ∗
P
The eigenvalues of the Jacobian matrix at P ∗ are easily computed with MATLAB, λ1 ≈ −0.086 +
0.123j and λ2 ≈ −0.086 − 0.123j. Therefore, as the modulus of both eigenvalues is less than one,
P ∗ is a stable fixed point of period one.
(ii) When A = 2.2 and B = 0.15, there are three points of period one, as the graphs in
Figure 1.16(b) indicate. Note that the solve command does not give all three solution here. The
fixed points occur approximately at the points U = (2.562, 0.131), M = (2.134, −0.317) and
L = (1.968, −0.185). Using the Jacobian matrix, the eigenvalues for U are λ1,2 = −0.145 ± 0.039j;
the eigenvalues for M are λ1 = 1.360, λ2 = 0.017; and the eigenvalues for L are λ1 = 0.555,
λ2 = 0.041.
3 3
2 2
1 1
0 0
y
y
−1 −1
−2 −2
−3 −3
0 0.5 1 1.5 2 2.5 3 3.5 4 0 0.5 1 1.5 2 2.5 3 3.5 4
x x
(a) (b)
Figure 1.18: The fixed points of period one are determined by the intersections of the two curves,
x = A + 0.15x cos(x2 + y 2 ) − 0.15y sin(x2 + y 2 ) and y = 0.15x sin(x2 + y 2 ) + 0.15y cos(x2 + y 2 ); (a)
A = 1 and (b) A = 2.2. Use the data cursor to locate the fixed points in the figure.
Therefore, U and L are stable fixed points of period one, while M is an unstable fixed point
of period one. These three points are located within a bistable region of the bifurcation diagram
given later in this chapter. The point U lies on the upper branch of the hysteresis loop and the
point L lies on the lower branch. Since M is unstable it does not appear in the bifurcation diagram
but is located between U and L.
To investigate the stability of the nonlinear SFR resonator, a linear stability analysis will be
applied. A first-order perturbative scheme is used to predict the values of a parameter where the
stationary solutions become unstable. Briefly, a small perturbation is added to a stable solution
and a Taylor series expansion is carried out, the nonlinear terms are ignored, and a linear stability
analysis is applied, see [12] for a detailed description. Table 1.2 lists the first two regions of
bistability and instability for the SFR for a range of fixed values of the parameter B computed
using a linear stability analysis.
To end the chapter, bifurcation diagrams will now be plotted for the SFR using the first and
second iterative methods given in the second section.
The following programs are used to plot Figures 1.19 and 1.20 when B = 0.15. Figure 1.19
shows the bifurcation diagram using the first iterative method without feedback, note that there
is no bistable region in this figure. Figure 1.20 displays the bifurcation diagram with a feedback
Table 1.2: The first two regions of bistability and instability computed for the SFR resonator to
three decimal places using a linear stability analysis.
mechanism incorporated. The first bistable region is clearly visible and makes interesting compar-
ison with the results of Table 1.2. Note that the second bistable region has not materialised due
to instabilities. Edit the program below to plot your own bifurcation diagrams for varying values
of B and compare the plot with the results in Table 1.2. An animated bifurcation diagram can be
downloaded from the MathWorks Central File Exchange.
25
20
Output Power
15
10
0
0 4 8 12 16
Input Power
Figure 1.20: Bifurcation diagram for the SFR when B = 0.15 using the second iterative method
with feedback. A hysteresis cycle is clearly visible.
Bibliography
34
[16] S.K. Scott, Oscillations, Waves, and Chaos in Chemical Kinetics, Oxford University Press,
1994.
[17] A. Siciliano, Matlab: Data Analysis and Visualization, World Scientific, 2008.
[18] Yu-Shu Chien and Ching-Tien Liou, Steady-state multiplicity for autocatalytic reactions in a
nonideal mixing of CSTR with two unpremixed feeds,Chemical Engineering Science, 50, No.
22, 3645-3650, 1995.