Mathematica Mathematica Input Equations of Motion

AI Thread Summary
The discussion revolves around inputting equations of motion for a double acting pendulum into Mathematica to solve for the angles θ2, θ2', and θ2''. The user is facing challenges with the syntax and structure required by Mathematica, particularly with the use of parentheses, brackets, and subscripting. Key points include the importance of correct syntax, as Mathematica is sensitive to the use of different types of brackets and case sensitivity in function names. The user has provided two equations of motion, but the initial attempts at using NDSolve have resulted in errors, indicating that the system may be underdetermined due to having more unknowns than equations. Suggestions include simplifying the problem to gain a better understanding of the syntax and structure needed to successfully implement the equations in Mathematica. The user is seeking assistance to finalize this work for their thesis.
DannyS
Messages
3
Reaction score
0
I am trying to input these 2 equations of motion for a double acting pendulum into mathematica in hopes of solving for θ2, θ2', and θ2''. I am fairly new to the program and I am having trouble inputting the equations. I am swinging a prosthetic leg like a pendulum and I am trying to predict what the second angle (θ2) will be. Can someone please tell me what I am doing wrong?

1. θ1'' = −g (2 m1 + m2) sin θ1 − m2 g sin(θ1 − 2 θ2) − 2 sin(θ1 − θ2) m2 (θ2'2 L2 + θ1'2 L1 cos(θ1 − θ2))/L1 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))

NDSolve[Subscript[\[Theta], 1]''[
t] == [[\[Minus]9.8*[ Subscript[m, 1] + Subscript[m, 2]]*
sin [Subscript[\[Theta], 1][t]]] \[Minus] [
Subscript[m, 2]*9.8*
sin[Subscript[\[Theta], 1][t] \[Minus]
2 Subscript[\[Theta], 2][t]]] \[Minus] [2*
sin[Subscript[\[Theta], 1][t] \[Minus]
Subscript[\[Theta], 2][t]]* Subscript[m,
2]*[(Subscript[\[Theta], 2]'[t])^2 Subscript[L,
2] + (Subscript[\[Theta], 1]'[t])^2*2* Subscript[L, 1]*
cos[Subscript[\[Theta], 1][t] \[Minus]
Subscript[\[Theta], 2][t]]]/[
Subscript[L,
1] (2*Subscript[m, 1] +
Subscript[m, 2] \[Minus]
Subscript[m, 2] *
cos (2*Subscript[\[Theta], 1][t] \[Minus]
2*Subscript[\[Theta], 2][t]))],
Subscript[\[Theta], 1][0] == 0,
Subscript[\[Theta], 2][0] == 0, (Subscript[\[Theta], 1],
Subscript[\[Theta], 2]), {t, 0, 10}]]]

2. θ2'' = 2 sin(θ1 − θ2) (θ1'2 L1 (m1 + m2) + g(m1 + m2) cos θ1 + θ2'2 L2 m2 cos(θ1 − θ2))/L2 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))

NDSolve[Subscript[\[Theta], 2]''] == [[
2*sin ((\[Pi]/6)*sin (55*[t]) - Subscript[\[Theta],
2])]*[(c)^2*1.61*.3 + [
9.8*1.61*
cos ((\[Pi]/6)*sin (55*[t]))]] + [(Subscript[\[Theta],
2]')^2*0.48*1.61*
cos ( (\[Pi]/6)*cos (55*[t]) - Subscript[\[Theta], 2])]/[
0.48*(1.61 - (1.61*
cos ((2*(\[Pi]/6)*cos (55*[t])) - (2*Subscript[\[Theta],
2]))))]]

I also attached the first equation with the numbers plugged in. I am using the equations of motion found here http://www.myphysicslab.com/dbl_pendulum.html This is the final step to completing my thesis so any help offered is much appreciated. Thank you in advanced.
 

Attachments

Physics news on Phys.org
Here are a few items that will help you get started.

1. Mathematica is fanatic about and completely unforgiving about the precise use of (), {} and []. In your first NDSolve you have many places where you have substituted pairs of these for other pairs. The result might look fine to you but it is completely unintelligible to Mathematica. And the error messages you get from this will make about as much sense to you as your input does to Mathematica. [] ONLY encloses function arguments. () ONLY groups expressions to override precedence. {} ONLY encloses a sequence of zero or more elements of a list.

2. Mathematica is fanatically case sensitive. Cos[t] is understood. cos[t] means nothing unless you have previously defined your own function cos[t].

3. I realize more and more people stumble onto Subscript in particular and "desktop publishing" in general and expect they should and should be able to make the mathematics they write look like what they see in textbooks. Watching from the sidelines for a long time has mostly convinced me that even after you get the mathematics correct that the work involved in "desktop publishing" mathematics is more work than getting the mathematics right in the first place and trying to both get the math right and published quality at the same time may make the overall cost even higher.

I have stripped all your Subscripting, fixed capitalization, fixed (), {} and [] I think and some very weird \[Minus] that I have never seen before, all in an attempt to at least get your first NDSolve to work.

NDSolve[{t1''[t] == ((-9.8*(m1 + m2)*Sin[t1[t]]) - (m2*9.8*Sin[t1[t] - 2 t2[t]]) - (2*Sin[t1[t] - t2[t]]*m2*((t2'[t])^2 l2 + (t1'[t])^2*2*l1*Cos[t1[t] - t2[t]])/(l1 (2*m1 + m2 - m2*Cos [2*t1[t] - 2*t2[t]])))),t1[0] == 0, t2[0] == 0}, {t1, t2}, {t, 0, 10}]

This is closer. But it still fails. It warns that the system is underdetermined. Perhaps this is because a solution would satisfy five unknowns, t1''[t], t1'[t], t1[t], t2'[t] and t2[t], but you only have three equations. Or perhaps my attempt to patch your code is incorrect.

Compare my undesktoppublished version to yours and see if you can justify or correct any of my changes and get to a point where the system will solve.

You might consider making up a far simpler system, but with the same number of unknowns, and try to get the simpler problem to correctly solve. With that experience you might learn some things to enable you to solve your more complex problem.
 
Last edited:
Thank you for your help! I am working on cleaning it up.
 

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
1K
Replies
3
Views
3K
Replies
9
Views
2K
Replies
3
Views
2K
Replies
1
Views
2K
Replies
6
Views
7K
Back
Top