Message Boards Message Boards

5 Replies
1 Total Likes
View groups...
Share this post:

Double pendulum in Mathematica

Posted 10 years ago

I've found this awesome Wolfram guide on how to create a double pendulum in Mathematica. But I'd like to know how to make it more interactive, I mean implement adjustable masses of the two pendulums, adjustable lengths of the rods, etc. I know I probably have to use Manipulate. I'd be very grateful for any help.

5 Replies

There are several ways of how one could set up the equations to describe the motion. The Featured Example page in the WLDC uses (fixed) Cartesian coordinates and the componentwise F = m a approach which is the first thing an engineering student learns in freshman year. Wolfram's set of equations nicely describe the motion without using sine, cosine, angles or their 1st/2nd time derivatives; it is very easy on the eye, which i like: the set almost looks like a linear ODE system (but, of course, it isn't). In general, the only problem/difficulty with setting up the equations of motion in fixed Cartesian coordinates is getting the algebraic signs painstakingly 100% correct — because the signs depend heavily on how the x-y-sytem is oriented: where does the positive X-axis point to, and where does the positive Y-axis point to?

The point of this post is to raise awareness that, IF you're sitting in a chair in front of your computer screen AND let the X-axis point to your right AND let the Y-axis point to the top of the screen ("pointing to the room ceiling above your head") —which is actually the convention used in Mathematica and in that Feature Example—, THEN some of the signs used in Wolfram's set are indeed formally and technically wrong. If you were a grade A student, you would know/notice right away when studying the short page. I prefered not to regard/report it as ordinary typo but to put it up for discussion and raising awareness among Engineering Mechanics experts. This is not about agreement or disagreement, this is about right or wrong. The reason/cause why/how it is so easy to mess up the signs is because of the very location of the two pendulums: they are located in quadrant IV of the coordinate system! In quadrant IV all y-coordinates are negative. The student must then take extra special care of the signs and it becomes easier to make mistakes; also, the resulting equations will contain more negative signs! (Therefore, to make one's life easier, it is common and advisable practice to always orient the coordinate system in such a way that the moving objects are located in quadrant I at the time of equation formulation.) In any case, the below set is the 100% right one for a fixed Cartesian coordinate system with the pos. X-axis pointing to your right and the pos. Y-axis to your top, you're welcome:

$${m_1{\ddot{x}_1}(t) = -\frac{\lambda _1(t)}{l_1} x_1(t)+\frac{\lambda _2(t)}{l_2}\left(x_2(t)-x_1(t)\right)}$$

$${m_1{\ddot{y}_1}(t) = -\frac{\lambda _1(t)}{l_1} y_1(t)+\frac{\lambda _2(t)}{l_2}\left(y_2(t)-y_1(t)\right)-m_1g}$$

$${m_2{\ddot{x}_2}(t) = -\frac{\lambda _2(t)}{l_2}\left(x_2(t)-x_1(t)\right)}$$

$${m_2{\ddot{y}_2}(t) = -\frac{\lambda _2(t)}{l_2}\left(y_2(t)-y_1(t)\right)-m_2g}$$

Two concessions though:

  1. The page does not explicitly specify the x-y coordinate system, we don't see a drawing of the axes of coordinates. Depending on how you let their axes point in positive directions, the signs in their given equations set could be considered correct, eventually. Okay. However, looking at the initial conditions and where/how the animation starts, it is clear that the page does assume the standard axes orientation on the computer screen, as described above. With this orientation, the equations are incorrect. Technically/formally. If anyone cares or has noticed.
  2. The fortunate thing is, nature does not care how you orient your fixed coordinate system to describe a motion. The solution, the motion, will be the same, no matter how you oriented the fixed axes of coordinates at the start of trying to solve the problem. Of course, one cannot generalize such a bold statement (and engineering students will lose points in their midterms for getting the signs incorrect) but, apparently, in this example, the solution is the same.

I will now go back to where i came from, and I don't need/want Wolfram to correct their page accordingly, simply because the point of the Featured Example page is to teach about Wolfram L and not to teach about pedanticism re junior college Engineering Mechanics. Needless to say, if i were the editor, i would correct the image on that page (by adding a drawing of the axes of coordinates) and correct the signs in the equations set accordingly. Sorry for being the clever **ck today but i simply couldn't hold back. I lerv my engineering mechanics 's all.

Last but not least here some piece of advice to whom it may concern ;)

If you're copy pasting (or comparing, for that matter) a solution (e.g. an equation, a formula, an expression/a term, a set of equations) from somewhere (e.g. wikipedia, blog, forum, formulary, journal, ebook, textbook, etc), make sure that it comes with a clearly indicated coordinate system (its frame of reference, its domain of validity) and that the orientation of the coordinate system coincides with the one that you are using in your problem/solution. Otherwise you cannot just copy/paste i.e. adopt 1-by-1 the solution which you've just looked up for completing your task. It's not a diss but sorry for the bad news, you really need to know what you're doing there. :P

POSTED BY: Raspi Rascal

Like everything in physics modeling, one has to start with the equations of motion. Here is small note on the subject. with notebook. All what you have do is wrap it in a Manipulate. You can adjust the masses and the lengths using sliders. Some of these equations are used as basis for the triple pendulum demo

POSTED BY: Nasser M. Abbasi

I suggest you first put a single pendulum model inside Manipulate. Once you've got that running, move up to the double pendulum. It's easier to troubleshoot a simpler problem.

POSTED BY: Frank Kampas

Yes, I have seen these other projects, but they are way too complicated for me. The one I've posted is pretty simple. I just want to modify it a little to make it more interactive.

A simple search for Double pendulum in the Wolfram Demonstration Project gives a lot of results. Code is downloadable.

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract