
Do you know this guy? You should. His name is Edward Lorenz and he’s the guy that created a simplified method of of modeling convection rolls that come about in equations describing atmospheric activity. Heck yeah he did. He published this paper Deterministic Nonperiodic Flow in the Journal of Atmospheric Sciences in 1963. This paper gave the basis for the eventual Chaos Theory. Whats the point of this history lesson? Well in order to model such physical and biological phenomena, you must use systems of differential equations. And these systems are the topic of the this the third block.
Lorenz’s method was made up of the following three equations:



These three linked differential equations include the three parameters σ, ρ, and β are all positive. σ is called the Prandtl Number and β is known as the Rayleigh Number. Both of these postive paremters pertain to the physical properties of a fluid in motion. Most commonly they are set to σ = 10 and β = 8/3. Varying the values of ρ yield qualitativly differing solution curves for a specific system. Setting ρ = 28 you get what has come to be known as the lorenz attractor. This solution curve which looks similar to an opened zebra mussle, is said to be chaotic as all nearby points diverge almost exponentially rapid.

The objective of this the third block is to further our exploration of the Euler method of approximation by applying it to systems of differential equations. I will do this by comparing exact solutions to the Euler approximations. Specifically I will experiment with various paremters in both the Lorenz and Rössler Systems of differential equations.
The Euler Method M-file I had used for previous blocks is null and void to this block since we are now discussing systems verses just a single differential equation. The code for this new M-file is as follows:
% Euler’s method for a system of differential equations.
% The differential equations are dy/dt = f(t,y) where y is a vector of unknown functions.
function [ t, y ] = euler_system( f, t_range, y_initial, nstep )
% We set a range of time values, from t(1) to t(2).
t(1) = t_range(1);
% We define dt by dividing the time range into an equal number of specified steps.
dt = ( t_range(2) – t_range(1) ) / nstep;
% We set the initial value of the vector y at the beginning time t(1).
y(:,1) = y_initial;
% We use Euler’s method to update the value of y at new time steps.
% “feval” is used instead of “eval” because we are passing the name of f to the program.
for i = 1 : nstep
t(i+1) = t(i) + dt;
y(:,i+1) = y(:,i) + dt * feval ( f, t(i), y(:,i) );
end
% The following command plots the components of y as functions of t.
plot(t,y)
% We also want a 3D plot of the vector components as they vary with t.
plot3(y(1, : ),y(2, : ),y(3, : ))
Saving this as euler_system.m I could then use it to plot both 2D and 3D approximations. Next I needed to create another m-file as done before, to specify the argument for the euler_system.m file to approximate. First I analyzed the Lorenz equations making the following code:
function yprime = lorenz_system ( t, y )
yprime = [ 10.0* (y(2)-y(1)); y(1)*(28.0-y(3))-y(2);y(1)*y(2)-(8/3)*y(3) ];
The three bolded numbers are the values inputed for σ, ρ, and β respectively. To then produce the 2D and 3D plots I had to input the following code into the MATLAB command window. The range of t values is set from 0-20 and the needed number of steps is set to 1000.
>> y_init = [ rand(); rand(); rand() ];
>> [ t, y ] = euler_system ( ‘lorenz_system’, [ 0.0, 20.0 ], y_init, 1000 );
The code produces the following two graphs:
2D Euler:

3D Euler:

