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[itex]\pi[/itex] and step sizes of h.
Find diff eq, such that y'=f(t,y)
yn+1= yn + h/6*(k1 + 2*k2 + 2*k3 + k4)
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).
Now I solved for x with the following:
xn+1 = xn + 1/6*(k1 + 2*k2 + 2*k3 + k4)
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.