List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Print the procedure output from dsolve
| [MUG] Print the procedure output from dsolve |
|
Author: Reuben D Budiardja
Posted: Mon, 13 May 2002 21:06:24 -0500
|
>> From: "Reuben D Budiardja" "reubendb"
Greetings,
I need some help with this. Suppose I have a differential equation that I
solve numerically using dsolve, something like:
dsol := dsolve({def_eq,ic}, numeric, output=listprocedure);
Maple wil then give me a listprocedure, for example:
dsol1 := [ t=proc(t) ... end proc, y(t)=proc(t) ... end proc ]
I can get the procedure by doing
fy := eval(y(t), dsol1);
and thus I can do
fy(1) ;
and get a result.
But what I really want, is either the function or the procedure of y(t). How
can I get that? I tried to do eval and print fy, and all I get is:
proc(t)... end proc.
How can I get the actual procedure ? I want this, because I use maple to
solve my differential equation, and then if I can get the procedure, I want
to use that numerical procedure / algorithm in other program such as C++.
Any help or pointer on this will be greatly appreciated.
Thanks.
Reuben D. Budiardja
|
| [MUG] Re: Print the procedure output from dsolve |
|
Author: Maple User Group
Posted: Fri, 17 May 2002 15:11:00 -0400
|
>> From: Maple User Group "maple_gr"
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Wed, 15 May 2002 11:40:09 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: Print the procedure output from dsolve
You could see the code with either
> showstat(fy);
or
> interface(verboseproc=3): eval(fy);
But you'll have to do some digging to get actual procedures that can
be used in C++. It might be easier to consult some of the references
listed in the help page ?dsolve,numeric, or use ready-made C code that is
available in various places.
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 16 May 2002 10:14:46 +0200
From: Preben Alsholm "ifakpa"
To: "maple-list" "reubendb"
Subject: Print the procedure output from dsolve
You can do as follows (here illustrated with y'=y, y(0)=1):
> restart;
> L:=dsolve({diff(y(t),t)=y(t),y(0)=1},y(t),type=numeric,output=listprocedure):
> f:=subs(L,y(t)):
> interface(verboseproc=2);
> eval(f);
Then you see the procedure f. That procedure, however, calls other Maple
procedures, so it might not be of any help in your situation.
--
Preben Alsholm
Institut for matematik (Department of Mathematics)
DTU (Technical University of Denmark)
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 16 May 2002 08:25:34 +0200
From: Helmut Kahovec "helmut.kahovec"
To: "maple-list" Reuben D Budiardja "reubendb"
Subject: Print the procedure output from dsolve
Well, you may set interface(verboseproc=2); or use showstat(). However,
it will be rather difficult to extract the numerical algorithm of the
solution from this.
> restart:
> ode:=diff(y(x),x$2)+y(x)=0:
> IC:=y(0)=0,D(y)(0)=0:
> dsol:=dsolve({ode,IC},numeric,output=listprocedure):
> f:=eval(y(x),dsol);
f := proc(x) ... end proc
> f(Pi);
0.
> showstat(f);
f := proc(x)
local res, plistproc, outpoint, ndsol;
1 outpoint := evalf(x);
2 plistproc := proc (rkf45_x)
local i, comp_soln_data, odeproc, icvec, LR_case, Y, val,
outpoint, pt, stop_proc, stop_array, cplex;
option `Copyright (c) 2000 by the University of Waterloo. ...
...
val := `dsolve/numeric/SC/IVPval`(comp_soln_data,outpoint);
[x = outpoint, seq(Y[i] = val[i],i = 1 .. nops(Y))]
end proc;
plistproc("complex") := false;
plistproc("right_comp_soln_data") := [
2, 9,
Array(
1..9,
[ ... ],
datatype = float[8],
storage = rectangular,
order = C_order
),
Array(
1..9, 1..2,
[ ... ],
datatype = float[8],
storage = rectangular,
order = C_order
),
4, false, 13, 0, true, 14, 1
];
plistproc("soln_procedures") := [14249992, 14325068, 14250072];
3 if not type(outpoint,'numeric') then
4 if member(outpoint,["start", "left", "right"]) then
5 return plistproc(x)
elif outpoint = "procedurelist" then
6 return eval(plistproc)
elif procname <> unknown then
7 return ('procname')(x)
else
8 ndsol := pointto(plistproc("soln_procedures")[2]);
9 return ('ndsol')(x)
end if
end if;
10 res := [traperror(plistproc(x))];
11 if type(res[1],string) then
12 error op(res)
else
13 rhs(res[1][2])
end if
end proc
Kind regards,
Helmut
|
Previous by date: [MUG] Re: eigenvect for real nonsymmetric matrix, Maple User Group
Next by date: [MUG] Coupled, nonlinear ODEs., Anders Ballestad
Previous thread: [MUG] MathML Conference, Stan Devitt
Next thread: [MUG] Coupled, nonlinear ODEs., Anders Ballestad
|