Ask Your Question

Andy's profile - activity

2014-02-06 08:10:01 +0200 received badge  Student (source)
2014-02-05 14:47:15 +0200 asked a question 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?

2012-09-04 15:55:43 +0200 asked a question Similar limits give very different behavior

The following code produces the expected right answer:

sage: var('x,h')
sage: f(x) = sin(x^2)
sage: lim((f(x+h)-f(x))/h, h=0)

The answer, of course, is 2xcos(x^2). However, the following code fails to complete:

sage: lim((f(pi+h)-f(pi))/h, h=0)

Sage just thinks and thinks and does not come up with an answer. This happens on two different versions I have access to, 5.2 and 5.0. What is happening?