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 4, Section 1, Problem 3:   
Bead on a Rotating Hoop

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

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

Solution

Clear["Global`*"];

x2rRule= {x,y,z}->{ ( r Sin[theta[#]]Cos[w #])&,
                    ( r Sin[theta[#]]Sin[w #])&,
                    ( r Cos[theta[#]]        )&}//Thread;

T= (m/2)  (x'[t]^2 + y'[t]^2 + z'[t]^2);
 V=  m g z[t];

L= (( (T-V) //.x2rRule
            //Simplify
            //TrigReduce
          ) //.{Cos[x_]^2->1-Sin[x]^2}
            //ExpandAll
         )

Lag[theta,L]

thetaSol= ( Solve[ Lag[theta,L], theta''[t]]
               //Flatten
               //.{g->wc^2 r}
               //ExpandAll
            )

energy= ( (theta'[t] D[L,theta'[t]]-L) 
          //.{g->wc^2 r}
          //.{Cos[x_]^2->1-Sin[x]^2}
          //ExpandAll
        )

{pRule, hamiltonian, eqMotion}= 
       Hamilton[L,{theta},{ptheta}];

energy==hamiltonian //.{g->wc^2 r} //.pRule

D[energy,t] //.thetaSol //.{g->wc^2 r} //Expand

Veff = energy //.{theta'[t]->0}

dVeff= D[Veff,theta[t]]  //Factor

Solve[dVeff/ Sin[theta[t]]==0,theta[t]][[1]]

eqRule=(
     theta[t]->{0,Pi,ArcCos[-wc^2/ w^2]
                    ,ArcCos[+wc^2/ w^2]+Pi}
                       );

dVeff==0  /.eqRule //Thread

values1={r->1, wc->1, m->1
        ,theta[t]->theta};

Plot3D[Veff //.values1 //Evaluate
        ,{theta,-Pi,Pi}
        ,{w,1,3}
        ,AxesLabel->{"theta","w","Potential"}];

p1= Plot[ Veff //.values1 /.{w->0.2} //Evaluate
           ,{theta,-Pi,Pi}];

p2= Plot[ Veff //.values1 /.{w->2.0} //Evaluate
           ,{theta,-Pi,Pi}];

Show[p1,p2];

eq1= thetaSol //.{g->wc^2 r} /.Rule->Equal

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

values2=  {w->2, wc->1};

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

ndsol1= NDSolve[{eq2//.values2,initial} //Flatten
             ,{theta[t],dtheta[t]},{t,0,30}][[1]]

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

Plot[ theta1[t] ,{t,0,30}];

Plot[dtheta1[t] ,{t,0,30}];

bead[t_]:= 
  Graphics[
    { PointSize[0.03],
      Point[{Sin[theta1[t]],Cos[theta1[t]]} ]
    }];

frames=12;
Do[  
   Show[ 
     bead[t]
    ,Graphics[{Hue[.1],Circle[{0,0},1]}
             ,AspectRatio->Automatic]
             ,PlotRange ->{{-2,2},{-2,2}}
             ]
,{t,0,20,20/(frames-1)}]