1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Classical mechanics & runge-kutta

  1. Jan 29, 2006 #1
    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))
  2. jcsd
  3. Jan 30, 2006 #2


    User Avatar
    Staff Emeritus
    Science Advisor

    Numerical recipies in C is online now:

    http://www.library.cornell.edu/nr/bookcpdf.html [Broken]

    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 [Broken]

    and later chapters.
    Last edited by a moderator: May 2, 2017
  4. Jan 30, 2006 #3
    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, thats how I would do it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook