Legal Notice, Disclaimer, and Book Ordering Information:

(* Legal Notice, Disclaimer, and Book Ordering Information:

Last Modified: FIO January 1, 1995

Mathematica For Physics
Robert L. Zimmerman and Fredrick I. Olness
MathSource Number: 0206-862 

ISBN 0-201-53796-6
For ordering information, call 1-800-822-6339
Addison-Wesley Publishing Company

Communication with the authors:
Fredrick I. Olness:  olness@mail.physics.smu.edu
Robert L. Zimmerman: bob@zim.uoregon.edu

Copyright 1995, Addison-Wesley Publishing Company, Inc. The material in
this file may be distributed freely  so long as the content remains
unchanged, and the copyright and  reference notices are included. The
publisher grants permission for the noncommercial use of these programs
and program segments.  All other uses require the prior written consent
of the publisher.    

All rights are reserved with regard to the  material in the
"Mathematica For Physics" text, and may not be reproduced, stored in a
retrieval system, or transmitted,  in any form or by any means,
electronic, mechanical, photocopying,  recording, or otherwise, without
the prior written permission  of the publisher. 

The programs and applications presented in this book have been included
for  their instructional value. They have been tested with care but are
not  guaranteed for any particular purpose. The publisher does not
offer any  warranties or representations, nor does it accept any
liabilities with  respect to the programs or applications. 

 *)

Chapter 3, Section 3, Problem 1:   
Two Coupled Harmonic Oscillators

<<mainDir:subDir:ch3init.m  (* Mac  Version *)

<<mainDir/subDir/ch3init.m  (* Unix Version *)

Solution

Clear["Global`*"];

T= (m/2) ( (x[1])'[t]^2 + (x[2])'[t]^2 ); 
 
V=( (k1/2)( x[2][t] - x[1][t])^2 
   + k2/2   x[1][t]^2 
   + k2/2   x[2][t]^2
  );

q={x[1][t], x[2][t]};
p=D[q,t]

Tij=Outer[D[T,#1,#2]&,p,p];
Vij=Outer[D[V,#1,#2]&,q,q];

matrix = Vij - w2 Tij;
matrix //MatrixForm

w2Sol= Solve[ Det[matrix]==0, w2] //Simplify

vector= Array[a,2]

eq= Thread[0==matrix.vector]

eq1 = eq /.w2Sol[[1]] //ExpandAll //Simplify

eqNorm={vector.vector==1};

ev1rule=Solve[Join[eq1,eqNorm],vector][[2]]

eq2 = eq /.w2Sol[[2]] //ExpandAll //Simplify

ev2rule=Solve[Join[eq2,eqNorm],vector][[2]]

eq3= Thread[0== matrix.vector]

sol= Reduce[{eq3,eqNorm,k1 !=0,m !=0}//Flatten
      ,{w2,a[1],a[2]}]

eq4= smallOsc[ T,V,{x[1][t],x[2][t]},{0,0},t]

eigenmatrix= vector //.{ev1rule,ev2rule}

xRule={x1[t],x2[t]} ->
       ( Transpose[eigenmatrix]. {c1 Cos[ freq1 t + phase1] 
                                 ,c2 Cos[ freq2 t + phase2]} 
        )//Thread //Simplify

freqrule= Thread[{freq1,freq2} -> (Sqrt[w2] /.w2Sol) ]

values= {k1->1, k2->1, m->1, phase1->0, phase2->0};

allRules=Join[xRule,freqrule,values];

plot1a= 
Plot[{x1[t]+1, x2[t]-1} //.allRules //.{c1->1, c2->0} //Evaluate
       ,{t,0,20}
       ,PlotStyle->{{Thickness[0.010]},{Thickness[0.005]}}
    ];

plot1b= ParametricPlot[ 
  {x1[t], x2[t]} //.allRules //.{c1->1, c2->0} //Evaluate
 ,{t,0,20}];

Show[GraphicsArray[{plot1a,plot1b}]];

plot2a= 
Plot[{x1[t]+1, x2[t]-1} //.allRules //.{c1->0, c2->1} //Evaluate
       ,{t,0,20}
       ,PlotStyle->{{Thickness[0.010]},{Thickness[0.005]}}
    ];

plot2b= ParametricPlot[ 
  {x1[t], x2[t]} //.allRules //.{c1->0, c2->1} //Evaluate
 ,{t,0,20}];

Show[GraphicsArray[{plot2a,plot2b}]];

plot3a= 
Plot[{x1[t]+1, x2[t]-1} //.allRules //.{c1->1, c2->1} //Evaluate
       ,{t,0,20}
       ,PlotStyle->{{Thickness[0.010]},{Thickness[0.005]}}
    ];

plot3b= ParametricPlot[ 
  {x1[t], x2[t]} //.allRules //.{c1->1, c2->1} //Evaluate
 ,{t,0,20}];

Show[GraphicsArray[{plot3a,plot3b}]];