Re: Non-Linear pendulum

*To*: mathgroup at smc.vnet.net*Subject*: [mg104910] Re: [mg104874] Non-Linear pendulum*From*: Mark McClure <mcmcclur at unca.edu>*Date*: Fri, 13 Nov 2009 05:53:20 -0500 (EST)*References*: <200911121104.GAA18781@smc.vnet.net>

On Thu, Nov 12, 2009 at 6:04 AM, Allamarein <matteo.diplomacy at gmail.com> wrote: > I'm getting to know Mathematica. I want to compile a code to see the > non-linear pendulum behavior. There's a syntax error in your code. Also, you define s to be the solution arising from NDSolve but then never refer to it again. NDSolve returns its solution in terms of an InterpolatingFunction which you need to incorporate into your subsequent code. Here's your equation: Clear[th]; l = 20; g = 9.81; s = NDSolve[{ th''[t] == -g/l Sin[th[t]], th[0] == Pi/2, th'[0] == 0}, th, {t, 0, 30}]; th[t_] = th[t] /. s[[1]]; I've done just a couple of things here. I changed your typeset \[Theta] to a th, which I find to be more readable in a newsgroup like this and I've defined th[t] using the solution from NDSolve. I think that having the Clear[th] at the begininng is a good idea too, in case you need to re-execute the code. Now, I'm going to make a little change to your definition of pendulum, basically making it a function of t that takes rotation into account. pendulum[t_] := Rotate[{Line[{{0, 0}, {0, -1}}], Circle[{0, -1.3}, 0.3]}, th[t], {0, 0}]; Now, the following animation should do what you want. Animate[Graphics[pendulum[t], PlotRange -> {{-1.8, 1.8}, {-1.8, 0.5}}], {t, 0, 30}] Mark McClure

**References**:**Non-Linear pendulum***From:*Allamarein <matteo.diplomacy@gmail.com>