The first 2D plot is very chaotic, having no real pattern to its curves. The blue and green lines as are closly related in that they follow pretty much the same path at an approximately constant deviation. The red line on the other hand differs greatly in value and though at first might look symmetric after closer examination is fairly independant of its counterparts paths. The 3D plot exemplifies mathematical entropy. The two dual spiral created is in no aspect uniform. The values diverging exponetially create a spirally effect that shifts planes as closes inward. Notice each ring in the spiral are at different spacing, with no inclination towards convergence or divergence. Next I will see how an ode45 solution will compare.
First I created an M-file denoteing the variables σ, ρ, and β:
function xdot = g(t,x)
xdot = zeros(3,1);
sig = 10.0;
rho = 28.0;
bet = 8.0/3.0;
xdot(1) = sig*(x(2)-x(1));
xdot(2) = rho*x(1)-x(2)-x(1)*x(3);
xdot(3) = x(1)*x(2)-bet*x(3);
Next I created an M-file to run this prior g.m file in an ode45 function:
function lorenz_demo(time)
% Usage: lorenz_demo(time)
% time=end point of time interval
% This function integrates the lorenz attractor
% from t=0 to t=time
[t,x] = ode45(’g’,[0 time],[1;2;3]);
disp(’press any key to continue …’)
pause
plot3(x(:,1),x(:,2),x(:,3))
print -deps lorenz.eps
3D ode45:

Remembering that in these examples, ρ =28 meaning the solution was to be chaotic. Ode45 produces this very similar dual spiral solution as had Euler’s. There are many more rings in each spiral making it look more uniform but In reality it is just as chaotic. Having more lines at this scale just makes it nearly impossible to see specific portions of curves. The reason there are more values involved is that ode45 has a much larger time range then Eulers method uses. This makes for a more exact solution in most cases but because this solution is chaos, it merely just produces more values.
Using the same two methods of analysis, that is; the same codes, I’ll see how switching the ρ value effects the solution. Setting ρ = 8, I produced the follwowing plots:
Euler 2D:

Euler 3D:

ode45 3D:

In the 2D plot the red line has very similar behavior to that of the blue and green. All three lines rather quickly converge to a single dimension(only one varying value). In the 3D plots, this same convergence can be scene by the single relatively uniform spiral. The ode45 spiral this time has less rings and is more of a consistant inward spiral then the less accurate Euler apporximation. The Euler spiral pinches at the bottom, in proximity to the set initial value of the origin. Yet the portion of spiral away from this initial point is more arcing. I interpret this as an example of Euler’s Methods flaws. From this comparison I can see that decreasing the value of ρ allows for more order in approximating a solution.
Next I will move on to experimenting with a Rossler system of differential equations. The equations are as follow:


These are all ordinary non-linear differential equations that define a chaotic system that varies over a time interval Δt. These equations are defined by the parameters a, b and c. Rössler studied the attractor created by these equations with the parmeters set to: a=0.2, b=0.2 and c=5.7. This Rössler Attractor is pictured below(image provided by wikipedia.org):

Most of the spiral is in the xy plane. This is because only two of the equations are influenced by values in the z-direction. Furthermore when z=0 the two equations become linear and the other is a constant. This allows for easy analysis in only the xy plane. I would have to assume aswell from my new knowledge of the first order nature of Eulers approximation that when z=0 a solution will be more easily and accurately estimated. Notice how in the xy-plane the spiral seems to be about an approximate center, but then all the portion extruded into the z-direction twists and defines a different point of reference. This change happens as the x and y values spiral in towards the origin(0,0), allowing the z variable to have more influence of the behavior. While obtaining the wonderful image from wikipedia I read that the values a=0.1, b=0.1 and c=14 are of the most common in use of the Rössler system. I will follow the same procedure as before with the lorenz equations. Using the same euler M-file, I then need only to redefine the equations and their respected parameters.
The new function M- file is:
function yprime = rossler_system ( t, y )
yprime = [-(y(2))-y(3);y(1)+(0.2*y(2));0.2+(y(3)*(y(1)-5.7))];
Once again I made the set parameter values bold to make is easier for you my reader to pick them out. In this first attempt I am using the same parameters Rössler used in his study. Inputing the following command into MATLAB will produce a 2D and 3D solution curve.
>>y_init=[ rand(); rand(); rand() ];
>>[ t, y ] = euler_system ( ‘rossler_system’, [-50.0, 50.0 ], y_init, 10000 );
Euler 2D:

Euler 3D:

