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 2, Problem 4:   
Motion of a Damped, Forced Nonlinear Pendulum

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

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

Solution

Clear["Global`*"];

eq1=theta''[t] + gam theta'[t]+ w0^2 Sin[theta[t]]==f0 Cos[wd t]

eq2= eq1 /.{theta'[t]->dtheta[t], theta''[t]->dtheta'[t]};
eq3={eq2, theta'[t]==dtheta[t]}

linearEq= eq3 //Map[Series[#,{theta[t],0,1}]&,#,{3}]& //Normal

values={w0->1, wd->1, gam->0.01, f0->0.2};

initial={theta[0]==0.9 Pi, dtheta[0]==0};

ndsol1=NDSolve[Join[eq3,initial] //.values //Evaluate
                ,{theta[t],dtheta[t]}
                ,{t,0,100}
                ,MaxSteps->1000][[1]]

theta1[t_]= theta[t] //.ndsol1;
dtheta1[t_]=dtheta[t] //.ndsol1;

ndsol2=NDSolve[Join[linearEq,initial] //.values //Evaluate
                ,{theta[t],dtheta[t]}
                ,{t,0,100}
                ,MaxSteps->1000][[1]]

theta2[t_]= theta[t] //.ndsol2;
dtheta2[t_]=dtheta[t] //.ndsol2;

Plot[{theta1[t],theta2[t]}
         ,{t,0,100}
         ,PlotStyle->{{Thickness[0.010]},{Thickness[0.005]}}];

fplot1= Show[ fftSpectrum[theta1[t], t, 100] 
             ,PlotRange->{{0,30},{0,25}}];

fplot2= Show[ fftSpectrum[theta2[t], t, 100] 
             ,PlotRange->{{0,30},{0,25}}];

Show[GraphicsArray[{fplot1,fplot2}]];

doublePlot[theta1[t],dtheta1[t],{t,0,100}];

doublePlot[theta2[t],dtheta2[t],{t,0,100}];