Examples of Second Order Linear Homogeneous Equations with Constant Coefficients

Initializations

$TextStyle={FontFamily->"Times",FontSize->16,FontSlant->Italic}
Off[General::spell1]
Off[InverseFunction::ifun]
Off[Solve::ifun]

Solution and Graphs for Two Distinct Real Roots of Characteristic Equation

Solve a Differential Equation

We wish to solve the differential equation
y'' + 5 y' + 6 y = 0.
which can input into Mathematica in the following way:

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

L[y[t]]

To solve this, we assume a solution looks like:

ϕ[t_] = Exp[r t]

Substitute into the differential equation:

L[ϕ[t]]

Simplify the resulting equation to get the characteristic equation:

Simplify[%]

Mathematica doesn't know that it can cancel the term (e^(r t)), but we know that we can divide by that term since it does not equal zero. We get the characteristic equation:

characteristic = (6+5 r+(r^2))==0

Which we can solve:

Solve[characteristic,r]

So we see that the characteristic equation has two distinct real roots. Define the general solution as a function of time, and two constants a and b:

f[t_,a_,b_] = a  Exp[-2t] + b Exp[-3t]

Note that typing e^(-2t) will not produce the anticipated result! Mathematica will treat e as an unknown parameter in this case.

We can verify this is a solution in the following manner:

L[f[t,a,b]]

Simplify[%]

Plot some solutions for different values of a and b

solution[a_,b_] := Plot[f[t,a,b],{t,0,4},AxesLabel->{"Time","y(t)"},ImageSize->{400,Automatic},PlotStyle->{Thick}]

solution[9,-7]

Notice that the solution is decaying to zero as t approaches infinity, and there is a maximum near t=0.25.

Here is how you would use Mathematica to solve this differential equation:

sol = DSolve[L[y[t]],y[t],t]

and how you can plot solutions for a range of initial parameters C[1] and C[2]:

y[t_] = y[t]/. First[sol]

functionlist=y[t]/. C[1] -> Range[-10,10,5]/. C[2]-> Range[-10,10,10]

Plot[Evaluate[functionlist],{t,0,2},
PlotRange -> {-10,10} ,AxesLabel->{"Time","General Solutions"},ImageSize->{400,Automatic},PlotStyle->{Thick}]

Clear[y,f,fp,fpp,r,characteristic]

Solution and Graphs for Complex Roots of Characteristic Equation

Solve a Differential Equation

We wish to solve the differential equation
y'' + y' + y = 0
which we can put into Mathematica as

L[y_]:=D[y,{t,2}] + D[y,t] + y == 0

L[y[t]]

To solve this, we assume a solution looks like:

ϕ[t_] = Exp[r t]

Substitute into the differential equation:

L[ϕ[t]]

Simplify the resulting equation to get the characteristic equation:

Simplify[%]

Mathematica doesn't know that it can cancel the term (e^(r t)), but we know that we can divide by that term since it does not equal zero. We get the characteristic equation:

characteristic =  (1+r+(r^2))==0

Which we can solve:

Solve[characteristic,r]

Notice that the roots returned by Mathematica may not be what you expected! This is a perfect example of how you need to understand the mathematics you are dealing with before you start using a computer algebra system. In fact, the roots that Mathematica returned are the same as you would expect

r = (1/2)  ±  i ((Sqrt[3])/2)

which we can verify by checking what the real and imaginary parts of the roots Mathematica returned are:

Re[-(((-1))^(1/3))]

Im[-(((-1))^(1/3))]

Re[(-1)^(2/3)]

Im[(-1)^(2/3)]

Define the general solution as a function of time,and two constants a and b:

f[t_,a_,b_] = a Exp[-t/2] Cos[Sqrt[3]t/2] + b Exp[-t/2] Sin[Sqrt[3]t/2]

We can verify this is a solution in the following manner:

L[f[t,a,b]]

Plot some solutions for different values of a and b

solution[a_,b_] := Plot[f[t,a,b],{t,0,10},AxesLabel->{"Time","y(t)"},ImageSize->{400,Automatic},PlotStyle->{Thick}]

solution[1,2]

Notice that the function oscillates, which is due to the appearance of the sine and cosine in the solution.

solution[0.1,16]

Here is how Mathematica would solve this equation:

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

If we wanted to plot from this, we would run into trouble since the solution is complex valued. Instead, let's generate plots of the general solution from our real valued solution above.

functionlist=f[t,a,b]/. a -> Range[-2,2,1] /. b-> Range[-5,5,5]

Plot[Evaluate[functionlist],{t,0,10},
PlotRange -> {-4,4},AxesLabel->{"Time","General Solutions"},ImageSize->{400,Automatic},PlotStyle->{Thick}]

Clear[y,f,fp,fpp,r,characteristic]

Solution and Graphs for Real Root of Multiplicity Two of Characteristic Equation

Solve a Differential Equation

We wish to solve the differential equation
9 y'' + 6 y' +  y = 0.
which can input into Mathematica in the following way:

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

L[y[t]]

To solve this, we assume a solution looks like:

ϕ[t_] = Exp[r t]

Substitute into the differential equation:

L[ϕ[t]]

Simplify the resulting equation to get the characteristic equation:

Simplify[%]

Mathematica doesn't know that it can cancel the term (e^(r t)), but we know that we can divide by that term since it does not equal zero. We get the characteristic equation:

characteristic =(((1+3 r))^2)==0

Which we can solve:

Solve[characteristic,r]

So we see that the characteristic equation has one real root, of multiplicity two. Define the general solution as a function of time, and two constants a and b:

f[t_,a_,b_] = a  Exp[-1/3 t] + b t Exp[-1/3t]

We can verify this is a solution in the following manner:

L[f[t,a,b]]

Simplify[%]

Plot some solutions for different values of a and b

solution[a_,b_] := Plot[f[t,a,b],{t,0,40},AxesLabel->{"Time","y(t)"},ImageSize->{400,Automatic},PlotStyle->{Thick}]

solution[9,-7]

Notice that the solution is decaying to zero as t approaches infinity, and that the solution crosses y=0 only once.

Here is how you would use Mathematica to solve this differential equation:

sol = DSolve[L[y[t]],y[t],t]

and how you can plot solutions for a range of initial parameters C[1] and C[2]:

y[t_] = y[t]/. First[sol]

functionlist=y[t]/. C[1] -> Range[-10,10,5] /. C[2]-> Range[-10,10,5]

Plot[Evaluate[functionlist],{t,0,15},
PlotRange -> {-20,20},AxesLabel->{"Time","General Solutions"},ImageSize->{400,Automatic},PlotStyle->{Thick}]

Clear[y,f,fp,fpp,r,characteristic]