Program to solve coupled ODEs?

  • Context: Graduate 
  • Thread starter Thread starter tomdodd4598
  • Start date Start date
  • Tags Tags
    Coupled Odes Program
Click For Summary

Discussion Overview

The discussion revolves around the numerical solution of coupled second-order non-linear ordinary differential equations (ODEs) related to a double pendulum system, as explored through Lagrangian mechanics. Participants share experiences and seek advice on software tools, specifically Mathematica, for solving these equations.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their attempt to create a Lagrangian for a double pendulum and the resulting coupled ODEs they encountered.
  • Multiple participants suggest Mathematica as a potential tool for solving these equations.
  • A participant inquires about the best version of Mathematica for their needs, expressing uncertainty about the differences between versions.
  • Another participant notes that the main differences in Mathematica versions are price-related, particularly for student and educator licenses.
  • A participant shares their experience of using a friend's Mathematica setup and encounters an error related to bracket usage in their input.
  • Some participants suggest that the error may be due to improper use of brackets and recommend checking the input syntax.
  • One participant mentions that their solution works for a limited time frame, suggesting potential issues with the complexity of the equations.
  • Another participant proposes testing the solution with a small angle approximation to compare numerical results with exact solutions.

Areas of Agreement / Disagreement

Participants generally agree on the utility of Mathematica for solving the coupled ODEs, but there is no consensus on the specific issues encountered with the software or the best approach to validate the solutions.

Contextual Notes

Participants express uncertainty regarding the limitations of their numerical solutions, particularly in relation to the complexity of the equations and the accuracy over time.

tomdodd4598
Messages
137
Reaction score
13
Hi there,

I have been using Leonard Susskind's lectures on classical mechanics to learn about Lagrangians and Hamiltonians, and decided to try to create a Lagrangian for the double pendulum and another pendulum-related system. I found the equations of motion, but they were unlike any differential equations I had ever seen before. I found out that, for each system, I had a pair of coupled second-order non-linear ODEs.

I have had no luck trying to find a program which can numerically solve these coupled ODEs. If anyone knows of such a program, I would love to know about it.

Thanks in advance
 
Physics news on Phys.org
Mathematica
 
brainpushups said:
Mathematica
I thought of Mathematica, but I wasn't aware it could solve problems such as this - thanks. As someone who is looking to get Mathematica anyway, which version should I go for? I will want to be able to solve problems such as this, but I am not sure which type of Mathematica is the cheapest that can.
 
I don't think there is an actual difference between any of the versions (except the price - student and educator licenses are significantly less than the professional license if I recall...). If you are interested in purchasing a license I would just contact their customer service directly to talk about options. I've been quite happy with their service.
 
brainpushups said:
I don't think there is an actual difference between any of the versions (except the price - student and educator licenses are significantly less than the professional license if I recall...). If you are interested in purchasing a license I would just contact their customer service directly to talk about options. I've been quite happy with their service.

Turns out that a friend that lives close by has had it for ages... I'm now using his computer via TeamViewer :P

I inputted the following, long expression, asking the program to solve the two equations:
EDIT: All of the sines and cosines are capitalised contrary to what's pasted in the spoiler.
s = NDSolve[{θ''[t] + φ'[t]*sin[φ[t]]*[cos[θ[t]]*cos[t] + sin[θ[t]]*sin[t]] + cos[φ[t]]*[θ'[t]*sin[θ[t]]*cos[t] + cos[θ[t]]*sin[t] - θ'[t]*cos[θ[t]]*sin[t] - sin[θ[t]]*cos[t]] == [φ'[t]*sin[φ[t]]*[cos[θ[t]]*cos[t] + sin[θ[t]]*sin[t]] - θ'[t]*cos[φ[t]]*[cos[θ[t]]*sin[t] - sin[θ[t]]*cos[t]]] + [φ'[t]^2]*cos[θ[t]]*sin[θ[t]] - 9.81*sin[θ[t]], φ'[t]*cos[φ[t]]*[sin[θ[t]]*cos[t] - cos[θ[t]]*sin[t]] + sin[φ[t]]*[θ'[t]*cos[θ[t]]*cos[t] - sin[θ[t]]*sin[t] + θ'[t]*sin[θ[t]]*sin[t] - cos[θ[t]]*cos[t]] + φ''[t]*[[sin[θ[t]]]^2] + 2*θ'[t]*φ'[t]*sin[θ[t]]*cos[θ[t]] == [[φ'[t]^2]*cos[φ[t]]*[sin[θ[t]]*cos[t] - cos[θ[t]]*sin[t]] + θ'[t]*φ'[t]*sin[φ[t]]*[cos[θ[t]]*cos[t] + sin[θ[t]]*sin[t]]], θ[0] == θ'[0] == φ[0] == φ'[0] == 0}, {θ, φ}, {t, 100}]
Plot[Evaluate[{θ[t], φ[t]} /. s], {t, 0, 100}, PlotStyle -> Automatic]

But I got the following error:
Syntax::sntxf: "φ'[t]*Sin[φ[t]]*" cannot be followed by "[Cos[θ[t]]*Cos[t]+Sin[θ[t]]*Sin[t]]".

Should I go to the Mathematica forums for this or is it something simple that I'm doing wrong?
 
Last edited:
Looks like it might be your use of brackets. If you are grouping for multiplication you must use parentheses.
 
brainpushups said:
Looks like it might be your use of brackets. If you are grouping for multiplication you must use parentheses.
Thank you! It's working now - sort of. It can only be solved accurately for 1.6 seconds... possibly just due to the equations' complexity.
4oBvGEk.png

Time t is on the x-axis, angle is on the y-axis, blue is θ, orange is φ, θ(0) = φ(0) = Pi/2, θ'(0) = φ'(0) = 0
 
Hmm. I don't think there should be an issue with these particular coupled equations. I think I've used Mathematica in the past to do this same thing. Have you tried plotting the solution for a small angle where the small angle approximation would hold? You could compare the numerical solution to the exact solution in that case to make sure they match. When I have a chance today I'll try it myself - don't hold your breath though; its going to be a busy day and then I have company for the weekend.
 

Similar threads

  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
3K