MapleDEexample4.mws

A DE Example

Second order, nonhomogeneous, constant coefficient

Here are some maple commands to assist you in solving a second order, constant coefficient, nonhomogeneous differential equation.  The equation being solved is

(2*D^2+7*D+6)(y) = 2*sin(t)

First I will factor the operator.

>    factor(2*D^2+7*D+6);

(D+2)*(2*D+3)

Or I could solve the auxiliary equation.

>    solve({2*m^2+7*m+6=0},{m});

{m = -3/2}, {m = -2}

Thus the general solution to the corresponding homogeneous equation would be

y = c1*exp((-3/2)*t)+c2*exp(-2*t) .

The form for a particular solution would be y[p] =

A*sin(t)+B*cos(t) .

Assign this the name f.

>    f:=A*sin(t)+B*cos(t);

f := A*sin(t)+B*cos(t)

Substitute f in for y in the left side of the original differentail equation.

>    2*diff(f,t,t)+7*diff(f,t)+6*f;

4*A*sin(t)+4*B*cos(t)+7*A*cos(t)-7*B*sin(t)

Set the expression above equal to the right side of the differential equation and equate coefficients of like terms to get

4A - 7B = 2  and  7A + 4B = 0.

 

Solve this system of equations.

>    solve({4*A-7*B=2,7*A+4*B=0},{A,B});

{A = 8/65, B = -14/65}

The general solution would be

y = C1*e^(-3*t/2)+C2*e^(-2*t)+8/65*sin(t)-14/65*cos(t) .

Below is Maple's solution to the ODE.

Can you see that it agrees with the solution given above?

>    ode1:={2*diff(y(t),t,t)+7*diff(y(t),t)+6*y(t)=2*sin(t)};

ode1 := {2*diff(y(t),`$`(t,2))+7*diff(y(t),t)+6*y(t) = 2*sin(t)}

>    dsolve(ode1);

{y(t) = exp(-2*t)*_C2+exp(-3/2*t)*_C1-14/65*cos(t)+8/65*sin(t)}

Here we put in some initial conditions.

>    ic:={y(0)=3,D(y)(0)=0};

ic := {y(0) = 3, D(y)(0) = 0}

>    dsolve(ode1 union ic,y(t));

y(t) = -47/5*exp(-2*t)+164/13*exp(-3/2*t)-14/65*cos(t)+8/65*sin(t)

Here is some alternative syntax for solving the same differential equation along with initial conditions.

>    ode2:=2*diff(y(t),t$2)+7*diff(y(t),t)+6*y(t)=2*sin(t);

ode2 := 2*diff(y(t),`$`(t,2))+7*diff(y(t),t)+6*y(t) = 2*sin(t)

>    ic2:=y(0)=3,D(y)(0)=0;

ic2 := y(0) = 3, D(y)(0) = 0

>    dsolve({ode2,ic2},{y(t)});

y(t) = -47/5*exp(-2*t)+164/13*exp(-3/2*t)-14/65*cos(t)+8/65*sin(t)

Here are the graphs of the transient solution (in green), steady state solution (in blue), and the solution (in red).

>    with(plots):

>    Transient:=plot((-47/5)*exp(-2*t)+(164/13)*exp(-3*t/2),t=0..4*Pi,y=-2..4,thickness=3,color=green):

>    SteadyState:=plot((8/65)*sin(t)-(14/65)*cos(t),t=0..4*Pi,y=-2..4,thickness=3,color=blue):

>    Solution:=plot((-47/5)*exp(-2*t)+(164/13)*exp(-3*t/2)+(8/65)*sin(t)-(14/65)*cos(t),t=0..4*Pi,y=-2..4,thickness=3,color=red):

>    display(Transient,SteadyState,Solution);

[Maple Plot]

>