Section 3.1: Mathematica Addition to Lecture

Initializations

I like to reset the font:

$TextStyle={FontFamily->"Times",FontSize->16,Background->None}

Homogeneous Linear Second Order Differential Equation

Here is the most general form of a homogenous linear second order differential equation, which Mathematica can solve.

L[y_]:=  a*D[y,{t,2}]+b*D[y,t]+c*y==0

L[y[t]]

DSolve[L[y[t]],y[t],t]

Notice how the quadratic formula was used to get this solution, and also notice that there are two constants of integration.

Example of Homogeneous Linear Second Order Differential Equation

This is a check of the calculation we did by hand. Remember, I want us to do these computations by hand so we can learn how the Mathematica DSolve command works! With this solution using DSolve, we really don't increase our understanding of the process, so it should only be used as a check.

L[y_]:=  1*D[y,{t,2}]+5*D[y,t]+6*y==0

L[y[t]]

Solve the differential equation:

DSolve[L[y[t]],y[t],t]

Solve the initial value problem:

DSolve[{L[y[t]],y[0]==2,y'[0]==3},y[t],t]

Example of Homogeneous Linear Second Order Differential Equation: Details that can help check your solution with pencil/paper

Here we use Mathematica to help us solve the above problem by hand, by doing some of the calculations for us. All of this can (and should!) be done by hand, but this shows you how you can check individual aspects of your solution. Remember, your solutions should be well explained so that someone not in the course can follow them! Don't skip explanatory steps.

L[y_]:=  1*D[y,{t,2}]+5*D[y,t]+6*y==0

Substitute into the differential equation:

L[Exp[r*t]]

Simplify[%]

Solve the Characteristic Equation:

Solve[r^2+5r+6==0,r]

Write down the General Solution:

(Subscript[r, 1])=-3;
(Subscript[r, 2])=-2;
ygen[t_]=(∑_(i=1)^2)(Subscript[c, i])*Exp[(Subscript[r, i])*t]

Apply the initial conditions to get a system of equations the constants (Subscript[c, 1]) and (Subscript[c, 2]) must satisfy:

eq1=ygen[0]==2
eq2=ygen'[0]== 3

You should be able to solve the system of equations using Cramer's rule. Here is how you can check your solution:

values=Solve[{eq1,eq2},{(Subscript[c, 1]),(Subscript[c, 2])}]

Substitute the values in to get the solution to the initial value problem:

yivp[t_]=ygen[t]/.Flatten[values]

Plot[yivp[t],{t,0,2},PlotStyle->Thick]

Beautiful!