Integrating 2nd order ODE using midpoint rule

AI Thread Summary
The discussion focuses on integrating Newton's equations of motion for a particle in a three-dimensional space, specifically starting with the x-coordinate. The user is currently using an Euler method for numerical integration but seeks to improve accuracy by implementing a second-order Runge-Kutta method. The user expresses confusion about how to apply the midpoint rule in this context, particularly regarding the function f and its parameters. A resource is provided to clarify the Runge-Kutta method, directing attention to a specific page that discusses finite difference methods and their application. The conversation emphasizes the transition from a basic numerical method to a more sophisticated one to enhance precision in solving differential equations related to motion.
Niles
Messages
1,834
Reaction score
0
Hi

I am trying to integrate Newtons equations for my system
<br /> a = \frac{F}{m} = \frac{d^2x}{dt^2}<br />
This is only for the first coordinate of the particle. I wish to do it for y and z as well, but let us just work with x for now to make it simple.

The force in the x-direction depends on the velocity in the x-direction, vx, and the y- and z-coordinate. In other words
<br /> F=F(v_x, y, z)<br />
Now, I wish to solve this equation, and I have currently implemented an Euler method. This is how I iterate
<br /> v_{n+1} = v_n + dt\cdot a(v_{x,n},y_n,z_n) \\<br /> x_{n+1} = x_{n} + dt\cdot v_{n}<br />
I now want to improve the error, and use a 2nd order Runge-Kutta method, i.e. the midpoint rule as briefly summarized here: http://www.efunda.com/math/num_ode/num_ode.cfm

I am not quite sure how to do this. In the link they say that now I should generally write
<br /> y_{n+1} = y_{n} + dt\cdot f(x_n + dt/2, y_n + k_1/2)<br />
where
<br /> k_1 = dt\cdot f(x_n, y_n).<br />
This is where my confusion arises: What does f(x_n + dt/2, y_n + k_1/2) correspond to for me?

I would really appreciate a hint or two with this.


Niles.
 
Physics news on Phys.org
Here you have it explained:
http://www.phy.pmf.unizg.hr/~npaar/teaching/compphys.pdf

page 292, "13.4 More on finite difference methods, Runge-Kutta methods"
 
Thanks!
 

Similar threads

Back
Top