Runge-Kutta 4th order method (RK4) for second order Diff Eq

Click For Summary
SUMMARY

The discussion focuses on applying the Runge-Kutta 4th order method (RK4) to solve the second-order differential equation x'' + b²*x = 0. The user initially struggles with converting the second-order equation into a system of first-order equations suitable for RK4. The correct approach involves substituting x' = v, leading to two coupled first-order equations. The final solution requires simultaneous updates of both x and v using RK4, leveraging intermediate values to improve accuracy.

PREREQUISITES
  • Understanding of second-order differential equations
  • Familiarity with the Runge-Kutta 4th order method
  • Knowledge of numerical methods for solving differential equations
  • Basic concepts of initial conditions in differential equations
NEXT STEPS
  • Implement the RK4 method for coupled first-order differential equations
  • Explore numerical stability and error analysis in RK4
  • Learn about alternative numerical methods for solving differential equations, such as the Adams-Bashforth method
  • Study the application of RK4 in physical systems, particularly in mechanics
USEFUL FOR

Students and professionals in mathematics, physics, and engineering who are working with differential equations and numerical methods for simulations and modeling.

Helmholtz
Messages
19
Reaction score
0

Homework Statement



Hello, maybe this is due to my lack of understand of RK4, but I have an equation: x'' + b^2*x=0 (derivatives with respect to variable t) and I need to use RK4 to find the solution on an interval. I can readily find solutions analytically, but my understanding of RK4 is that I need the problem in a first order diff eq, which I do not accomplish when I use characteristic equations. Initial conditions are x(t)=0 and x'(0)=0. The intervals is 0 to 4\pi and step sizes of h.

Homework Equations


Find diff eq, such that y'=f(t,y)

RK4 equations:
yn+1= yn + h/6*(k1 + 2*k2 + 2*k3 + k4)

k1=f(tn,yn)

k2=f(tn+h/2,yn+k1*h/2)

k3=f(tn+h/2,yn+k2*h/2)

k4=f(tn+h,yn+k3*h)


The Attempt at a Solution



My attempt to break the problem to first order is a substitution with x'=v

And it follows that that: v'= -b^2*x = f(t,x).

Now I have two first order differential equations. I can use RK4 to get values for v and x, but it seems like my values of v depend on x and vice verse? Here is what I have so far, but it is coupled so I think it's wrong.

First I solved for the higher ordered one, aka v. So:

vn+1 = vn + 1/6*(l1 + 2*l2 + 2*l3 +l4).

Where:

l1= -b^2*xn*h
l2= -b^2*xn*h*(1+h/2)
l3= -b^2*xn*h*(1+h/2+h2/4)
l4= -b^2*xn*h*(1+h/2+h2/2+h3/4)

Now I solved for x with the following:

xn+1 = xn + 1/6*(k1 + 2*k2 + 2*k3 + k4)

Where:
k1= vn*h
k2= vn*h*(1+h/2)
k3= vn*h*(1+h/2+h2/4)
k4= vn*h*(1+h/2+h2/2+h3/4)

Is this right? Since I have initial conditions I think I can build this up to the full solution since I know v0 and x0.
 
Last edited:
Physics news on Phys.org
Sorry to say, but you got it all wrong! The point is to solve both equations at the same time, and use the intermediate solutions to get a better guess for the next intermediate solution, and when you have all 4 of them you take an "average" to actually advance one time step.

Check this thread for more details:
https://www.physicsforums.com/showthread.php?t=671526
 
I have figured it out, thanks DrClaude.
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 6 ·
Replies
6
Views
51K
  • · Replies 36 ·
2
Replies
36
Views
6K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 65 ·
3
Replies
65
Views
8K