Math 331.1 •  Fall 2005

Undamped harmonic oscillator

Copyright © 2005 Murray Eisenberg.  All rights reserved.

Example:  Undamped harmonic oscillator (mass m = 1, spring constant k = 2, damping coefficient b = 0)
	y''  +  2 y  =  0

Equivalent system of 1st order ODEs:

\(TraditionalForm\`\(y'\  = \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ v, 

      v'\  = \ \ \ \(-2\)\ y\ \)\)

Needs["Graphics`PlotField`"]

Clear[A];  A  =  { {0,  1},  {-2,  0} };  
    MatrixForm[A]

Clear [F];  F[x_,  v_]  :=  A  .  {x,  v};  F[x,  v]

field  =  
      PlotVectorField[F[x,  v],  {x,  -3,  3}, {v,  -3,  3},  
        Axes  ->  True,  AxesLabel  ->  {"x",  "y"}, 
         ScaleFunction  ->  (0.25&),  
        ScaleFactor  ->  0.175,  PlotPoints  ->  19];

Eigenvalues[A]

yk[t_]  :=  k1 Cos[(Sqrt[2]) t]  +  k2 Sin[(Sqrt[2]) t]

Solve[{yk[0]  ==  2,  yk'[0]  ==  1},  {k1,  k2}]

\(y[t_]\  := \ 2\ Cos[\@2\ t]\  + \ 1\/\@2\ Sin[\@2\ t]; 

    v[t_]\  := \ \(y'\)[t]; \ v[t]\)

phasecurve  =  
      ParametricPlot[Evaluate[{y[t],  v[t]}], 
         {t,  0,  ((2  π)/(Sqrt[2]))},  AspectRatio  ->  Automatic, 
         PlotRange  ->  {{-3,  3},  {-3,  3}}];

Plot[{y[t],  v[t]},  {t,  0,  3  (π/(Sqrt[2]))},  
      PlotStyle  ->  {RGBColor[0, 0, 0],  Dashing[{0.04,  0.03}]}];

Show[{field,  phasecurve}];