Hi Everybody,
Suppose I have this procedure assign to p:
>p:=MyProc(args1,args2,args3,h) statement end proc:
where h is the step size.
args1 = {ode,ic} , args2 = x(t) et args3 = t=a..b. The output of MyProc is a list of list
I would like to do what dsolve do when you write:
p:=dsolve( {ode,ic},x(t),x(t),numeric)
and then evaluate p(2) for example.
So my question is how can I make MyProc so I can evaluate p(2). THis mean that p is a procedure given by the procedure MyProc. I don't want to use global in my procedure. Is this possible?
Mario
An error in typo
The 6 th line should read:
p:=dsolve( {ode,ic},x(t),numeric)
sorry!
I think what you want is
Your MyProc will look like
proc(args1, args2, args3, h) local v1, v2; # and more as needed statements; # these set things up proc(x) ssss end proc; # ssss uses v1, v2 and also args1, args2, etc end proc;This is how dsolve/numeric works.
While we are on the subject
<p>First of all, thanks you Jacques. Secondly, while on the subject of dsolve(...,numeric,..), I am wondering how Maple can give exactly, say, p(1/2) when the ics are x(a)=b. I know how to go from the ics to the left and from the ics to the right. </p>
<p>But, on the choice of h, nothing can assure me that I will be right on the spot (t=1/2). Does Maple redo the calculation with h = (a - 1/2)/N? This way, I am sure that the last calculation will be x(1/2)=something, wich is what I am looking for.</p>
<p><span><a href="http://www.mapleprimes.com/viewfile/2666"><img width="150" height="35" alt="" src="http://www.mapleprimes.com/scripts/image.php?image=http://www.mapleprimes.com/files/3867_Signature.jpg&width=300&height=300" /></a></span></p>
Oups! sorry for the bad output
Let me retry again.
First of all, thanks you Jacques. Secondly, while on the subject of dsolve(...,numeric,..), I am wondering how Maple can give exactly, say, p(1/2) when the ics are x(a)=b. I know how to go from the ics to the left and from the ics to the right.
But, on the choice of h, nothing can assure me that I will be right on the spot (t=1/2). Does Maple redo the calculation with h = (a - 1/2)/N? This way, I am sure that the last calculation will be x(1/2)=something, wich is what I am looking for.
dsolve
First of all, dsolve(..., numeric) isn't using a fixed step size, so your question doesn't quite make sense. The default method is a Runge-Kutta-Fehlberg method. But let's suppose you specified, say, method=classical[foreuler] for the Euler method which does have a fixed step size. Now the actual numerical calculation doesn't happen until you call p(1/2), so the end point t=1/2 is known. The step size can either be specified explicitly or chosen by Maple: if the latter, the choice is made by the procedure p itself. Anyway, if 1/2-a is not an integer multiple of the step size, the last step will be made smaller so that it ends up at t=1/2.