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!

Homework Help: Solving second-order ODE with Runge-Kutta 4

  1. Apr 22, 2013 #1
    1. The problem statement, all variables and given/known data
    Note: I think there is a typo here but I'm not sure. Is there supposed to be a comma between the delta t/2 and y_n on K2 and K3, and delta t and y_n on K4?

    2. Relevant equations
    See above.

    3. The attempt at a solution
    Substituting dy/t = z gives
    [itex]\frac{dz}{dt} = 3z - 2ty - cos(t)

    \frac{dy}{dt} = z[/itex]

    I'm not sure where to go from here. I can find K_1, but I'm not sure how to find K_2z as it depends on t, y, and z. What do I choose for z in K2? Do I need to redefine K_2 as

    [itex] f \left ( t_n + \frac{\Delta t}{2}, y_n + \frac{K_1_y}{2}, z_n + \frac{k_1_z}{2} \right )[/itex] Is there some other way I should approach the problem?

    Any help is appreciated, thanks.
  2. jcsd
  3. Apr 23, 2013 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    In K1, there should be a comma between tn and yn.

    In K2, K3, and K4, there should be commas between the delta t terms and the yn terms.

    Remember z = dy/dt, and you are given dy/dt = 0 at t = 0.
  4. Apr 23, 2013 #3
    This is aimed towards SteamKing, K1 is found with dy/dt=0, but how is K2 solved when f(0.05,1) is undefined by the question and there is no obvious way to determine the f(0.05,1).

  5. Apr 23, 2013 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    You are incrementing t between calculating K1 and K2, which is not what is called for in the definition of K1 ... K4. For K2, you use the same values for yn and t as for K1. Once you have calculated K2, you use this value to calculate K3, and you use K3 to calculate K4. Once you have calculated K1 ... K4, then you increment t by delta t and determine y(n+1).
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted