Results 1 to 6 of 6

Math Help - Solving 2nd ODE with Runge Kutta?

  1. #1
    Newbie
    Joined
    May 2010
    Posts
    13

    Solving 2nd ODE with Runge Kutta?

    I have a simple pendulum that has equation:

    \ddot{\theta} + \omega^2 \sin{\theta} = 0

    My problem is that the examples I have come across in textbooks all refer the differential equation only on its first order, so what if I have a second order?

    How should I implement it in runge kutta's method?

    Thanks
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    Similar idea in this thread.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    May 2010
    Posts
    13
    so I have to reduce the 2nd order to a 1st order, by using reduction of orders technique?

    can you show me how to do it?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    It's not exactly called "reduction of order", even though it does reduce the order. "Reduction of order" is a different technique.

    What you do here is define a vector solution to the problem:

    Let x_{1}(t)=\theta(t), and let

    x_{2}(t)=\theta'(t). Then the differential equation becomes the system

    x_{1}'(t)=x_{2}(t)
    x_{2}'(t)=-\omega^{2}\sin(x_{1}(t)).

    In this manner, I believe you can transform any nth degree ODE into a system of n first-order ODE's. Make sense?
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    May 2010
    Posts
    13
    no sorry, I feel like an idiot. So do I have to use the Runge Kutta twice for both first order differential equation? But How?
    Follow Math Help Forum on Facebook and Google+

  6. #6
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    So do I have to use the Runge Kutta twice for both first order differential equation?
    No, you don't have to do that. I don't even think that would be a solution. No, instead, what you do is vectorize everything. If you look here, you will see the RK4 formulas.

    Now, in those formulas, there's nothing that says that the y_{n+1}, the f, and the y_{n} can't be vectors. You would still have h be a scalar, because it's an increment in the independent variable. So, just to make everything explicit, let me write out the vector version of RK4 (vectors are in bold, scalars not in bold):

    Given the ODE system

    \dot{\mathbf{x}}=\mathbf{f}(t,\mathbf{x}),\quad \mathbf{x}(t_{0})=\mathbf{x}_{0}, the RK4 method for this problem is given by

    \displaystyle \mathbf{x}_{n+1}=\mathbf{x}_{n}+\frac{h}{6}\left(\  mathbf{k}_{1}+2\mathbf{k}_{2}+2\mathbf{k}_{3}+\mat  hbf{k}_{4}\right)

    t_{n+1}=t_{n}+h

    where \mathbf{x}_{n+1} is the RK4 approximation of \mathbf{x}(t_{n+1}), and

    \mathbf{k}_{1}=\mathbf{f}(t_{n},\mathbf{x}_{n})

    \displaystyle \mathbf{k}_{2}=\mathbf{f}\left(t_{n}+\frac{h}{2},\  mathbf{x}_{n}+\frac{h}{2}\,\mathbf{k}_{1}\right)

    \displaystyle \mathbf{k}_{3}=\mathbf{f}\left(t_{n}+\frac{h}{2},\  mathbf{x}_{n}+\frac{h}{2}\,\mathbf{k}_{2}\right)

    \displaystyle \mathbf{k}_{4}=\mathbf{f}\left(t_{n}+h,\mathbf{x}_  {n}+h\,\mathbf{k}_{3}\right).

    If you examine these equations carefully, you'll see that all the multiplications are defined: scalar multiplication of a vector. That plus function evaluations gives you everything you need. Don't forget that your ODE/function evaluation is

    \dot{\mathbf{x}}(t)=\begin{bmatrix}\dot{x}_{1}(t)\  \ \dot{x}_{2}(t)\end{bmatrix}=\mathbf{f}(t,\mathbf{x  })=\begin{bmatrix}x_{2}(t)\\-\omega^{2}\sin(x_{1}(t))\end{bmatrix}.

    Does that make things clearer?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Solving double pendulum with runge kutta
    Posted in the Math Software Forum
    Replies: 0
    Last Post: January 5th 2011, 10:34 PM
  2. Solving Second Order Differential Equations using Runge Kutta
    Posted in the Differential Equations Forum
    Replies: 5
    Last Post: December 22nd 2010, 12:33 PM
  3. Runge Kutta
    Posted in the Math Software Forum
    Replies: 5
    Last Post: November 10th 2010, 02:24 PM
  4. Runge-Kutta
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: May 22nd 2008, 08:54 PM
  5. Runge Kutta
    Posted in the Calculus Forum
    Replies: 0
    Last Post: January 23rd 2008, 11:11 PM

Search Tags


/mathhelpforum @mathhelpforum