Procedure for solving 2nd order constant coefficient linear differential equations

Part 0. The equation:

Suibstitute your data for the following:

a = 1
b =  3
c = 14
f[t_] := (E^t) (t^2)

It is required to solve the equation

eqn  =  (a y''[t]  +  b y'[t]  +  
            c y[t]  ==  f[t])

Part 1. Solve the characteristic equation

Consider the chartacteristic equation:

charEqn  =  (a r^2  +  b r  +  
            c  ==  0)

charSoln  =  Solve[charEqn,  r]

If[Length[charSoln]  ==  2,  {α,  β}  =  
        r /. charSoln, 
{α}  =  
        r /. charSoln]

Part 2.  Solve the homogeneous equation

homogEqn  =  (a y''[t]  +  b y'[t]  +  
            c y[t]  ==  0)

A fundamental family of solutions to the homogeneous equation  depends on the nature of the roots of the characteristic equation:

Case I.   The characteristic equation has two distinct real roots.

A fundamental family of solutions to the homogeneous equation is the following.  (In case the roots are distinct and complex, the following gives a fundamental family of complex solutions.)

\(\(\({φ\_1[t_], φ\_2\ [
          t_]}\  = \ {Exp[α\ t]\ , \ Exp[β\ t]\ }\)\(
\)
    \)\)

Case II.   The characteristic equation has two complex conjugate roots.

A fundamental family of solutions to the homogeneous equation is the following.

λ  =  Re[α]
μ  =  Im[α]
{(Subscript[φ, 1])[t_], (Subscript[φ, 2]) [
          t_]}  =  {Exp[λ t] Sin[μ t],  
        Exp[λ t] Cos[μ t]}

Case II.   The characteristic equation has one real root repeated with multiplicity two.

A fundamental family of solutions to the homogeneous equation is the following.

{(Subscript[φ, 1])[t_], (Subscript[φ, 2]) [
          t_]}  =  {Exp[α t] ,   t Exp[α t] }

Part 2.  Find a particular solution to the inhomogenous equation.

We guess a  particular solution to the inhomogeneous equation of the following form.  (Substitute the appropriate functional form depending on the nature of the right hand side f[t].)

Clear[yp, A, B, CC]
yp[t_] :=  (E^t) (A0 + A1 t + A2 (t^2))

We put this proposed solution into the left hand side of the differential equation:

LHS  =  
      Expand[a yp''[t]   +  b yp'[t]  +  c yp[t]]

We set the left hand side equal to the right hand side, namely f[t]

coeffEqn  =  (LHS  ==  f[t])

Substituting n different values of t yields n linear equations in the n unknown parameters  A0, A1, A2, ....

linearEquations  =  {
(coeffEqn1  =  
            coeffEqn  /.  
              t ->  0),  
(coeffEqn2  =  
            coeffEqn  /.  
              t   ->  1),  
(coeffEqn3  =  
            coeffEqn  /.  t  ->  2)}

coeffSoln  =  Solve[linearEquations,  {A0,  A1,  A2}]

YP[t_]  :=  (yp[t] /.  
          coeffSoln[[1]])
YP[t]

Part 3.  The general solution

The general solution to the differential equation is:

genSoln[t_]  :=  
      C1 (Subscript[φ, 1])[t]  +  C2 (Subscript[φ, 2])[t]  +  
        YP[t]
genSoln[t]

Part 4.  An initial value problem.

Let's consider the IVP consisting of our differential equation

Clear[y]
eqn

with the initial conditions:

Clear[y,  InitialConditions]
InitialConditions  =  {y[0]  ==  3,  y'[0]  ==  
          2}

If we substitute the general solution for y[t], the initial conditions become 2 linear equations in the unknowns C1 and C2.

y[t_]  =  
        genSoln[t];

    InitialConditions

We solve these linear equations and substitute the result into y[t] to obtain the solution to the IVP.

IVSoln  =  Solve[
          InitialConditions,  {C1, 
            C2}][[1]]
F[t_]  =  
        Expand[(y[t]  /.  IVSoln)];
F[t]

Plot[F[t],  {t,  -5,  5}]

Part 5. Compare with built in Mathematica routines

Clear[y,  F]
eqn
dSoln  =  DSolve[eqn,  y[t],  t];
F[t_]  =  Expand[ Simplify[y[t] /.  dSoln[[1]]]]

Clear[y,  F]
eqn
InitialConditions
dSoln  =  
        DSolve[{eqn,  InitialConditions},  y[t],  
          t];
F[t_]  =  Expand[ Simplify[y[t] /.  dSoln[[1]]]]