LaplaceClass_A11.mws

LaplaceClass_A11.mws
Tue Oct 11 09:20:59 MDT 2005

>    restart;

>    with(plots, display):

>    step := (t,A) -> Heaviside(t-A);   Our text's "step" function.

step := proc (t, A) options operator, arrow; Heaviside(t-A) end proc

>    RHS := t -> (1 - step(t,1))*2*t + 2*step(t,1);

RHS := proc (t) options operator, arrow; 2*(1-step(t,1))*t+2*step(t,1) end proc

>    TRG := 0..4:

>    P_RHS := plot(RHS, TRG): Save driving-function plot for later.

>    #display(P_RHS);   Checking if the driving function's entered properly.

The differential equation: y'' +  y = RHS with y(0) = 0 and y'(0) = 1.

 

>    DEA := (D@@2)(y)(t) + y(t) = RHS(t);

DEA := `@@`(D,2)(y)(t)+y(t) = 2*(1-Heaviside(t-1))*t+2*Heaviside(t-1)

Set up the initial conditions:

>    WIMPY := y(0) = 0, D(y)(0) = 1:

Put together the argument sequence for "dsolve":

>    IVP := {DEA, WIMPY}:

>    VARS := y(t):

>    CARGO := IVP, VARS:

>    SOLN := dsolve(CARGO);   Solve the initial-value problem.

SOLN := y(t) = -sin(t)+(-2*t+2*sin(t-1)+2)*Heaviside(t-1)+2*t

Recover the solution for plotting and checking:

>    yy := unapply( rhs(SOLN), t):   Get solution as Maple function yy

>    P_SOLN := plot(yy, TRG, colour=BLACK):   Plot the solution.

>    display(P_RHS, P_SOLN);   Solution and driving function together.

[Maple Plot]

>    ########################################################

Here we check the piecewise formula for the solution:

>    assume(u < 1);

>    assume(v > 1);  

>   

>    yy(u);

-sin(u)+2*u

>    yy(v);

-sin(v)+2*sin(v-1)+2

>    #########################################################

>   

>