home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Physics / SpringyPendulum / SpringyPendulum.app / springyPendulum.ma < prev    next >
Encoding:
Text File  |  1991-12-05  |  12.3 KB  |  231 lines

  1. (*^
  2.  
  3. ::[paletteColors = 128; currentKernel; 
  4.     fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8,  24, "Times"; ;
  5.     fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6,  18, "Times"; ;
  6.     fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, L1, e6,  14, "Times"; ;
  7.     fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L1, a20,  18, "Times"; ;
  8.     fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L1, a15,  14, "Times"; ;
  9.     fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L1, a12,  12, "Times"; ;
  10.     fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  11.     fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  10, "Times"; ;
  12.     fontset = input, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1,  12, "Courier"; ;
  13.     fontset = output, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5,  12, "Courier"; ;
  14.     fontset = message, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1,  12, "Courier"; ;
  15.     fontset = print, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1,  12, "Courier"; ;
  16.     fontset = info, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1,  12, "Courier"; ;
  17.     fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1,  12, "Courier"; ;
  18.     fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1,  10, "Times"; ;
  19.     fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  20.     fontset = Left Header, nohscroll, cellOutline,  12;
  21.     fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, L1,  12;
  22.     fontset = Left Footer, cellOutline, blackBox,  12;
  23.     fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  10, "Times"; ;
  24.     fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  25.     fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12, "Courier"; ;
  26.     fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  27.     fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  28.     fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  29.     fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;
  30.     fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1,  12;]
  31. :[font = title; inactive; preserveAspect; ]
  32. Lagrange's Equations for a Pendulum on a Spring.
  33. :[font = subtitle; inactive; preserveAspect; ]
  34. by Charles G. Fleming
  35. Educational Computing Services
  36. Allegheny College
  37. Partially supported by a grant from the 
  38. Vira Heinz Foundation.
  39. :[font = subtitle; inactive; preserveAspect; ]
  40. This notebook contains a step-by-step derivation of Lagrange's differential equations for the motion of a pendulum whose rotating arm is a spring instead of a rigid arm.  Although this notebook deals with a specific mechanical system, it should be relatively easy for the user to modify it to handle a wide variety of other mechanical systems.
  41. :[font = section; inactive; Cclosed; preserveAspect; startGroup; ]
  42. Set Up
  43. :[font = input; initialization; preserveAspect; endGroup; ]
  44. *)
  45. Off[General::spell]
  46. Off[General::spell1]
  47. (*
  48. :[font = section; inactive; Cclosed; preserveAspect; startGroup; ]
  49. The derivation of Lagrange's Equations
  50. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  51. The Coordinates 
  52. :[font = text; inactive; preserveAspect; endGroup; ]
  53. Polar coordinates, r and theta,  naturally describe the position of the mass on a pendulum whose arm is a spring rather than a rigid rod.  We will refer to this mechanical system as a springy pendulum. The attachement point for the pendulum arm is assumed to be at r = 0.  We denote the natural length of the spring by r0.  Theta is measured from  the negative x axis,  in the counterclockwise direction .   
  54. ;[s]
  55. 3:0,0;320,1;321,2;408,-1;
  56. 3:1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;
  57. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  58. The Kinetic Energy
  59. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  60. The formula for the kinetic energy of the system is 1/2 m v2, where v denotes the length of the velocity vector.  Recall that the velocity vector is given by (ds/dt, dr/dt) where s is the arc length parameter for the path along which the mass travels.  Since s = r theta, we have that the velocity is given by (r dtheta/dt, dr/dt).  Therefore v2 is 
  61. (r dtheta/dt)2 + (dr/dt)2.  We denote the kinetic energy by T.
  62. ;[s]
  63. 9:0,0;59,1;60,2;344,3;345,4;363,5;364,6;374,7;375,8;412,-1;
  64. 9:1,14,11,Times,0,16,0,0,0;1,14,11,Times,32,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,32,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,32,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,32,16,0,0,0;1,14,11,Times,0,16,0,0,0;
  65. :[font = input; initialization; preserveAspect; endGroup; endGroup; ]
  66. *)
  67. T = (m/2) ( (r[t] D[theta[t], t])^2 + (D[r[t], t])^2 )
  68. (*
  69. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  70. The Potential Energy
  71. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  72. The calculation of the potential energy of the system is a little more challenging.  The potential energy at a point (r, theta) is by definition the negative of the path integral of  f . dR, from some reference point 
  73. (rRef, thetaRef) to the point (r, theta).   f is the force acting on the mass and R is the position vector of the mass. 
  74. ;[s]
  75. 1:0,0;338,-1;
  76. 1:1,14,11,Times,0,16,0,0,0;
  77. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup; ]
  78. The position vector
  79. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  80. The position vector R with respect to the standard basis is given by the following formula. 
  81. ;[s]
  82. 1:0,0;92,-1;
  83. 1:1,14,11,Times,0,16,0,0,0;
  84. :[font = input; initialization; preserveAspect; endGroup; endGroup; ]
  85. *)
  86. R = {r Cos[theta], r Sin[theta]}
  87. (*
  88. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup; ]
  89. Tangent vectors
  90. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  91. A more natural basis for this problem is obtained by thinking of r and theta as curvilinear coordinates.  The tangent vectors along curves obtained by holding r and then theta fixed, form a basis.  These vectors are easy to compute.
  92. ;[s]
  93. 1:0,0;232,-1;
  94. 1:1,14,11,Times,0,16,0,0,0;
  95. :[font = input; initialization; preserveAspect; ]
  96. *)
  97. vr = D[R, r]
  98. (*
  99. :[font = input; initialization; preserveAspect; endGroup; ]
  100. *)
  101. vtheta = D[R, theta]
  102. (*
  103. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  104. The following calculuations show that vr has length one, but vtheta has length r.  This will be important when we compute f . dR.
  105. ;[s]
  106. 5:0,0;39,1;40,2;62,3;67,4;129,-1;
  107. 5:1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;
  108. :[font = input; initialization; preserveAspect; ]
  109. *)
  110.  
  111. lenr = Sqrt[vr . vr] /. Sin[theta]^2 -> 1 - Cos[theta]^2
  112. (*
  113. :[font = input; initialization; preserveAspect; ]
  114. *)
  115.  
  116. lentheta = Sqrt[vtheta . vtheta] /. Sin[theta]^2 -> 1 - Cos[theta]^2
  117. (*
  118. :[font = input; initialization; preserveAspect; endGroup; endGroup; ]
  119. *)
  120.  
  121. lentheta = Simplify[lentheta]
  122. (*
  123. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup; ]
  124. The differential of position
  125. :[font = text; inactive; preserveAspect; ]
  126. The differential of the position vector dR is simply
  127. ;[s]
  128. 1:0,0;52,-1;
  129. 1:1,14,11,Times,0,16,0,0,0;
  130. :[font = input; initialization; preserveAspect; endGroup; ]
  131. *)
  132. dR = vr dr + vtheta dtheta
  133. (*
  134. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup; ]
  135. The forces
  136. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  137. The component of the force on the mass in the vr direction is obtained from Hooke's Law.
  138. ;[s]
  139. 3:0,0;47,1;48,2;88,-1;
  140. 3:1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;
  141. :[font = input; initialization; preserveAspect; endGroup; ]
  142. *)
  143. fr = - k (r - r0) vr
  144. (*
  145. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  146. The component of the force in the vtheta direction is due to gravity.
  147. ;[s]
  148. 1:0,0;69,-1;
  149. 1:1,14,11,Times,0,16,0,0,0;
  150. :[font = input; initialization; preserveAspect; ]
  151. *)
  152. ftheta = - m g Sin[theta] vtheta
  153. (*
  154. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  155. Now since ftheta is in terms of a unit vector in the theta direction, and since as we saw above, vtheta has length r, we must modify ftheta before we use it in our calculations.
  156. ;[s]
  157. 7:0,0;11,1;16,2;98,3;103,4;134,5;139,6;177,-1;
  158. 7:1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;
  159. :[font = input; initialization; preserveAspect; endGroup; endGroup; endGroup; ]
  160. *)
  161. ftheta = ftheta / r
  162. (*
  163. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup; ]
  164. Compute    f . dR
  165. :[font = input; initialization; preserveAspect; ]
  166. *)
  167. fdR = Simplify[(fr + ftheta) . dR]
  168. (*
  169. :[font = input; initialization; preserveAspect; ]
  170. *)
  171. fdR = fdR /. Sin[x_]^2 -> 1 - Cos[x]^2
  172. (*
  173. :[font = text; inactive; preserveAspect; endGroup; ]
  174. This result can also be rewritten as 
  175. f . dR = - k (r - r0) dr - m g Sin[theta] r dtheta.
  176. ;[s]
  177. 1:0,0;89,-1;
  178. 1:1,14,11,Times,0,16,0,0,0;
  179. :[font = subsubsection; inactive; Cclosed; preserveAspect; startGroup; ]
  180. Compute the potential energy
  181. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  182. To compute the potential energy at an arbitrary point (r, theta), we must now integrate - f . dR along a path from some reference point to the point (r, theta).  We wil choose the point (r0, Pi/2) as our reference point and assume that the potential there is zero.  Recall that we are free to choose any point as the reference point and can assign to that point as potential we wish.  Since the forces considered here are conservitave, we can integrate along any path from (r0, Pi/2) to (r, theta).  The path we choose is the path from (r0, Pi/2) to (r, Pi/2) where the angle constant, and then from (r, Pi/2) to (r, theta) where r is constant.  Along the first path dtheta is zero, and along the second path dr is zero.  Since r and theta are functions of t, we insert this dependence in the following formulas.
  183. ;[s]
  184. 7:0,0;188,1;189,2;475,3;476,4;538,5;539,6;812,-1;
  185. 7:1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;1,14,11,Times,64,16,0,0,0;1,14,11,Times,0,16,0,0,0;
  186. :[font = input; initialization; preserveAspect; ]
  187. *)
  188.  
  189. integral1 = - Integrate[ - k (u - r0) , {u, r0, r[t]}]
  190. (*
  191. :[font = input; initialization; preserveAspect; ]
  192. *)
  193.  
  194. integral2 = - Integrate[ - m g Sin[u] r[t] , {u, Pi/2, theta[t]}]
  195. (*
  196. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  197. The potential energy of this system then is
  198. ;[s]
  199. 1:0,0;43,-1;
  200. 1:1,14,11,Times,0,16,0,0,0;
  201. :[font = input; initialization; preserveAspect; endGroup; endGroup; endGroup; endGroup; endGroup; ]
  202. *)
  203. V = integral1 + integral2
  204. (*
  205. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  206. The Lagrangian
  207. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  208. Recall that the Lagrangian is T - V.
  209. ;[s]
  210. 1:0,0;36,-1;
  211. 1:1,14,11,Times,0,16,0,0,0;
  212. :[font = input; initialization; preserveAspect; endGroup; endGroup; ]
  213. *)
  214. L = Simplify[T - V]
  215. (*
  216. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ]
  217. Lagrange's Equations
  218. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ]
  219. Our last step is to compute Langrange's equations.  These second order equations will describe the motion of the springy pendulum.
  220. ;[s]
  221. 1:0,0;130,-1;
  222. 1:1,14,11,Times,0,16,0,0,0;
  223. :[font = input; initialization; preserveAspect; ]
  224. *)
  225. equ1 = D[ D[L, D[r[t], t]], t] - D[L, r[t]]
  226. (*
  227. :[font = input; initialization; preserveAspect; endGroup; endGroup; endGroup; ]
  228. *)
  229. equ2 = D[ D[L, D[theta[t], t]], t] - D[L, theta[t]]
  230. (*
  231. ^*)