Mathematica Troubleshooting Mathematica Pendulum Equation: Finding Solutions with NDSolve

AI Thread Summary
The discussion revolves around troubleshooting the equation of motion for a pendulum, specifically addressing issues with the NDSolve function in Mathematica. The original equation includes variables θ2 and θ2'2 as unknowns, but the solver encounters difficulties, particularly with step limits when attempting to find a solution. By reducing the accuracy and precision goals, the solver can produce results, albeit not ideal. The user shares a modified version of the NDSolve command that successfully generates solutions, which can be visualized using ListPlot. However, increasing the accuracy and precision goals leads to complications, such as the introduction of complex components. The discussion emphasizes the importance of adjusting solver parameters to achieve more realistic results and suggests exploring NDSolve options for better control over the solution process.
DannyS
Messages
3
Reaction score
0
I am trying to input the equation of motion for a pendulum:
θ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))

with θ2 and θ2'2 being the only unknowns but I am not getting the results that are needed. Can someone please check if there are any mistakes in my equation.

NDSolve[{20.64*-Cos[
6.3 t] == ((-9.8*(1.61)*
Sin[.52*Sin [6.3 t]]) - (1.61*9.8*
Sin[Sin [6.3 t] - 2 Theta[t]] - (2*
Sin[Sin [6.3 t] -
Theta[t]])*1.61*((Theta'[t])^2 *0.48 + (3.21*
Cos[6.3 t])^2*.3*Cos[.52*Sin [6.3 t]] -
Theta[t])/(.30 (1.61 -
1.61*Cos[2*.52*Sin [6.3 t] - 2*Theta[t]])))),
Theta[0] == 10000}, Theta[t], {t, 0, 10}]

Thanks!
 
Physics news on Phys.org
It appears, at least with the version I am running, that the solver is running into limits on the number of steps to take trying to find a solution before it finishes.

By reducing the accuracy and precision demands greatly it is possible to get it to solve.

In[1]:= s=NDSolve[{20.64*-Cos[6.3 t]==((-9.8*(1.61)*Sin[.52*Sin[6.3 t]])-(1.61*9.8*Sin[Sin[6.3 t]-2 Theta[t]]-(2*Sin[Sin[6.3 t]-Theta[t]])*1.61*((Theta'[t])^2*0.48+(3.21*Cos[6.3 t])^2*.3*Cos[.52*Sin[6.3 t]]-Theta[t])/(.30 (1.61-1.61*Cos[2*.52*Sin[6.3 t]-2*Theta[t]])))),Theta[0]==10000},Theta[t],{t,0,10},
AccuracyGoal->1,PrecisionGoal->1]

Out[1]= {{Theta[t]->InterpolatingFunction[{{0.,10.}},<>][t]},{Theta[t]->InterpolatingFunction[{{0.,10.}},<>][t]}}

This should then show you one of the solutions:

In[2]:= ListPlot[Table[{j,First[First]/.t->j},{j,0,10,.1}]/.->[_,v_]->v]

And this should then show you the other solution.

In[3]:= ListPlot[Table[{j,First[Last]/.t->j},{j,0,10,.1}]/.Rule[_,v_]->v]

If you GENTLY increase the AccuracyGoal and PrecisionGoal you should start to see it produce something more like what the real solutions are, but by the time I get up to 4 I start getting complaints about a complex component being introduced, although the plot does start to look a little bit like a sine wave oscillating around 9993.

I used the ListPlot to look at these because my first few attempts at getting anything sensible to Plot directly from the InterpolatingFunction failed. You can bump down the step size in that ListPlot and see a little more detail.

Take a look at the results from the ListPlot s and see if this is anything like what your real system should be doing. If it is then this may be moving in the direction of getting you something useful. If so then you might look at Options[NDSolve] and use the help system to take a look at what each of those options do. Those will be used, in a way similar to how I used AccuracyGoal, to control the solver and get it to find a way to deliver the solution you desire.
 

Similar threads

Replies
2
Views
4K
Replies
1
Views
2K
Replies
4
Views
1K
Replies
11
Views
2K
Replies
4
Views
3K
Replies
2
Views
3K
Back
Top