Results 1 to 6 of 6

Math Help - Solving Second Order Differential Equations using Runge Kutta

  1. #1
    Newbie
    Joined
    Dec 2010
    Posts
    3

    Solving Second Order Differential Equations using Runge Kutta

    1. The problem statement, all variables and given/known data
    In aerodynamics, one encounters the following initial value problem for Airy’s equations:

    y''(x) + xy = 0, y(0) = 1, y'(0) = 0

    Using the Runge-Kutta method with h=0.005 and determine values between x=0 and x=10 sufficient to sketch the relationship.



    2. Relevant equations
    y''(x) + xy = 0, y(0) = 1, y'(0) = 0
    I think,
    k1 = h*f(Xn, Yn)
    k2 = h*f(Xn+h/2, Yn+k1/2)
    k3 = h*f(Xn+h/2, Yn+k2/2)
    k4 = h*f(Xn + h, Yn + k3)

    3. The attempt at a solution
    From what I have read you cant do second order ODE using runge kutta without breaking it into a system of first order ODEs so thats what I tried.

    I tried:
    d2y/dx2 + xy = 0

    dy/dx = z, y(0) = 1

    dz/dx + xy = 0

    dz/dx = -xy, z(0) = 0

    I dont know if that is right or not and if it is I have no idea where to go from here.

    Thanks for any help.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    2
    There's nothing wrong with your change to a system. It'll work fine. You now need to figure out, in the RK4 method, what quantities are vectors and what quantities are scalars, and what's what.

    What is your f?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2010
    Posts
    3
    I am doing this all in MATLAB, This is what I have come up with but I am not sure if this is correct or not.

    Attached are my MATLAB code, a Graph of the results, and an excel sheet of all results.
    the matlab code can be opened in notepad.

    Thanks for any help.
    MEA Proj.zip
    Follow Math Help Forum on Facebook and Google+

  4. #4
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    2
    Hmm. Well, I'm not a MATLAB expert, by any means. Captain Black (CB) is one of the best on the MHF for that. So we could either ask CB to look at the problem, or you could translate your code into mathematical equations. Your choice.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2010
    Posts
    3
    All the code does is loop through these equations for each value of X.

    x_{n+1}\equiv x_n+h

    z_{n+1,1}\equiv z_{n,1}+\frac{1}{6}\left(k_{1,1}+2k_{2,1}+2k_{3,1}  +k_{4,1}\right)

    z_{n+1,2}\equiv z_{n,2}+\frac{1}{6}\left(k_{1,2}+2k_{2,2}+2k_{3,2}  +k_{4,2}\right)

    where:

    k_{1,1}\equiv hz_{n,2}

    k_{1,2}\equiv -hx_nz_{n,1}

    k_{2,1}\equiv h\left(z_{n,2}+\frac{1}{2}k_{1,2}\right)

    k_{2,2}\equiv -h\left(x_n+\frac{h}{2}\right)\left(z_{n,1}+\frac{1  }{2}k_{1,2}\right)

    k_{3,1}\equiv h\left(z_{n,2}+\frac{1}{2}k_{2,2}\right)

    k_{3,2}\equiv -h\left(x_n+\frac{h}{2}\right)\left(z_{n,1}+\frac{1  }{2}k_{2,2}\right)

    k_{4,1}\equiv h\left(z_{n,2}+k_{3,2}\right)

    k_{4,2}\equiv -h\left(x_n+h\right)\left(z_{n,1}+k_{3,2}\right)
    Follow Math Help Forum on Facebook and Google+

  6. #6
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    5
    Awards
    2
    Ok, from what you've typed, I see three problems (or one problem, depending on how you look at it). You should have this:

    k_{2,2}\equiv -h\left(x_n+\frac{h}{2}\right)\left(z_{n,1}+\frac{1  }{2}k_{1,1}\right) and

    k_{3,2}\equiv -h\left(x_n+\frac{h}{2}\right)\left(z_{n,1}+\frac{1  }{2}k_{2,1}\right) and

    k_{4,2}\equiv -h\left(x_n+h\right)\left(z_{n,1}+k_{3,1}\right),

    instead of what you have. The only difference is that I'm taking the second component of k at the far right of each equation. You did this correctly for k_{1,1} and k_{1,2}, but not for the rest.

    Everything else looks good to me.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 0
    Last Post: July 20th 2011, 04:04 PM
  2. Runge Kutta - Second order differential again.
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: January 13th 2010, 07:41 AM
  3. Runge Kutta on second order differential
    Posted in the Differential Equations Forum
    Replies: 5
    Last Post: January 12th 2010, 08:55 AM
  4. Replies: 0
    Last Post: August 6th 2009, 06:51 AM
  5. Runge-Kutta of Order 4
    Posted in the Advanced Applied Math Forum
    Replies: 8
    Last Post: March 10th 2009, 01:53 PM

Search Tags


/mathhelpforum @mathhelpforum