In the 2D plot, the green line seems to be slightly ahead of the blue line but their overall behavior is equivalent. The red line is similar in that it spikes when the largest ocsillations occur in the other lines. The overal behavior of either line is highly chaotic. The only pattern that could be put to it is a repeating progression of increasing amplitude which resets at differents values over seemingly un related intervals. The 3D plot is a Rössler Attractor like the previous image. Eulers method produces very few curves but the rebelous nature of the z-orbitals can still be viewed. I saw when analyzing the Lorenz Attractor, ode45 produce more curves with such levels of chaos. So my next step is to creat two new M-files. First to denote the equations and their parameters then to run that file in an ode45 function.
rossler.m:
function xdot = rossler(t,x)
xdot = zeros(3,1);
a = 0.2;
b = 0.2;
c = 5.7;
xdot(1) = -(x(2))-x(3);
xdot(2) = x(1)+a*x(2);
xdot(3) = b+x(3)*(x(1)-c);
ode45.m:
function rossler_demo(time)
[t,x] = ode45(’rossler’,[0 time],[1;2;3]);
disp(’press any key to continue …’)
pause
plot3(x(:,1),x(:,2),x(:,3))
print -deps rossler.eps
Then inputting the following command into MATLAB will produce the desired plot.
>>rossler_demo(200)

My assumption was correct. Ode45 produced created a greater number of approximations. Recalling that ode45 is a 4th order method of approximation compared to Euler’s which is a first order, this situation seems appropriate. Also the fact that ode45 is being solved over the time range 0-200 where as the euler is -50-50; makes for a created number of curves in its plot. Regardless both solutions seem t gravitate around the same two approximate areas. Finally I am going to test what will happen if I change all three parameters. I noticed most of the talked about sets of parameter values puts c equal to a much higher number then a and b. Since we already saw that a high ρ value in the lorenz equations yields greater chaos, I thought I’d try a c value in the same area as a and b. My partner Paul Hannah and I decided to just pick three completely arbitrary values that were all less then 1. The values and code are as follows:
a=0.7 b=0.11 c=0.54
rossler_systerm.m
function yprime = rossler_system ( t, y )
yprime = [-(y(2))-y(3);y(1)+(0.7*y(2));0.11+(y(3)*(y(1)-0.54))];
MATLAB Command:
>>y_init=[ rand(); rand(); rand() ];
>>[ t, y ] = euler_system ( ‘rossler_system’, [ 0.0, 10.0 ], y_init, 5000 );
Euler 2D:

Euler 3D:
rossler.m:
function xdot = rossler(t,x)
xdot = zeros(3,1);
a = 0.7;
b = 0.11;
c = 0.54;
xdot(1) = -(x(2))-x(3);
xdot(2) = x(1)+a*x(2);
xdot(3) = b+x(3)*(x(1)-c);
ode45.m:
function rossler_demo(time)
[t,x] = ode45(’rossler’,[0 time],[1;2;3]);
disp(’press any key to continue …’)
pause
plot3(x(:,1),x(:,2),x(:,3))
print -deps rossler.eps
MATLAB Command:
>>rossler_demo(15)

Looking at the 2D Euler approximation you can instantly see that there is very little if any structure in the lines. That fact plus the magnitude of lines involved in the ode45 solution lead me to believe that decreasing the c value does not necessarilly lead to greater order. Furthermore the Euler 3D plot seems to be almost linear on the bottom of the cornucopia shaped spiral. The ode45 plot seems to be more consistant in its spiralling. I believe this can be again attributed to the difference in the methods of approximation. Where the Euler aproximation seems linear in the spirally is due to it’s first order method of estimating solutions plus the fact that its occuring around z=0. As you can recall from earlier in this, my Block 3 blog, I discussed that when z=0, the equations become linear:


With the third being constant at b.
So with now three blocks completed, I look excitedly on to my future in this exploration of differential equations. Remembering of course, the information already obtained. This isn’t difficult though, as many of the main ideas continue to be examined in each of our blocks. Idea’s such as understanding types of approximation methods makes analysis an easier process. Well I hope you’ve enjoyed “Block 3” brought to you by Nick Campbell. An extra happy Patriots Day to everyone! Until next time, take it easy…