i want to see the simulation of two uncoupled Simple Harmonic Motion (SHM) pendulum with different Lengths and released at different initial displacement angles. in this case adding one more pendulum in my code

also, How to plot the graph of phase difference between these two pendulums vs time. for a fixed initial displacement.

this is my code so far with single pendulum.

theta0 = 15 Degree; L = 2.01; g = 9.81;
omega = Sqrt[g/L];
T = 2 Pi/omega;
theta[t_] := theta0*Cos[omega*t];
x[t_] := L*Sin[theta[t]]; y[t_] := -L*Cos[theta[t]];

 line := Line[{{0, 0}, {x[t], y[t]}}];
  {Point[{x[t], y[t]}],
   line}, PlotRange -> {{-5, 5}, {-5, 0}}, Frame -> True], {t, 0, 2 T,
   0.05 T}]

enter image description here

All help is much appreciated.

  • 1
    $\begingroup$ What is the actual MMA problem you are unable to solve? $\endgroup$ – Quantum_Oli Mar 17 '16 at 10:17
  • $\begingroup$ @Quantum_Oli i want to add another pendulum and see it phase difference. given difference length, $\endgroup$ – Nabil Mar 17 '16 at 11:24
  • 1
    $\begingroup$ The different initial angles do not change anything, since this just scales the amplitude. The difference in length means different frequencies (thus different times for the phase to accumulate 2Pi). Phase of a harmonic oscillator is linear in time. You will not get a very interesting graph, you'll simply get a linear function of time. Perhaps you are looking for something else? You can get some groovy beat-frequency patterns if you take the difference in displacement, for example. $\endgroup$ – LLlAMnYP Mar 17 '16 at 11:29

This allows you to watch two pendulums swing in time,

g = 9.81;
pendulumTrajectory[L_, theta0_, t_] := With[
   {theta = theta0 Cos[Sqrt[g/L] t]},
   {L Sin[theta], -L Cos[theta]}
 point1 = pendulumTrajectory[2.01, 15 Degree, t];
 point2 = pendulumTrajectory[3.01, 25 Degree, t];

 line2 = Line[{{0, 0}, point2}];
 Graphics[{{Red, {PointSize[Large], Point[point1]}, 
    Line[{{0, 0}, point1}]},
   {Blue, {PointSize[Large], Point[point2]}, 
    Line[{{0, 0}, point2}]}},
  PlotRange -> {{-5, 5}, {-5, 0}}, Frame -> True], {t, 0, 10, 0.05}]

enter image description here

  • $\begingroup$ This is just Perfect! one good example of two pendulum with difference length swinging. Thanks $\endgroup$ – Nabil Mar 17 '16 at 11:45
  • 1
    $\begingroup$ For something really cool, look at the answers to this question $\endgroup$ – Jason B. Mar 17 '16 at 11:46

Here is a generalization to many pendula. The phase differences in this case are revealed by the special points in time at which "revivals" occur, i.e., where the pendula that have all been launched with the same angle all group back together:

pendulum[α_, l_] := 
 Module[{radius = .03, 
   p = -l {Sin[α], Cos[α]}}, {{Brown, 
    Line[{{0, 0}, p}]}, {Orange, Disk[p, radius]}}]

pendulumArray[t_, α0_] := 
 Graphics[{{Cyan, Disk[{0, 0}, .03]}, 
   Table[pendulum[α0 Cos[2 Pi ν t], 1/ν^2], {ν, 
     51/60, 65/60, 1/60}]}, Background -> Black, 
  PlotRange -> {1.8 {-Sin[α0], Sin[α0]}, {-1.45, .05}}]

created with convert -scale 33% -colors 8

  • $\begingroup$ Thank you, dear Jens, for sharing this with us. This is truly mesmerizing. +ComplexInfinity. Just how many frames is this? $\endgroup$ – LLlAMnYP Mar 17 '16 at 17:14
  • $\begingroup$ @LLlAMnYP Thanks - it's about 2400 frames (from a ListAnimate), and I had to shrink the GIF down quite a lot because the upload limit on this site is just 2MB... $\endgroup$ – Jens Mar 17 '16 at 18:05
  • $\begingroup$ @Jens , I'm always amazed by how in-depth your answers are. The post I linked to with the double pendulum I saw that you answered 2 hours after it was asked and I wondered "Did he have that already worked out for a class or did he just make it on the fly?" $\endgroup$ – Jason B. Mar 17 '16 at 18:32
  • $\begingroup$ Indeed, low res, 8 color pallete, no doubt it's one full period of the system. Does anyone else see ballet dancers, turning into a tense game of ping-pong, then quite a lively game of soccer, before gradually restoring order? $\endgroup$ – LLlAMnYP Mar 17 '16 at 18:40
  • $\begingroup$ @JasonB Indeed, I had something prepared already in both this and the double-pendulum answer. The hard part was remembering where I kept it... and then making the movies to upload here. For this answer, I definitely wanted to show a movie, of course. As they say: two thousand pictures say more than a thousand words. Or something like that. $\endgroup$ – Jens Mar 17 '16 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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