Similar idea in this thread.
I have a simple pendulum that has equation:
My problem is that the examples I have come across in textbooks all refer the differential equation only on its first order, so what if I have a second order?
How should I implement it in runge kutta's method?
Thanks
It's not exactly called "reduction of order", even though it does reduce the order. "Reduction of order" is a different technique.
What you do here is define a vector solution to the problem:
Let and let
Then the differential equation becomes the system
In this manner, I believe you can transform any nth degree ODE into a system of n first-order ODE's. Make sense?
No, you don't have to do that. I don't even think that would be a solution. No, instead, what you do is vectorize everything. If you look here, you will see the RK4 formulas.So do I have to use the Runge Kutta twice for both first order differential equation?
Now, in those formulas, there's nothing that says that the the , and the can't be vectors. You would still have be a scalar, because it's an increment in the independent variable. So, just to make everything explicit, let me write out the vector version of RK4 (vectors are in bold, scalars not in bold):
Given the ODE system
the RK4 method for this problem is given by
where is the RK4 approximation of and
If you examine these equations carefully, you'll see that all the multiplications are defined: scalar multiplication of a vector. That plus function evaluations gives you everything you need. Don't forget that your ODE/function evaluation is
Does that make things clearer?