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: 4th order RK to solve 2nd order ODE

  1. Dec 2, 2016 #1
    1. The problem statement, all variables and given/known data
    Consider the initial value problem x" + x′ t+ 3x = t; x(0) = 1, x′(0) = 2 Convert this problem to a system of two first order equations and determine approximate values of the solution at t=0.5 and t=1.0 using the 4th Order Runge-Kutta Method with h=0.1.
    2. Relevant equations
    yn+1 = yn + 1/6 ( k1 + 2k2 + 2k3 + k4)
    k1 = h* f(xn, yn)
    k2 = h* f(xn + 1/2 h, yn + 1/2 k1)
    k3 = h* f(xn + 1/2 h, yn + 1/2 k2)
    k4 = h* f(xn+1, yn+k3)
    3. The attempt at a solution
    I tried to convert the equation into two linear ODEs:

    x = x1
    x′= x1' = x2
    x′′= x1'' = x2'

    x2' = -x2 t + t - 3x1 (first linear ODE)
    x1' = x2 (second linear ODE)

    I do not know what to do from here.
    From 4th Order RK equations, I do not know what f(xn, yn) is.
    Last edited by a moderator: Dec 2, 2016
  2. jcsd
  3. Dec 2, 2016 #2
    The Runge-Kutta method give the solution to the differential equation:

    This can also be generalized to several equations by allowing ##x(t)## and ##f(x,t)## being vectors, i.e. ##x=(x_1,x_2,...,x_n)## and ##f=(f_1,f_2,...,f_n)##. So, in your case ##f=(f_1,f_2)## is a two-dimensional array containing the right-hand side of each equation.

    By the way, I recommend that you use Latex to write your equations. In your post it is difficult to read them.
  4. Dec 2, 2016 #3

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    for a detailed explanation plus worked example.

    BTW: I do not agree that your work is difficult to read; in fact, it reads surprisingly well and looks quite good. However, post #2 is correct in suggesting the use of LaTeX; you would find it much easier and faster than constantly using the [ S U B] ... [/ S U B] construction, and it wold look even better than what you have already.
  5. Dec 2, 2016 #4


    User Avatar
    Homework Helper
    Gold Member

    Some of the ' need to be outside of the [ SUB] ' [/SUB]
  6. Dec 2, 2016 #5


    Staff: Mentor

    I moved them, so it should be OK now.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted