THIRD BLOCK

In the third block we will be looking at the three dimensional graphs using both Euler’s method and the Ode45 method from last block. The lorenz equations are the given examples we will be analyzing with these graphs. The block will conclude with an analysis of the Rossler system of differential equations. 

The Lorenz Attractor is made up of three equations, which are 

dx/dy=σ(y-x)

dx/dt=x(ρ-x)

dz/dt=xy-βz 

The first step we need to take before we can get any of our approximations we must modify our m files from previous blocks. We use the following code: 

function[t,y] = eulerpm (f,t_range, y_initial, nstep)

dt = (t_range(2) – t_range(1)) / nstep;

t = t_range;

y(:,1) = y_initial;

fori = 1 :nstep

t(i+1) = t(i) + dt;

y(:,i+1) = y(i) + dt * feval( f, t(i), y(i) );

plot(t,y)

plot3( y(1,:), y(2,:), y(3,:) )

xlabel(‘t’)

ylabel(‘y’)

end

In order to evaluate the systems of equations we must change the y axis into an array input. The next step is to use the plot3 matlab command. After this the next file that must be changed is the example problem m-file called pmexample.m.

 functionyprime= pmexample(t,y)

yprime = [10.0* (y(2)-y(1)); y(1)*(28.0-y(3))-y(2);y(1)*y(2)-8*y(3)/3];

end

We must note that these values are default values to ensure that our euler program is running properly.

>> y_init = [rand(),rand(),rand()];

>> [ t, y ] = eulerpm ( ‘pmexample’, [ 0.0, 20.0 ], y_init, 1000 );

The following was graph was yeilded by MATLAB as a result,

1

As you can see, much like graphs from previous blocks, euler’s method produces rigid graphs that are not very accurate. Now let us use the Ode45 method and compare the two graphs.

Our first step is to create two m. files for this method. The first file is so we can evaluate the differential equation, and the second file we create allows us to modify the ode45 program in MATLAB, making life much easier for us.

 

pmlorenz.m:

functionxdot = pmlorenz(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);

pmlorenz2.m:

functionpmlorenz2(time)

[t,x] = ode45(‘pmlorenz’,[0 time],[1;2;3]);

disp(‘press any key to continue ?’)

pause

plot3(x(:,1),x(:,2),x(:,3))

After we enter the lorenz code into the command screan in MATLAB we can see the following lorenz equation graph produced by the ode45 method.

2

Much, much better. It is actually difficult to beleive that this is the same as the graph above but believe it so. We can see, just like the previous blocks, the ode45 method of solving these differential equations produces a much smoother, more detailed graph of the function. As you follow through the rest of this block, we will be further proving this conclusion using three more examples. In these examples, I will be using the same m. files as in the problem above with changes only in the rho sigma and beta of each. Because of this, to avoid redundency I will just include the new values of these three.

The first example will use:

Example #2:

ρ = 18

σ = 10

β = 8/3

 Euler’s Method Approximation

 4

Ode45 Method Approximation

 

5

Example 3:

σ = 10

β = 8/3

ρ = 8

Euler’s Method Approximation

euler1

Ode45 Method Approximation

ode11

Now that we have seen a few examples using the lorenz attractor it has become apparent that there is a significant difference between euler’s method and the ode45 method if solving. Each example shows how much smoother and more accurate the ode45 method is when analyzing lorenz’s system of equations.

The next step we will be taking is to show that this is not only the case for Lorenz’s system of equations, but also for Rossler’s system of equations as well. This will demonstrate that another Ode system of equations that creates an attractor as well as furthering our conclusion that euler’s method is not nearly as accurate or reliable for our use.

In order to do this, we must take similar steps as creating the lorenz system. We create two m. files, one to create a graph of the attractor and the other to set the variables and equation.

rossler.m:

function xdot = rossler(t,x)

a = 0.2;
b = 0.2;
c = 5.7;

xdot(1) = -x(2)-z;
xdot(2) = x(1)+ax(2);
xdot(3) = b+x(3)*(x(1)-c);

rossler2.m:

function rossler2(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

Example 1:

a = 0.2

b = 0.2

c = 5.7

ode21

As you can see by the graph above, this approximation has a different shape as the lorenz examples. This attractor draws the point verticaly away from the xy plane at one point allong its circular path creating a bumb or hill.

Example 2:

a = 0.1

b = 0.1

c = 4

ode3

Much like the previous problem, once again we see a similar shape with circular path and an annomoly conatined within.

We conclude with analyzing the roles of the three variables a, b and c.

Variable a is responsible for controling the spot where the annomaly enters the center. The larger the value of a is, the further from the center the path is. Variable a also controls the proximity of each revolution in comparison to the last. When we increase or decrease variable a from the value .2, it creates a swirl effect in the graph that groups the revolutions together in a circular path.

Variable b seems as though it has a direct correlation with the height of the annomoly in the graph. By varying the value of b we can see the anomoly going up or down in height.

Variable c similar to variable, controls the proximity of the revolutions as well.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.