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

(D^2-2*D-8)(y) = 2*exp(x)-exp(-x) .

First I will factor the operator.

>    factor(D^2-2*D-8);

(D+2)*(D-4)

Or I could solve the auxiliary equation.

>    solve({m^2-2*m-8=0},{m});

{m = 4}, {m = -2}

Thus two linearly independent solutions to the complementary equation (solutions to the corresponding homogeneous equation) are y[i] =

exp(-2*x), exp(4*x) .

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

A*exp(x)+B*exp(-x) .

Assign this the name f.

>    f:=A*exp(x)+B*exp(-x);

f := A*exp(x)+B*exp(-x)

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

>    diff(f,x,x)-2*diff(f,x)-8*f;

-9*A*exp(x)-5*B*exp(-x)

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

-9A = 2  and  -5B = -1.

 

Solve this system of equations.

>    solve({-9*A=2,-5*B=-1},{A,B});

{B = 1/5, A = -2/9}

The general solution would be

y = C[1]*e^(-2*x) + C[2]*e^(4*x) - (2/9)*e^x + (1/5)*e^(-x).

Below is Maple's solution to the ODE.

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

>    ode1:={diff(y(x),x,x)-2*diff(y(x),x)-8*y(x)=2*exp(x)-exp(-x)};

ode1 := {diff(y(x),`$`(x,2))-2*diff(y(x),x)-8*y(x) = 2*exp(x)-exp(-x)}

>    dsolve(ode1);

{y(x) = exp(4*x)*_C2+exp(-2*x)*_C1+1/45*(-10*exp(2*x)+9)*exp(-x)}

Here we put in some initial conditions.

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

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

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

y(x) = 11/45*exp(4*x)-2/9*exp(-2*x)+1/45*(-10*exp(2*x)+9)*exp(-x)

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

>    ode2:=diff(y(x),x$2)-2*diff(y(x),x)-8*y(x)=2*exp(x)-exp(-x);

ode2 := diff(y(x),`$`(x,2))-2*diff(y(x),x)-8*y(x) = 2*exp(x)-exp(-x)

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

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

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

y(x) = 11/45*exp(4*x)-2/9*exp(-2*x)+1/45*(-10*exp(2*x)+9)*exp(-x)

>