Application Center - Maplesoft

App Preview:

Plotting solutions to differential equations

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

1202.mws

Module 12 : Differential Equation

1202 : Plotting Solutions

O B J E C T I V E

Consider the solutions to differential equations as paths through direction fields.....

S E T U P

In this project we will use the following command packages. Type and execute this line before begining the project below. If you re-enter the worksheet for this project, be sure to re-execute this statement before jumping to any point in the worksheet.

> restart; with(DEtools): with(plots):

Warning, the name changecoords has been redefined

___________________________________________________________________________________

A. Solutions to Simple Differential Equaions

___________________________________________________________________________________

A solution to a differential equation is a function that satisfies the differential equation. Using a direction field, we can see many possibile solutions. Imagine a river with a current given by the direction field. If a leaf were to fall into the river it would be swept along a path determined by those currents. The curve that the leaf sweeps out corresponds to a solution of the differential equation. However, if the leaf were to have landed in a slightly different location in the river, the path it takes may be quite different.

Here is a differential equation : y = 3x2 - 1. Since this is a simple differential equation, obviously the solutions are all of the form x3 - x + C.

> deq := diff(y(x),x) = 3*x^2 - 1;

deq := diff(y(x),x) = 3*x^2-1

In order to graph a solution we need to pick a point that the curve passes through. Lets choose the origin. Thus we will specifiy y(0) = 0.

> DEplot( deq, y(x), x=-2..2, [[ y(0) = 0 ]], y=-8..8, linecolour=red, color = blue, stepsize=.1,arrows=MEDIUM );

[Maple Plot]

The curve in red is the solution which follows the flow of the direction field and passes through (0,0).

Its also possible to view an entire family of solutions at once by using Maples ability to create a set of different points to consider. Each point will specify a different solution. The set of all of these solutions form a family of solutions.

> deq := diff(y(x),x) = 3*x^2 - 1;

deq := diff(y(x),x) = 3*x^2-1

> DEplot( deq, y(x), x=-2..2, [[ y(0) = k/4 ] $ k = -9..9 ],
y=-8..8, color = blue, stepsize=.05, linecolour=red, arrows=MEDIUM );

[Maple Plot]

> deq := diff(y(x),x) = cos(x);

deq := diff(y(x),x) = cos(x)

> DEplot( deq, y(x), x=0..2*Pi,[[ y(0) = k/4] $ k = -9..9 ], y=-3..3, color = blue, stepsize=.05,linecolour=red, arrows=MEDIUM);

[Maple Plot]

> deq := diff(y(x),x) = 1-x;

deq := diff(y(x),x) = 1-x

> dfieldplot( deq, y, x = -3..3, y = -3..3, color = blue,arrows=MEDIUM );

[Maple Plot]

> DEplot( deq, y(x), x=-3..3, [[ y(k) = 0 ] $ k = -3..3 ], y=-3..3,
color = blue, linecolour=red, arrows=MEDIUM );

[Maple Plot]

> deq := diff(y(x),x) = x;

deq := diff(y(x),x) = x

> DEplot( deq, y(x), x=-3..3, [[ y(k/4)=0 ] $ k = -11..11], y=-3..3,
color = blue, linecolour=red, arrows=MEDIUM );

[Maple Plot]

___________________________________________________________________________________

B. Solutions to Other Differential Equation

___________________________________________________________________________________

The problems above had simple answers because each differential equation could be integrated to get a solution. In this section we will do the same thing - plot a direction field and various solutions which flow as trajectories in the direction field. However, these differential equations are not simply the derivative of known functions. You will notice that the direction vectors are not parallel for each value of x. Instead there is a more dynamic flow. Even though the situation is a bit more complicated, the method still works just as well.

Here is an example of a differential equation and a direction field.

> deq := diff(y(x),x) = x^2 + y^2;

deq := diff(y(x),x) = x^2+y^2

> DEplot( deq ,y(x), x=-3..3, y=-3..3, stepsize=.05, color = blue, arrows=MEDIUM );

