- Explore how exact solutions to first order differential equations differ from Euler approximations.
- Experiment with Euler approximations to the Lorenz equations for various parameter values and initial conditions.
- The Lotka-Volterra predator-prey equations are
where y is the number of predators, x is the number of prey, and
are parameters that tune the interaction of the predators and prey. Explore solutions of the predator-prey equations for varying parameter values and initial conditions.
- Explore the behavior of the Rössler system of differential equations
for various parameter values and initial conditions.

2nd Assignment:1st order vs. Euler’s
First Order Differential vs. Euler’s Approximation
In the Second 3 week block, Laquita and I we assigned the following to complete:
The above 4 steps was taking from the professor’s page.
We were assigned the following linked equations:
Laquita and I followed the example on the professor’s page and realized that it is more simple to use Euler’s method to a first order differential equation because you can find the answer to any point but you would be less precise. A more precise way is to use separation of variables. We also assumed that Euler’s Approximation is more difficult to first order differential equations in Excel because it’s numerical. Also, Euler’s method can give a bigger margin of error the farther you go from the initial condition when an actual precise answer is needed. This system was also different because the Euler Approximation equations were linked. So now, Laquita and I wrote excel formula’s like we did in the first 3 week block, to create Euler’s method for the three linked equations and to collect graphs of our data.
THE LORENZ ATTRACTOR:
In the second 3 week block I focused on the Lorenz Attractor. The lorenz Attractor as stated in wikipedia is “a 3-dimensional structure corresponding to the long-term behavior of a chaotic flow, noted for its butterfly shape.” Edward Lorenz was a meterologist who accidental discovered the chaos theory. He wanted to prove that fully predicting the weather was nearly impossible.
Because the lorenz Attractor is expressed as 3 linear equations, the equations above was used. An easy way of understanding these equations was to use euler’s method in excel. Euler’s method helped me get an aproximation solution for my equations. My x(t), y(t), & z(t) were given random numbers while sigma, beta, and rho were given from an example but slightly modified. Sigma and rho are both related to kinematic viscosity and heat flow. So, I made my sigma = 10, beta = 8/3, and rho = 28 as seen in the table below:This is the formula command that was used for (t): C2 + $B$4, for x(t) was: D2 + $B$4*($B$1*(E2-D2))
| sigma: | 10 | t | x(t) | y(t) | z(t) |
| beta: | 2.6667 | 0 | 0.2 | 0.89 | 0.52 |
| rho: | 50 | 0.01 | 0.3 | 1 | 0.51 |
| delta t | 0.01 | 0.02 | 0.4 | 1.14 | 0.5 |
| 0.03 | 0.4 | 1.31 | 0.49 | ||
| 0.04 | 0.5 | 1.52 | 0.48 | ||
| 0.05 | 0.6 | 1.77 | 0.48 | ||
| 0.06 | 0.7 | 2.07 | 0.47 | ||
| 0.07 | 0.9 | 2.41 | 0.48 | ||
| 0.08 | 1 | 2.83 | 0.49 | ||
| 0.09 | 1.2 | 3.31 | 0.5 | ||
| 0.1 | 1.4 | 3.88 | 0.53 | ||
| 0.11 | 1.7 | 4.54 | 0.57 | ||
| 0.12 | 2 | 5.32 | 0.63 | ||
| 0.13 | 2.3 | 6.23 | 0.72 | ||
| 0.14 | 2.7 | 7.3 | 0.84 | ||
| 0.15 | 3.1 | 8.55 | 1.01 | ||
| 0.16 | 3.7 | 10 | 1.26 | ||
| 0.17 | 4.3 | 11.7 | 1.59 | ||
| 0.18 | 5.1 | 13.7 | 2.05 | ||
| 0.19 | 5.9 | 16 | 2.69 | ||
| 0.2 | 6.9 | 18.6 | 3.56 |
Because excel does not allow us to plot the points in three dimensional graphs, I plotted the points x, y, z, as a function of t. As you can see below, the curves for x(t) and y(t) have similar curves but the curve for z(t) is completely different from the previous curves.
FIGURE 1
Because Excel can’t plot graphs in 3 dimensions I broke up my graphs into three parts:
-
y(t) vs. z(t) = FIGURE 2
-
y(t) vs. x(t) = FIGURE 3
-
x(t) vs. z(t) = FIGURE 4
y(t) versus x(t)
FIGURE 2
y(t) versus x(t)
FIGURE 3
x(t) versus z(t)
FIGURE 4
Now I used matlab to get a better approximation of the Lorenz Attractor. I also used matlab to generate 3d graphs which would help me visualize what is happenning in the lorenz attractor. Because this website (Simple ODE Methods) presented a very good explanation of Euler’s Method in matlab, The following code was based off that website and the professors’s website.
Steps:
Write and save the following as an M file called euler.m in matlab text editior :
function [ t, y ] = euler ( f, t_range, y_initial, nstep )
t(1) = t_range(1);
dt = ( t_range(2) – t_range(1) ) / nstep;
y(1) = y_initial;
for i = 1 : nstep
t(i+1) = t(i) + dt;
y(i+1) = y(i) + dt * feval ( f, t(i), y(i) );
end
plot(t,y)
Next we write the following as an M file and save it as test_example:
function yprime = test_example ( t, y )
yprime = y*(2./t-1);
Now we will run the program by installing these commands in matlab. At first when I tried this part it didn’t work because I had to re-type the quotation marks:
>> y_init = 0.1;
>> [ t, y ] = euler ( ‘test_example’, [ 0.1, 9.0 ], y_init, 200 );
- After the inputs are placed and the program is run, matlab will generate this graph:
FIGURE 5
-
Now we will create an M file that will modify our Lorenz equations. We will name it euler_system.m
function [ t, y ] = euler_system( f, t_range, y_initial, nstep )
t(1) = t_range(1);
dt = ( t_range(2) – t_range(1) ) / nstep;
y(:,1) = y_initial;
for i = 1 : nstep
t(i+1) = t(i) + dt;
y(:,i+1) = y(:,i) + dt * feval ( f, t(i), y(:,i) );
end
plot(t,y) plot3(y(1,:),y(2,:),y(3,:))
1.Likewise we will now create another M file and save it as Lorenz_system.m
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*y(3)/3 ];
2.Now we will run the command by typing the following inputs in matlab:
>> y_init = [ rand(); rand(); rand() ];
>> [ t, y ] = euler_system ( ‘lorenz_system’, [ 0.0, 20.0 ], y_init, 1000 );
3.The following two graphs are given:
FIGURE 6
FIGURE 7
Here Is a youtube video that displays the Lorenz Attractor
PREDATOR VS. PREY ( Lotka–Volterra equations):
“The Lotka–Volterra equations, also known as the predator-prey equations, are a pair of first order, non-linear, differential equations frequently used to describe the dynamics of biological systems in which two species interact, one a predator and one its prey. They were proposed independently by Alfred J. Lotka in 1925 and Vito Volterra in 1926.” (Wikipedia)
The Lotka-Volterra equations are:
-
y is the number of predators
-
x is the number of its preys
-
&
represent the growth of the two populations against time;
-
t represents time
-
,
,
,
are parameters that represent the interation between two species.
-MATLAB-
MATLAB INPUTS:
>>% Define initial conditions.
>>t0 = 0;
>>tfinal = 15;
>>y0 = [20 20]‘;
>>% Simulate the differential equation.
>>tfinal = tfinal*(1+eps);
>>[t,y] = ode23(‘lotka’,[t0 tfinal],y0);
>>subplot(1,2,1)
>>plot(t,y)
>>title(‘Time history’)
>>subplot(1,2,2)
>>plot(y(:,1),y(:,2))
>>title(‘Phase plane plot’ )
The graph below is generated
>>[T,Y] = ode45(‘lotka’,[t0 tfinal],y0);
>>subplot(1,1,1)
>>title(‘Phase plane plot’)
>>plot(y(:,1),y(:,2),’-',Y(:,1),Y(:,2),’-');
>>legend(‘ode23′,’ode45′)
the graph below is generated
The 2 graphs above represent Predator vs. Prey. The prey represent the blue and the predators represent the green. As the prey increses in numbers the predators increase, but as the predators increases the prey’s decreases and since the prey’s are decreasing, the predator’s are increasing. This is a cycle that continues on and on.
-Excel-
My Formulas are:
Below is my graph for Predator vs. Prey that I created on excel. This graph is similar to the 2 previous graphs above and once again as the prey increses in numbers the predators increase, but as the predators increases the prey’s decreases and since the prey’s are decreasing, the predator’s are increasing. This graph looks like it’s oscillating.
Here is my table for my excel graph above:
| Delta (t) | 0.01 | t | Prey | Predator |
| Alpha | 1 | 0 | 25 | 25 |
| Beta | 0.01 | 0.01 | 25.1875 | 24.875 |
| Gamma | 1 | 0.02 | 25.37672 | 24.75156 |
| Delta | 0.02 | 0.03 | 25.56768 | 24.62966 |
| 0.04 | 25.76038 | 24.50931 | ||
| 0.05 | 25.95485 | 24.39049 | ||
| 0.06 | 26.15109 | 24.2732 | ||
| 0.07 | 26.34913 | 24.15742 | ||
| 0.08 | 26.54896 | 24.04315 | ||
| 0.09 | 26.75062 | 23.93038 | ||
| 0.1 | 26.95411 | 23.81911 | ||
| 0.11 | 27.15945 | 23.70933 | ||
| 0.12 | 27.36665 | 23.60102 | ||
| 0.13 | 27.57573 | 23.49418 | ||
| 0.14 | 27.7867 | 23.38882 | ||
| 0.15 | 27.99958 | 23.28491 | ||
| 0.16 | 28.21438 | 23.18245 | ||
| 0.17 | 28.43111 | 23.08144 | ||
| 0.18 | 28.6498 | 22.98188 | ||
| 0.19 | 28.87046 | 22.88374 | ||
| 0.2 | 29.0931 | 22.78704 | ||
| 0.21 | 29.31773 | 22.69176 | ||
| 0.22 | 29.54438 | 22.59789 | ||
| 0.23 | 29.77306 | 22.50544 | ||
| 0.24 | 30.00379 | 22.4144 | ||
| 0.25 | 30.23657 | 22.32476 | ||
| 0.26 | 30.47144 | 22.23652 | ||
| 0.27 | 30.70839 | 22.14967 | ||
| 0.28 | 30.94746 | 22.06421 | ||
| 0.29 | 31.18865 | 21.98013 | ||
| 0.3 | 31.43198 | 21.89743 | ||
| 0.31 | 31.67748 | 21.81612 | ||
| 0.32 | 31.92514 | 21.73617 | ||
| 0.33 | 32.175 | 21.65759 | ||
| 0.34 | 32.42707 | 21.58039 | ||
| 0.35 | 32.68136 | 21.50454 | ||
| 0.36 | 32.93789 | 21.43005 | ||
| 0.37 | 33.19669 | 21.35693 | ||
| 0.38 | 33.45775 | 21.28515 | ||
| 0.39 | 33.72112 | 21.21473 | ||
| 0.4 | 33.98679 | 21.14566 |
The video below is an example of predator vs. prey that I found on youtube.
—————————————————————————————————————————————————-
Rössler system of differential equations
I used the equations above to generate an excel table and graph.
Below is my Table for the Rossler Attractor.
| alpha | 0.1 | 0 | 0.865348 | 0.891994 | 0.084655 |
| beta | 0.1 | 0.03 | 0.836049 | 0.92063 | 0.054298 |
| gamma | 14 | 0.06 | 0.806801 | 0.948473 | 0.035854 |
| 0.09 | 0.777271 | 0.975523 | 0.024663 | ||
| 0.12 | 0.747266 | 1.001767 | 0.01788 | ||
| 0.15 | 0.716676 | 1.027191 | 0.013771 | ||
| 0.18 | 0.685448 | 1.051773 | 0.011283 | ||
| 0.21 | 0.653556 | 1.075491 | 0.009776 | ||
| 0.24 | 0.620998 | 1.098325 | 0.008862 | ||
| 0.27 | 0.587782 | 1.120249 | 0.008305 | ||
| 0.3 | 0.553926 | 1.141244 | 0.007963 | ||
| 0.33 | 0.519449 | 1.161285 | 0.007751 | ||
| 0.36 | 0.484378 | 1.180352 | 0.007616 | ||
| 0.39 | 0.448739 | 1.198425 | 0.007528 | ||
| 0.42 | 0.412561 | 1.215482 | 0.007468 | ||
| 0.45 | 0.375872 | 1.231506 | 0.007424 | ||
| 0.48 | 0.338704 | 1.246476 | 0.007389 | ||
| 0.51 | 0.301088 | 1.260377 | 0.007361 | ||
| 0.54 | 0.263056 | 1.273191 | 0.007336 | ||
| 0.57 | 0.22464 | 1.284902 | 0.007313 | ||
| 0.6 | 0.185874 | 1.295496 | 0.007291 | ||
| 0.63 | 0.14679 | 1.304958 | 0.007269 | ||
| 0.66 | 0.107423 | 1.313277 | 0.007248 | ||
| 0.69 | 0.067808 | 1.32044 | 0.007227 | ||
| 0.72 | 0.027978 | 1.326435 | 0.007207 | ||
| 0.75 | -0.01203 | 1.331254 | 0.007186 | ||
| 0.78 | -0.05218 | 1.334887 | 0.007165 | ||
| 0.81 | -0.09245 | 1.337326 | 0.007145 | ||
| 0.84 | -0.13278 | 1.338564 | 0.007124 | ||
| 0.87 | -0.17315 | 1.338597 | 0.007104 | ||
| 0.9 | -0.21352 | 1.337418 | 0.007083 |
This is the graph for the Rossler Attractor.

Rossler Period Duplication Video









