Solutions to desolve_odeint seem large

asked 2023-06-23 04:35:56 +0100

Jack Zuffante gravatar image

updated 2023-06-23 09:38:53 +0100

Emmanuel Charpentier gravatar image

I'm trying to figure out what, if anything, is going wrong with this code here. It says in the SageMath documentation that for desolve_odeint, the order of dvars must be the same as that of des. In my case, that means dp/dt=dp, dth/dt=dth, d(dp)/t=g, and d(dth)/t=h. But it's spitting out values that are much larger than what I would expect for t-values between 0 and 10.

t,p,th,dp,dth=var('t,p,th,dp,dth')
g=5*p*dth^2+4*t*dth^2*dp
h=-4*t/(5*p^2+4*t^2)*dth-5*p/(5*p^2+4*t^2)*dp*dth+4*t*dth^3
f=[dp,dth,g,h]
sol=desolve_odeint(f,[5,0,1,1],srange(0,10),[p,th,dp,dth],ivar=t)
sol[2]
edit retag flag offensive close merge delete

Comments

Edited for legibility. Indent your code fragmants by four spaces (or use the 101010 button)...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-06-23 09:39:52 +0100 )edit

Replace srange(0,10) by srange(0,10,0.01)

achrzesz gravatar imageachrzesz ( 2023-06-23 17:30:30 +0100 )edit

Thank you, this works. I guess it was mistaking 10 for the step size or something.

Jack Zuffante gravatar imageJack Zuffante ( 2023-06-23 23:40:53 +0100 )edit