Classical mechanics & runge-kutta

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
gulsen
Messages
215
Reaction score
0
We have a pendullum in a car, that is being pulled with:
a) constant F force
b) connectec to a spring, with force F = -kx

The physics part is done, and we have 2 differential equations (non-lineer), and we're supposed to write a C program to calculate theta(t) and x(t) from them. We should solve them with Rugne-Kutta. Here they are:

[tex](M+m)x'' + mL\theta''cos(\theta) - mL(\theta')^2 sin(\theta) - F = 0[/tex]
[tex]mL^2\theta'' + mLx''cos(\theta) + mgLsin(\theta) = 0[/tex]

The problem is, we've learned how to solve
[tex]f'' + p(t)f' + q(t)f + r(t) = 0[/tex]

but these equations have two independent variables. Now, what's the path to follow?

(note: yes, these two equations are confirmed to be enough to get values for x(t) and theta(t))
 
Physics news on Phys.org
Numerical recipies in C is online now:

http://www.library.cornell.edu/nr/bookcpdf.html

The general approach is to convert your system of second order differential equations into a system of linear first order differential equations.

See for example

http://www.library.cornell.edu/nr/bookcpdf/c16-0.pdf

and later chapters.
 
Last edited by a moderator:
I actually solved the simple pendulum this way in high school. What you need to do is use an RK4 to get [tex]\theta '[/tex] and [tex]x'[/tex] from the second order equations, and then use the same RK4 to do a simple time integral of that velocity ([tex]dx = vdt[/tex]). At least, that's how I would do it.