Solving a Linear System of Differential Equations using Maple, Study notes of Differential Equations

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

Pre 2010

Uploaded on 08/16/2009

koofers-user-7hd
koofers-user-7hd ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Solving a Linear System
Math 308
In this example, we see how to solve a linear system of the form x'=Ax.
Suppose
= A๎˜
๎˜‚
๎˜ƒ
๎˜ƒ๎˜„
๎˜…
๎˜†
๎˜†
1โˆ’2
4โˆ’5
and we want to solve x' = Ax,
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)-2*y(t);
:= eq1 =
โˆ‚
โˆ‚
t( )x t โˆ’ ( )x t2 ( )y t
> eq2 := diff(y(t),t) = 4*x(t)-5*y(t);
:= eq2 =
โˆ‚
โˆ‚
t( )y t โˆ’ 4 ( )x t5 ( )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( )โˆ’3t_C2 e( )โˆ’t = ( )x t +
1
2_C1 e( )โˆ’3t_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];
pf2

Partial preview of the text

Download Solving a Linear System of Differential Equations using Maple and more Study notes Differential Equations in PDF only on Docsity!

Solving a Linear System

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

_C1 +

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. >