# Revision history [back]

### Looong computation by desolve_rk4

I'm having an issue with very long computation times for numerical solutions to DEs using desolve_rk4. It happens when computing a solution that runs off to +/- infinity. For example, the following command will do it:

t,y = var('t,y')
f(t,y) = 6+y-y^2
desolve_rk4(f(t,y), y, ivar=t, ics=[0,-4], end_points=[0,10], output='plot')


If I make "end_points" run from 0 to something much smaller, like 0.1, everything is okay. But I want some way to fix this behavior so that I can change the initial conditions easily for classroom demos without having to constantly change the endpoints (in an interact, for example). I also don't quite understand why it should be taking so long simply to run to infinity -- this behavior doesn't match my understanding of the RK4 algorithm. (I can understand that we might hit overflow quickly, but I would expect it should simply stop computation at that point.)

Any suggestions?

 2 retagged tmonteil 18968 ●22 ●133 ●351 http://wiki.sagemath.o...

### Looong computation by desolve_rk4

I'm having an issue with very long computation times for numerical solutions to DEs using desolve_rk4. It happens when computing a solution that runs off to +/- infinity. For example, the following command will do it:

t,y = var('t,y')
f(t,y) = 6+y-y^2
desolve_rk4(f(t,y), y, ivar=t, ics=[0,-4], end_points=[0,10], output='plot')


If I make "end_points" run from 0 to something much smaller, like 0.1, everything is okay. But I want some way to fix this behavior so that I can change the initial conditions easily for classroom demos without having to constantly change the endpoints (in an interact, for example). I also don't quite understand why it should be taking so long simply to run to infinity -- this behavior doesn't match my understanding of the RK4 algorithm. (I can understand that we might hit overflow quickly, but I would expect it should simply stop computation at that point.)

Any suggestions?