Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Non-Linear pendulum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104925] Re: Non-Linear pendulum
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Fri, 13 Nov 2009 05:56:11 -0500 (EST)
  • References: <hdgr31$jbl$1@smc.vnet.net>

Several errors here. 1) You use the undefined theta instead of the
solution of the equation (s). 2) The result in s should be morphed a
bit to be useable 3) Rotate should not be used in a graphics
environment. Use GeometricTransformation and RotationTransform
instead. 4 Spelling of \[Theta] as \[Theta[ doesn't help either.

The following works:

pendulum = {Line[{{0, 0}, {0, -1}}], Circle[{0, -1.3}, 0.3]};
l = 20;
g = 9.81;
s = \[Theta] /. (NDSolve[{\[Theta]''[
        t] == -g/l Sin[\[Theta][t]], \[Theta][0] ==
       Pi/2, \[Theta]'[0] == 0}, \[Theta], {t, 0, 30}])[[1, 1]]
Animate[Graphics[
  GeometricTransformation[pendulum, RotationTransform[s[t]]],
  PlotRange -> {{-2, 2}, {0, -2}}], {t, 0, 30},
 AnimationRunning -> False]

Cheers -- Sjoerd

On Nov 12, 1:21 pm, Allamarein <matteo.diplom... at gmail.com> wrote:
> I'm getting to know Mathematica. I want to compile a code to see the
> non-linear pendulum behavior.
>
> pendulum= {Line[{{0, 0}, {0, -1}}], Circle[{0, -1.3}, 0.3]};
> l = 20;
> g = 9.81;
> s = NDSolve[
>    { \[Theta]''[t] == -g /l Sin[\[Theta][t]],
>     \[Theta][0] == Pi/2,
>     \[Theta]'[0] == 0}, \[Theta],
>    {t, 0, 30}];
> Animate[
>  Graphics[Rotate[pendulum, \[Theta[]t], {0, 0}],
>   PlotRange -> {{-2, 2}, {0, -2}}],
>  {t, 0, 30}, AnimationRunning -> False]
>
> This code doesn't work. I realized my error is in Rotate argument. If
> I change this line with:
>
> Graphics[Rotate[pendulum, Sin[t], {0, 0}]
>
> code runs, but it's not the result (obviously).
> How can I correct my code, to see the pendulum oscillates with \[Theta]
> [t] law?



  • Prev by Date: Re: Re: How to Calculatelength of an Spline curve between
  • Next by Date: Dialogue box generator
  • Previous by thread: Re: Non-Linear pendulum
  • Next by thread: Re: Non-Linear pendulum