Ask Your Question

implicitnone's profile - activity

2023-06-14 08:32:48 +0100 received badge  Notable Question (source)
2020-11-06 11:12:34 +0100 received badge  Popular Question (source)
2017-01-07 15:04:17 +0100 received badge  Supporter (source)
2017-01-07 15:04:11 +0100 commented answer Function dependence flexibility

Thank you, that works!

2017-01-07 14:23:01 +0100 received badge  Student (source)
2017-01-07 09:15:17 +0100 asked a question Function dependence flexibility

I'd like to declare an unknown function f. If I had one variable x, I would write

f=function('f')(x)

Instead, I would like to declare this function with a variable list (or tuple) that has unknown length at the beginning of the program. For example,

f=function('f')(x,y)

has two variables or

f=function('f')(x,y,t)

has three.

I can get a list (or tuple) containing my variables just before the function declaration:

vars=[x,y,z,t]

Then how can I declare my function like

f=function('f')(vars)

?

2017-01-07 07:52:19 +0100 commented answer desolve_system_rk4 vs desolve_odeint

Thank you Paul. It is a more serious issue than I thought. I will try to reformulate my physical problem.

2017-01-06 20:23:29 +0100 received badge  Editor (source)
2017-01-06 14:44:59 +0100 asked a question desolve_system_rk4 vs desolve_odeint

I am getting different results (a result vs no result) from desolve_system_rk4 and desolve_odeint for the same system. What am I missing? My code is the following:

reset()
from sage.calculus.desolvers import desolve_system_rk4,desolve_odeint
var('eta,r,ph');

drdt=-sqrt(2.0*r + 200.0 / r - 100.0)*(r - 2.0) / (r^2)
dphdt=10.0*(r - 2.0) / (r^3)

sol1=desolve_system_rk4([drdt,dphdt],[r,ph],ics=[0,4.0,0.3],ivar=eta,end_points=1000,step=0.01)
sol2=desolve_odeint([drdt,dphdt],[4.0,0.3],srange(0,1000,0.01),[r,ph])

D=[[j*cos(k),j*sin(k)] for i,j,k in sol1]

p1=list_plot(D,aspect_ratio=1)    
p2=line(zip(sol2[:,0]*cos(sol2[:,1]),sol2[:,0]*sin(sol2[:,1])))

show(graphics_array([p1,p2]))