# [✓] Derive, solve and plot the equations of motion for the double pendulum?

Posted 1 year ago
1482 Views
|
3 Replies
|
6 Total Likes
|
 I am trying to derive the equations of motion for the double pendulum and then solve and plot it. Unfortunately, it does not work. Any suggestions? Remove[l1, l2, m1, m2, g] x1 = l1*Sin[\[Theta]1[t]]; x1' = D[x1, t]; y1 = -l1*Cos[\[Theta]1[t]]; y1' = D[y1, t]; x2 = l2*Sin[\[Theta]2[t]] + x1; x2' = D[x2, t]; y2 = -l2*Cos[\[Theta]2[t]] + y1; y2' = D[y2, t]; V = m1*g*y1 + m2*g*y2; T = m1/2*(x1' + y1')^2 + m2*(x2' + y2')^2; Lagrange = T - V; eqs = D[D[Lagrange, \[Theta]'], t] - D[Lagrange, \[Theta]]; sol = NDSolve[{eqs == 0, \[Theta]1[0] = Pi, \[Theta]2[0] = Pi, \[Theta]1'[0] = 0, \[Theta]2'[0] = 0}, {\[Theta]1, \[Theta]2}, {t, 0, 10}]; l1 = 1; l2 = 1; g = 9.81; m1 = 1; m2 = 1; Plot[{\[Theta]1, \[Theta]2}, {t, 0, 10}] 
3 Replies
Sort By:
Posted 1 year ago
 I think your expression for the kinetic energy is incorrect.
 Thank you, I corrected it, but the output says: NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {True,\[Pi],\[Pi],0,0}. NDSolve::deqn: Equation or list of equations expected instead of True in the first argument {True,\[Pi],\[Pi],0,0}. 
 Disregarding physics and considering what you have done only programming-wise Boundary conditions need to be used with equal (==) rather then Set (i.e, a single = sign) There is a problem with the differentiation (the first part) You have two variables but only one differential equation, so after correcting the mistakes, you are still left with insoluble problem since NDSolve (or any other solution solution method, be it computational or analytical) will not be able to solve this. Here is the corrected code, you may continue from there l1 = 1; l2 = 1; g = 9.81; m1 = 1; m2 = 1; x1 = l1*Sin[\[Theta]1[t]]; x1' = D[x1, t]; y1 = -l1*Cos[\[Theta]1[t]]; y1' = D[y1, t]; x2 = l2*Sin[\[Theta]2[t]] + x1; x2' = D[x2, t]; y2 = -l2*Cos[\[Theta]2[t]] + y1; y2' = D[y2, t]; V = m1*g*y1 + m2*g*y2; T = m1/2*(x1' + y1')^2 + m2*(x2' + y2')^2; Lagrange = T - V eqs = D[D[Lagrange, \[Theta]'[t]], t] - D[Lagrange, \[Theta]]; sol = NDSolve[{Lagrange == 0, \[Theta]1[0] == Pi, \[Theta]2[0] == Pi, \[Theta]1'[0] == 0, \[Theta]2'[0] == 0}, {\[Theta]1, \[Theta]2}, {t, 0, 10}] HTHyehuda