[Maple Plot]

We can also include a starting point to generate a solution.

> DEplot( deq ,y(x), x=-3..3, [[ y(0)=0 ]],
y=-3..3,stepsize=.05, color = blue, linecolour=red,arrows=MEDIUM );

[Maple Plot]

In fact, we can generate a family of solutions by choosing x intercepts from -4 to 4 in increments of 1/4.

> DEplot( deq, y(x), x=-4..4, [[ y(k/4)=0 ] $ k = -12..12], y=-3..3,
color = blue, linecolour=red, arrows=MEDIUM );

[Maple Plot]

Here is another family generated by choosing different y intercepts.

> DEplot( deq, y(x), x=-3..3, [[ y(0)= k/4 ] $ k = -11..11], y=-3..3,
color = blue, linecolour=red,arrows=MEDIUM );

[Maple Plot]

Here is an example where the differential equation is very sensitive to the initial point chosen. A tiny change in the starting point of a tragectory can lead to very large differences as the object travels pathes following the direction feild.

> deq := diff(y(x),x) = x + y;

deq := diff(y(x),x) = x+y

> DEplot( deq, y(x), x=-3..3, [[ y(0)= k/10 ] $ k = -20..20], y=-3..3,
color = blue, linecolour=green, arrows=MEDIUM );

[Maple Plot]

___________________________________________________________________________________

C. Plotting Solutions to Parametric Differential Equations

___________________________________________________________________________________

We can also plot solutions to parametric differential equations

> deq := [ diff(x(t),t)= 4 - y(t),diff(y(t),t)= x(t) - 4 ];

deq := [diff(x(t),t) = 4-y(t), diff(y(t),t) = x(t)-...

> DEplot( deq, [x(t),y(t)],t= 0..25, [[x(0)=0,y(0)=0]], stepsize=.05,
arrows = medium, color = coral,linecolor= 1 + .5*sin(t*Pi/2),
method=classical[foreuler]);

[Maple Plot]

Here is an example from predator - prey models

> restart; with(DEtools): with(plots):

Warning, the name changecoords has been redefined

> deq := [diff(x(t),t) = x(t)*1(1 - 1*x(t) - 4*y(t)),
diff(y(t),t) = y(t)*(1 - 4*x(t) - 3*y(t)) ];

deq := [diff(x(t),t) = x(t), diff(y(t),t) = y(t)*(1...

> DEplot( deq, [x(t),y(t)],t= 0..25,[[x(0)=1,y(0)=1],[x(0)=.4,y(0)=1]],
[[x(0)=1,y(0)=.6 ]], stepsize=.05,arrows = small,
color = aquamarine,linecolour=sin(t*Pi) );

[Maple Plot]

Unlike a textbook, you are not limited to simply looking at his graph. You can click the mouse anywhere on the graph. You will see a black border appear around the graph. If you click and drag the mouse on the graph, it will rotate the graph in three dimensions. In the way, you can see around, under, and over the graph and view from every angle.

___________________________________________________________________________________

D. Chaos in Three Dimensions

___________________________________________________________________________________

One of the first and most famous example of a chaotic attractor is the Lorenz Attractor defined by three parametric differential equations.

> deq := [ diff(x(t),t) = 10*(y(t)-x(t)),
diff(y(t),t) = 28*x(t) - y(t) -x(t)*z(t),
diff(z(t),t) = x(t)*y(t) - (8/3)*z(t) ];

deq := [diff(x(t),t) = 10*y(t)-10*x(t), diff(y(t),t...

> DEplot3d(deq, {x(t),y(t),z(t)}, t=0..100, [[x(0) = 10, y(0)= 10,z(0)= 10]],
stepsize=.02, x = -20..20, y=-25..25,z= 0..50, linecolour=sin(t*Pi/3),
thickness = 1, orientation = [-40,80], title=`Lorenz Chaotic Attractor`);

[Maple Plot]

>