

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document demonstrates how to solve a system of linear differential equations using maple. The matrix form of the equations, the maple code to define and solve the system, and the vector form of the solution. It also shows how to handle initial value problems and plot the results.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Math 308
In this example, we see how to solve a linear system of the form x'=Ax.
Suppose
A =
and we want to solve x ' = A x,
where x =
x ( ) t y ( ) t The differential equation written in matrix form above is really two first order equations:
x'(t) = x(t) - 2y(t) y'(t) = 4x(t) - 5y(t)
We define the problem in Maple by entering these equations individually: > eq1 := diff(x(t),t) = x(t)-2y(t);*
eq1 := = โ
t
x ( ) t x( ) t โ 2 y( ) t
> eq2 := diff(y(t),t) = 4x(t)-5y(t);**
eq2 := = โ
t
y( ) t 4 x( ) t โ 5 y( ) t
We can use the dsolve function to solve the system. As usual, the first argument to dsolve is the problem to be solved, and the second argument holds the functions to be found. In this case, the problem is a system, so we put both equations in brackets. Also, there are two functions to be found, so we also put them in brackets. > sol := dsolve([eq1,eq2],[x(t),y(t)]);
sol :={ y( ) t = _C1 e + , }
( โ 3 t ) _C2 e
( โ t ) x( ) t = +
_C1 e
( โ 3 t ) _C2 e
( โ t )
Note that Maple has returned the two functions in a list, enclosed in curly brackets. To access the elements of the list, we use the notation sol[i], where i is an integer. It is important to also notice that Maple did not put x(t) first; the order tends to be random. It might even be different the next time we enter the exact same command. > sol[2];
x( ) t = +
_C1 e
( โ 3 t ) _C2 e
( โ t )
> sol[1];
y( ) t = _C1 e +
( โ 3 t ) _C2 e
( โ t )
The vector form of the solution would be
=
x ( ) t y ( ) t
e
( โ 3 t ) _C2
e
( โ t )
Check this--you should understand that this is the same solution as the individual functions in sol.
If we have an initial value problem to solve, we must include the initial conditions as part of the problem to be solved in the dsolve function. Suppse we want to solve the above system, with the initial conditions x(0)=-1, y(0)=1. Here is how we can use dsolve to do this: > sol1 := dsolve([eq1,eq2,x(0)=-1,y(0)=1],[x(t),y(t)]);
sol1 :={ y( ) t =โ 3 e + , }
( โ t ) 4 e
( โ 3 t ) x( ) t =โ 3 e +
( โ t ) 2 e
( โ 3 t )
Here is one way to pull apart Maple's solution and plot the results. Note that when I executed these commands, Maple put y(t) first and x(t) second in sol1. If they are in a different order, you will have to change the indices in the following commands. Also note that I use the rhs function to get the right-hand side of the expression returned by Maple. > solx := rhs(sol1[2]);
solx :=โ 3 e +
( โ t ) 2 e
( โ 3 t )
> soly := rhs(sol1[1]);
soly :=โ 3 e +
( โ t ) 4 e
( โ 3 t )
> plot({solx,soly},t=-0.25..3);
You can tell which curve is which by the initial conditions. >