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

Click For Summary
The discussion focuses on applying the Runge-Kutta 4th order (RK4) method to solve the second-order differential equation x'' + b^2*x = 0 by converting it into a system of first-order equations. The user successfully substitutes x' with v, resulting in two coupled first-order equations: v' = -b^2*x and x' = v. Initial conditions are provided as x(0) = 0 and x'(0) = 0, allowing for the use of RK4 to compute values for both x and v. The key insight is that both equations must be solved simultaneously, utilizing intermediate solutions to improve accuracy at each time step. The user ultimately confirms their understanding with assistance from another forum member.
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:
Question: A clock's minute hand has length 4 and its hour hand has length 3. What is the distance between the tips at the moment when it is increasing most rapidly?(Putnam Exam Question) Answer: Making assumption that both the hands moves at constant angular velocities, the answer is ## \sqrt{7} .## But don't you think this assumption is somewhat doubtful and wrong?

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