Demo 3.1

Solving Initial Value Problems for second order ODE's

To solve a second order IVP we use DSolve with two initial conditions, and we transform the solution into a function of those two initial conditions.  
Because of the semicolon in the second button, the solution as a list of rules is calculated but not shown on the screen.  Only the function is shown.

({{Second Order :   General Initial Value Solution}, {\(Clear[y]; 

            soln = 
	
              DSolve[{\[SelectionPlaceholder]\  == 
                      \[SelectionPlaceholder], 
                    y[\[SelectionPlaceholder]] == c1, 
                    \(y'\)[\[SelectionPlaceholder]] == c2}, y[t], t]
	 // 
                Simplify; 
	y[t_, c1_, c2_] = y[t] /. First[soln]\)}, {Plotting}, {\(Plot[Evaluate[
                y[t, \[SelectionPlaceholder], \[SelectionPlaceholder]]], {t, 
                \[SelectionPlaceholder]\ , \[SelectionPlaceholder]\ }
	, 
              AspectRatio -> 1]\ \)}, {\(Plot[Evaluate[
                Table[y[t, c1, \[SelectionPlaceholder]], {c1, 
                    \[SelectionPlaceholder]\ , \[SelectionPlaceholder]\ , 
                    \[SelectionPlaceholder]\ }]], 

              		{t, \[SelectionPlaceholder]\ , \[SelectionPlaceholder]\ }, 
              AspectRatio -> 1]\)}, {\(Plot[Evaluate[
                Table[y[t, \[SelectionPlaceholder], c2], {c2, 
                    \[SelectionPlaceholder]\ , \[SelectionPlaceholder]\ , 
                    \[SelectionPlaceholder]\ }]], 

              		{t, \[SelectionPlaceholder]\ , \[SelectionPlaceholder]\ }, 
              AspectRatio -> 1]\)}})

Example 1.                   y''+6y'+5y=0, y(0)=c1, y'(0)=c2

\(\(Clear[y]; 

    soln = 
	
      DSolve[{\(\(y'\)'\)[t] + 6 \( y'\)[t] + 5  y[t]\  == 0, 
            y[0] == c1, \(y'\)[0] == c2}, y[t], t]
	 // Simplify; 
	
    y[t_, c1_, c2_] = y[t] /. First[soln]\ \)\)

Expand[y[t, c1, c2]]

In the above expression the constants are precisely the initial conditions.

The characteristic roots are -5 and -1.  Note that all solutions tend to zero for t -> Infinity.
We can plot the solution for  a specific pair of initial conditions.

Plot[y[t, 5, 10], {t, 0 , 4 }, AspectRatio -> 1]

The function y(t,5,10) is given as the sum of the two exponential functions (e^(-t)) and (e^(-5 t)) in the following way

Expand[y[t, 5, 10]]

Let us plot the three functions y(t,5,10) and -15/4 (e^(-5 t)) and 35/4 (e^(-t)) in one graph so that we can see the superposition.

Plot[{y[t, 5, 10], -15/4*Exp[-5 t], 35/4*Exp[-t]}, 
                {t, 0 , 4 }, AspectRatio -> 1]

Back to the general solution y(t,c1,c2). 
We can also fix y'(0)=c2=10 (or any other number) and plot the solutions for several values of y(0)=c1. Thus, in the following graph all solutions start with a slope of 10.

\(Plot[Evaluate[Table[y[t, c1, 10], {c1, \(-10\)\ , 10\ , 4\ }]], 

      		{t, 0\ , 5\ }, AspectRatio -> 1]\)

Or we can fix y(0)=c1=1 (or any other number) and plot solutions for various values of y'(0).

\(Plot[Evaluate[Table[y[t, 1, c2], {c2, \(-10\)\ , 10\ , 4\ }]], 

      		{t, 0\ , 4\ }, AspectRatio -> 1]\)

Example 2.                  y''-4y'-5y=0,  y(1)=c1,  y'(1)=c2

\(Clear[y]; 

    soln = 
	
      DSolve[{\(\(y'\)'\)[t] - 4 \( y'\)[t] - 5  y[t]\  == 0, 
            y[1] == c1, \(y'\)[1] == c2}, y[t], t]
	 // Simplify; 
	
    y[t_, c1_, c2_] = y[t] /. First[soln]\)

Expand[y[t, c1, c2]]

The characteristic roots are -1 and 5. In this case the solutions tend to + or - Infinity if
the coefficient 1/6(c1+c2) is nonzero. 
The solution tends to zero for t -> Infinity if and only if c1 + c2 = 0 .

\(Plot[Evaluate[Table[y[t, c1, 5], {c1, \(-15\)\ , 15\ , 5\ }]], 

      		{t, 0\ , 2\ }, AspectRatio -> 1]\)

Example 3.                  y'' + 0.2  y' + 1.01 y = 0    and    y'' + 1.01 y = 0

This is an example, where the characteristic equations both have complex roots. In this case, the solutions show a type of oscillation, described by sine and cosine functions. This will be studied in section 3.4 of the textbook.

\(\(Clear[y]; 

    soln = 
	
      DSolve[{\(\(y'\)'\)[t]\  + 1/5*\(y'\)[t] + 101/100*y[t]\  == 0, 
            y[0] == 1, \(y'\)[0] == 0}, y[t], t]\  // \ Simplify; 

    y[t_] = y[t]\  /. \ First[soln]\ \)\)

Let us compare the graph of the solution with the solution of the differential equation 
y'' +1.01 y = 0, where the term involving y' is deleted.

\(Clear[u]; 

    solnu = DSolve[{\(\(u'\)'\)[t] + 101/100*u[t] == 0, u[0] == 1, 
            \(u'\)[0] == 0}, u[t], t] // Simplify; \ 
    u[t_] = u[t] /. First[solnu]\)

Plot[{y[t], u[t]}, {t, -1 , 40}]

These are examples of oscillations and damped oscillations.