Hi,(adsbygoogle = window.adsbygoogle || []).push({});

I'm trying to solve an initial-value ODE using RK4, say dx/dt = f(x,t), x(0) = x0. I want to find t_end so that x(t_end) = 0.

The basic RK4 implementation works fine, however I'm having some difficulties with stopping it in time. I've tried googling around but all I could find was references to matlab or similar, which doesn't say anything about how the zero crossing is detected and handled.

The immediate way I can think of is to check after each integration step if x(t) has crossed, and if so restart the step using say half the step length, repeating until it no longer crosses, x(t) = 0 or the step length is below some minimum. Is this an acceptable solution? Are there some better ways?

Cheers!

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Stopping ODE solver on zero crossing

Loading...

Similar Threads - Stopping solver zero | Date |
---|---|

A Finite Difference solver for 2D Elasticity equations | Mar 17, 2016 |

Matrix-free iteration methods and implicit ODE solvers | Oct 16, 2015 |

N body solver (is this right?) | Sep 9, 2014 |

Dont know how to write PDE of semiconductors in Matlab (PDE solver) | Mar 24, 2012 |

Initial speed of object sliding to a stop w/ air resistance | Sep 3, 2010 |

**Physics Forums - The Fusion of Science and Community**