Take the 2-minute tour ×
Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free, no registration required.

I've been having difficulty creating a mathematical model of a pendulum in my code. While there is plenty of info on general equations describing a the motion of a pendulum, I seem to be having difficulty translating those into code, or more specifically cartesian coordinates. These difficulties no doubt stem from my poor math skills, thus, I am looking for help.

My initial thought before even researching the matter was to simply use two independent Sine Wave oscillators. I used a basic equation y(t) = A*sin(ω*t+φ). I think that its probably worth mentioning here that while I understand what that equation does. I'm not 100% clear one why it behaves periodically. Of course have dealt with trigonometric ratios before, but I don't feel like I have a grasp on the actual concepts behind it. I don't fully appreciate all of its consequences I guess.

Anyways, I initially figured I could determine the x coordinate and the y coordinate using 2 separate sine wave oscillators, while having the period of the y oscillator be half of the value of the x oscillator. This however (possibly obvious to you...) resulted in something closely resembling lissajous curves.

Now I've been reading explanations on the movement of a pendulum, yet while reading I get lost at two points regardless of the source I am reading from.

First of all, everyone refers to a differential equation that I don't understand, probably due to never taking calculus. Here is a link to them all... http://hyperphysics.phy-astr.gsu.edu/hbase/pend.html#c3

And secondly, how can I derive two separate coordinates from one of these equations?

share|improve this question
    
As a primer, you might want to look up Polar Coordinates. Your pendulum is most naturally described by the angle $\theta$, from which you obtain $x$ and $y$ using trigonometry. –  Lagerbaer May 14 '11 at 21:47
1  
Yeah, I had done that i think. I wrote a function and used its output like... r*cos(oscil(t)), r*sin(oscil(t))... –  Pete May 14 '11 at 22:02

1 Answer 1

Forget about the motion for a moment. First just consider a pendulum of length $\ell$ at an angle $\vartheta$ from rest. If $(0,0)=0\mathbf{e}_x+0\mathbf{e}_y$ is where the pendulum is attached, then the end of it is at $$ \bigl(\ell\cdot\sin(\vartheta), -\ell\cdot\cos(\vartheta)\bigr) $$

So, now let's describe the motion in terms of these variables. $\ell$ would usually be constant, so we don't need to care about this. It's $\vartheta$ that varies in time, so we get $$ y(t) = -\ell\cdot\cos(\vartheta(t)), $$ $$ x(t) = \ell\cdot\sin(\vartheta(t)), $$ Unfortunatly, we don't know $\vartheta(t)$ yet. We can either

  1. Assume that it does oscillate harmonically, that is, $\vartheta(t)=A\cdot\sin(\omega t)$ for some $A$ and $\omega$, which is often a good approximation.
  2. Decide we can do better, which is necessary if you consider big angles like $30^\circ$.

Lets stick to small angles here. $\vartheta(t)=A\cdot\sin(\omega t)$ with $A\ll1$. We can then try to further simplify the cartesian coordinate representations: in $$ x(t) = \ell\cdot\sin(\vartheta(t)) = \ell\cdot\sin\bigl(A\cdot\sin(\omega t)\bigr), $$ we can use that $A\cdot\sin(\omega t)\ll 1$ and $\sin(x)\approx x$ for $x\ll 1$, therefore $$ x(t) \approx \ell\cdot A\cdot\sin(\omega t). $$ In $$ y(t) = -\ell\cdot\cos(\vartheta(t)) = -\ell\cdot\cos\bigl(A\cdot\sin(\omega t)\bigr), $$ we can use that $\cos(x)\approx 1-\tfrac{x^2}2$ for $x\ll 1$, therefore $$ y(t) \approx \ell\cdot \bigl(\tfrac{A^2}2\cdot\sin^2(\omega t)-1\bigr) $$ which, due to $\sin^2(x)=\tfrac12-\tfrac12\cos(2x)$, can be further simplyfied to $$ y(t) \approx \tfrac{A^2}{4}\ell\cdot\cos(2\omega t) - \tfrac\ell2. $$ As you see, two harmonic oscillators is in fact not such a bad assumption, and the important thing is that $y$ must oscillate at twice the frequency of $x$.


Sorry, I forgot about this question...

When I say $\sin(x)$ is approximately $x$, I mean just what I say: if you look at the sine function, and "zoom in" very close to 0 (that is, $x\ll1$, for instance $x=.001$), then this function looks very much like the simple $f(x)=x$. http://www.wolframalpha.com/input/?i=plot+sin%28x%29+from+-.01+to+.01 It's just when you look very carefully that you notice it's in fact bent a little bit.

share|improve this answer
    
Ok so I'm doing my best to follow your answer. Thanks for putting in the effort to make it so exhaustive. So what I am gaining from your post is: If we could know the angle at every instant we could merely find the location of the pendulum with y(t)=-l*cos(theta(t)). However since we cannot know the angle of its path we must take that into account when solving the problem. Thus we can expand the expression of theta into l*sin(A*sin(frequency*t)). At this point I lose you for a second... I understand that A*sin(wt) is necessarily much smaller (thats what '<<' indicates, right?) continued –  Pete May 15 '11 at 20:16
    
than 1. But what do you mean that sin(x) is approximately x? Is sin(x) effectively saying sin(x(t)), which we know is much less than 1? Furthermore, I don't understand why its relation to 1 is relavant. The same questions arise of course when you talk about y(x). Finally, are you saying that equation y(t) = (A^2/2)L*cos(2wt)-(l/2) returns the value of theta? Or rather, is the equation of the oscillator need to simulate this motion? Thanks a lot for your help and baring with my poor math skills. –  Pete May 15 '11 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.