Integrating 2nd order ODE using midpoint rule

In summary, Niles is seeking help with integrating Newton's equations for his system. He is currently using an Euler method but wants to improve the error by implementing a 2nd order Runge-Kutta method. He is unsure about the equation he needs to use for this method and is looking for guidance. He has been provided with a resource explaining the concept of Runge-Kutta methods and is seeking further clarification.
  • #1
Niles
1,866
0
Hi

I am trying to integrate Newtons equations for my system
[tex]
a = \frac{F}{m} = \frac{d^2x}{dt^2}
[/tex]
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
[tex]
F=F(v_x, y, z)
[/tex]
Now, I wish to solve this equation, and I have currently implemented an Euler method. This is how I iterate
[tex]
v_{n+1} = v_n + dt\cdot a(v_{x,n},y_n,z_n) \\
x_{n+1} = x_{n} + dt\cdot v_{n}
[/tex]
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
[tex]
y_{n+1} = y_{n} + dt\cdot f(x_n + dt/2, y_n + k_1/2)
[/tex]
where
[tex]
k_1 = dt\cdot f(x_n, y_n).
[/tex]
This is where my confusion arises: What does [itex]f(x_n + dt/2, y_n + k_1/2)[/itex] correspond to for me?

I would really appreciate a hint or two with this.


Niles.
 
Physics news on Phys.org
  • #2
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"
 
  • #3
Thanks!
 

Related to Integrating 2nd order ODE using midpoint rule

1. How does the midpoint rule work for integrating 2nd order ODEs?

The midpoint rule is a numerical method used to approximate the solution of a second-order ordinary differential equation (ODE). It involves dividing the interval of integration into smaller subintervals and using the midpoint of each subinterval to approximate the value of the function at that point. This approximation is then used to calculate the integral using the trapezoidal rule.

2. What are the benefits of using the midpoint rule for integrating 2nd order ODEs?

The midpoint rule is relatively easy to implement and requires only basic knowledge of calculus. It also provides a more accurate approximation compared to other numerical methods, such as Euler's method, and can handle a wide range of ODEs. Additionally, the midpoint rule is more stable and less prone to error compared to other methods.

3. Can the midpoint rule be used for all types of 2nd order ODEs?

No, the midpoint rule is best suited for ODEs with a smooth solution. This means that the function being integrated should be continuous and have a continuous second derivative. It may not provide accurate results for ODEs with discontinuities or singularities.

4. How can the accuracy of the midpoint rule be improved?

The accuracy of the midpoint rule can be improved by using smaller subintervals and increasing the number of iterations. This will result in a more accurate approximation of the integral. Additionally, using a higher-order midpoint rule, such as Simpson's rule, can also improve accuracy.

5. Are there any limitations to using the midpoint rule for integrating 2nd order ODEs?

One limitation of the midpoint rule is that it can only handle ODEs with a known initial condition. It also requires the function to be evaluated at the midpoint of each subinterval, which can be time-consuming for complex ODEs. Additionally, the midpoint rule may not provide accurate results for ODEs with rapidly changing solutions or for functions that have a large number of oscillations.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • Differential Equations
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Advanced Physics Homework Help
Replies
5
Views
1K
  • Linear and Abstract Algebra
Replies
13
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
625
Replies
16
Views
3K
Replies
18
Views
2K
Replies
3
Views
892
  • Calculus and Beyond Homework Help
Replies
11
Views
2K
Back
Top