converting ODE from maple to python -
how convert following code written in maple python framework
ode:=diff(y(x),x)= #=an equation sol:=dsolve([ode, y(1)=0.73}, numeric, output=listprocedure) fy:=eval(y(x),sol);nn:=100 x 1 nn fy(5.1*x/nn) end do;
i not find code similar above program. thank help
it possible have maple convert code python command codegeneration:-python
. write code procedure , convert it. problem, if try run trouble of maple not recognizing e.g. dsolve
in python , verbatim copy function calls python. is, not sure possible have maple automatically it.
here unsuccessful attempt, disregarding for
loop troubling because
myproc := proc(ode,ic) local sol,fy,out,i,nn; sol := dsolve({ode,ic},numeric,output=listprocedure); nn := 100; fy := eval(y(x),sol); out := []; nn do; out := [op(out),fy(5.1*i/nn)]; end do; out; end proc: ## example of use: ## myproc(diff(y(x),x) = 1/x,y(1) = 0.73); ## convert python codegeneration:-python(myproc);
warning, function names {dsolve, eval, y} not recognized in target language #def myproc (ode, ic): # sol = dsolve(set([ode,ic]), numeric, output == listprocedure) # nn = 100 # fy = eval(y(x), sol) # out = [] # in range(1, nn + 1): # out = [tuple(out),fy(0.51e1 * / nn)] # return(out)
Comments
Post a Comment