Mathematica Input Equations of Motion

In summary, the conversation is about inputting equations of motion for a double acting pendulum into Mathematica in order to predict the second angle (θ2). The person is having trouble inputting the equations and is seeking assistance. They have provided two equations and are trying to plug in numbers to solve the problem, but are encountering errors due to incorrect use of symbols and functions in Mathematica. They are advised to be careful with the use of (), {}, and [] and to consider simplifying their problem to better understand how to correctly input their equations.
  • #1
DannyS
3
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

  • Pendulum w:Numbers.nb
    8.1 KB · Views: 330
  • Equation 2.nb
    3.8 KB · Views: 267
Physics news on Phys.org
  • #2
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:
  • #3
Thank you for your help! I am working on cleaning it up.
 

What is Mathematica?

Mathematica is a computational software program used for mathematical, scientific, and engineering calculations. It allows users to enter equations, perform calculations, and visualize results.

How do I input equations of motion in Mathematica?

To input equations of motion in Mathematica, you can use the built-in function "DSolve" or "NDSolve". These functions can handle both ordinary and partial differential equations.

What are the benefits of using Mathematica for equations of motion?

Using Mathematica for equations of motion allows for accurate and efficient calculations, as well as the ability to visualize and manipulate the results. It also has a large library of built-in functions and tools specifically designed for solving differential equations.

Can Mathematica handle complex equations of motion?

Yes, Mathematica can handle complex equations of motion. It has built-in functions for solving both linear and non-linear differential equations, making it a powerful tool for modeling complex systems.

How can I plot the results of my equations of motion in Mathematica?

To plot the results of your equations of motion in Mathematica, you can use the "Plot" function. This function allows you to specify the variables, range, and style of the plot, making it easy to visualize the behavior of your system.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
223
  • Engineering and Comp Sci Homework Help
Replies
1
Views
826
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • Introductory Physics Homework Help
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
4K
Back
Top