MapleDEexample2.mws

A DE Example

Fourth order, nonhomogeneous, constant coefficient

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

(D^4-D^3-2*D^2-4*D-24)(y) = e^(3*x)+6*cos(2*x)

First I will factor the operator.

>    factor(D^4-D^3-2*D^2-4*D-24);

(D-3)*(D+2)*(D^2+4)

Or I could solve the auxiliary equation.

>    solve({m^4-m^3-2*m^2-4*m-24=0},{m});

{m = -2}, {m = 3}, {m = 2*I}, {m = -2*I}

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

e^(3*x), e^(-2*x), sin(2*x), cos(2*x)

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

A*x*e^(3*x)+B*x*sin(2*x)+C*x*cos(2*x) .

Assign this the name f.

>    f:=A*x*exp(3*x)+B*x*sin(2*x)+C*x*cos(2*x);

f := A*x*exp(3*x)+B*x*sin(2*x)+C*x*cos(2*x)

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

>    diff(f,x,x,x,x)-diff(f,x,x,x)-2*diff(f,x,x)-4*diff(f,x)-24*f;

8*C*cos(2*x)+65*A*exp(3*x)+8*B*sin(2*x)-40*B*cos(2*x)+40*C*sin(2*x)

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

8*C-40*B = 6, 65*A = 1, 8*B+40*C = 0 .

 

Solve this system of equations.

>    solve({8*C-40*B=6, 65*A=1, 8*B+40*C=0},{A,B,C});

{B = -15/104, A = 1/65, C = 3/104}

The general solution would be

y = C[1]*e^(3*x) + C[2]*e^(-2*x) + C[3]*sin(2*x) + C[4]*cos(2*x) + (1/65)*x*e^(3*x) - (15/104)*x*sin(2*x) + (3/104)*x*cos(2*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,x,x)-diff(y(x),x,x,x)-2*diff(y(x),x,x)-4*diff(y(x),x)-24*y(x)=exp(3*x)+6*cos(2*x)};

ode1 := {diff(y(x),`$`(x,4))-diff(y(x),`$`(x,3))-2*diff(y(x),`$`(x,2))-4*diff(y(x),x)-24*y(x) = exp(3*x)+6*cos(2*x)}

>    dsolve(ode1);

{y(x) = (-3/338-15/104*x)*sin(2*x)+(3/104*x-159/2704)*cos(2*x)-43/4225*exp(3*x)+1/65*x*exp(3*x)+_C1*exp(3*x)+_C2*sin(2*x)+_C3*cos(2*x)+_C4*exp(-2*x)}

Here we put in some initial conditions.

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

ic := {y(0) = 0, D(y)(0) = 1, `@@`(D,2)(y)(0) = 1, `@@`(D,3)(y)(0) = 1}

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

y(x) = (-3/338-15/104*x)*sin(2*x)+(3/104*x-159/2704)*cos(2*x)+502/4225*exp(3*x)+1/65*x*exp(3*x)+407/1352*sin(2*x)-71/1352*cos(2*x)-3/400*exp(-2*x)

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

>    ode2:=diff(y(x),x$4)-diff(y(x),x$3)-2*diff(y(x),x$2)-4*diff(y(x),x)-24*y(x)=exp(3*x)+6*cos(2*x);

ode2 := diff(y(x),`$`(x,4))-diff(y(x),`$`(x,3))-2*diff(y(x),`$`(x,2))-4*diff(y(x),x)-24*y(x) = exp(3*x)+6*cos(2*x)

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

ic2 := y(0) = 0, D(y)(0) = 1, `@@`(D,2)(y)(0) = 1, `@@`(D,3)(y)(0) = 1

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

y(x) = (3/104*x-159/2704)*cos(2*x)+(-15/104*x-3/338)*sin(2*x)+502/4225*exp(3*x)+1/65*x*exp(3*x)-71/1352*cos(2*x)-3/400*exp(-2*x)+407/1352*sin(2*x)

Below I am naming the general solution f, renaming the arbitrary constants A, B, C, and D, entering the initial conditions, and solving the resulting system of equations to find A, B, C, and D.

>    f:= (-3/338-15/104*x)*sin(2*x)+(3/104*x-159/2704)*cos(2*x)-43/4225*exp(3*x)+1/65*x*exp(3*x)+A*exp(3*x)+B*sin(2*x)+C*cos(2*x)+D*exp(-2*x);

f := (-15/104*x-3/338)*sin(2*x)+(3/104*x-159/2704)*cos(2*x)-43/4225*exp(3*x)+1/65*x*exp(3*x)+A*exp(3*x)+B*sin(2*x)+C*cos(2*x)+D*exp(-2*x)

>    eval(f,x=0);

-4663/67600+A+C+D

>    fx:=diff(f,x);

fx := -15/104*sin(2*x)+2*(-15/104*x-3/338)*cos(2*x)+3/104*cos(2*x)-2*(3/104*x-159/2704)*sin(2*x)-64/4225*exp(3*x)+3/65*x*exp(3*x)+3*A*exp(3*x)+2*B*cos(2*x)-2*C*sin(2*x)-2*D*exp(-2*x)
fx := -15/104*sin(2*x)+2*(-15/104*x-3/338)*cos(2*x)+3/104*cos(2*x)-2*(3/104*x-159/2704)*sin(2*x)-64/4225*exp(3*x)+3/65*x*exp(3*x)+3*A*exp(3*x)+2*B*cos(2*x)-2*C*sin(2*x)-2*D*exp(-2*x)

>    eval(fx,x=0);

-137/33800+3*A+2*B-2*D

>    fxx:=diff(fx,x);

fxx := -15/26*cos(2*x)-4*(-15/104*x-3/338)*sin(2*x)-3/26*sin(2*x)-4*(3/104*x-159/2704)*cos(2*x)+3/4225*exp(3*x)+9/65*x*exp(3*x)+9*A*exp(3*x)-4*B*sin(2*x)-4*C*cos(2*x)+4*D*exp(-2*x)
fxx := -15/26*cos(2*x)-4*(-15/104*x-3/338)*sin(2*x)-3/26*sin(2*x)-4*(3/104*x-159/2704)*cos(2*x)+3/4225*exp(3*x)+9/65*x*exp(3*x)+9*A*exp(3*x)-4*B*sin(2*x)-4*C*cos(2*x)+4*D*exp(-2*x)

>    eval(fxx,x=0);

-5763/16900+9*A-4*C+4*D

>    fxxx:=diff(fxx,x);

fxxx := 45/26*sin(2*x)-8*(-15/104*x-3/338)*cos(2*x)-9/26*cos(2*x)+8*(3/104*x-159/2704)*sin(2*x)+594/4225*exp(3*x)+27/65*x*exp(3*x)+27*A*exp(3*x)-8*B*cos(2*x)+8*C*sin(2*x)-8*D*exp(-2*x)
fxxx := 45/26*sin(2*x)-8*(-15/104*x-3/338)*cos(2*x)-9/26*cos(2*x)+8*(3/104*x-159/2704)*sin(2*x)+594/4225*exp(3*x)+27/65*x*exp(3*x)+27*A*exp(3*x)-8*B*cos(2*x)+8*C*sin(2*x)-8*D*exp(-2*x)

>    eval(fxxx,x=0);

-1137/8450+27*A-8*B-8*D

>    solve({-4663/67600+A+C+D=0,-137/33800+3*A+2*B-2*D=1,-5763/16900+9*A-4*C+4*D=1,-1137/8450+27*A-8*B-8*D=1},{A,B,C,D});

{D = -3/400, C = -71/1352, B = 407/1352, A = 109/845}

>