{VERSION 5 0 "IBM INTEL NT" "5.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading
1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }1 0 0
0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1
18 0 0 0 0 0 1 1 0 0 0 0 0 0 1 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }
{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 1 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }}
{SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 82 "File: depart\\math\\mat270
5\\examples\\dsolvnr5.mws Date: 7-jan-1999 By: bob jantzen" }}{PARA
18 "" 0 "" {TEXT -1 52 "dsolve numeric: making robust functions of sol
utions" }}{PARA 19 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1
158 "This worksheet explains how to make MAPLE functions of the output
of dsolve/numeric solutions which can themselves appear in other deq'
s or be integrated etc." }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 38 "[MUG]
Re: dsolve(numeric) 24-FEB-1995" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1
26 " [MUG] Re: dsolve(numeric)" }}{PARA 0 "" 0 "" {TEXT -1 618 "From: \+
mi372@mluri.sari.ac.uk (Colin Birch)\n\n>>> From: herod@math.gatech.ed
u (Jim Herod)\n>\n>Although the example below will not illustrate it, \+
I am interested\n>in differential equations which are so complicated t
hat the solution can\n>not be found analytically.I use the \"numeric\"
option for dsolve. I want to\n>use the solution y(t) for the differen
tial equation in ways other than\nplotting\n>the solution:\n>for examp
le,\n> compute its norm: int('y(t)^2','t'=0..1), or\n> use it f
or a forcing function: dsolve(\{diff(z(t),t)=y(t-1),\n> \+
z(1) =1\}, z(t),numeric);\n>Is this possible?
" }}{PARA 0 "" 0 "" {TEXT -1 632 "I think that what you want to hear a
bout is the \"listprocedure\" option for\ndsolve,numeric. This is desc
ribed very clearly on pages 27,28 of the booklet\n\"Release 3 Notes Ma
ple V\" that comes with Maple V release 3. Here is the\napplication to
your example:\n\n> eqn := \{diff(y(t),t)=1, y(0)=0\};\n\n \+
d\n eqn := \{---- y(t) = 1,
y(0) = 0\}\n dt\n# Here the listproc
edure option is used.\n> soln := dsolve(eqn, y(t), numeric, output=lis
tprocedure);\n\n soln := [t = proc(t) ... end, y(t) = proc(
t) ... end]\n\n> yt := rhs(soln[2]);\n\nyt := proc(t) ... end" }}
{PARA 0 "" 0 "" {TEXT -1 1182 "# Because of the way numeric integratio
n works, y(t)^2 has to be defined\n# as a new procedure.\n> yt2 := pro
c(t)\n> evalf(yt(t)^2);\n> end;\n\nyt2 := proc(t) evalf(yt(t)^2) end\n
\n# Sorry, not quite the same question as you asked.\n> evalf(int(yt2,
u=0..3));\n\n 9.000000000\n\n# Probabl
y you will want to define z(t) using listprocedure as well.\n> soln2:=
dsolve(\{diff(z(t),t)='yt(t-1)', z(1)=1\}, z(t),\nnumeric,output=listp
rocedure);\n\n soln2 := [t = proc(t) ... end, z(t) = proc(t)
... end]\n> zt:=rhs(soln2[2]);\n\nzt := proc(t) ... end\n\n> zt(1);\n
1.\n> zt(2);\n \+
1.500000000\n\n> plot(zt, 0..5);\n\nI hope that this is \+
helpful. It seems a little awkward to have to define yt2\nas above so \+
as to make the integral int(yt(t)^2, t=0..3) work. Is there a\nbetter \+
way?\n\nColin Birch\n Craigiebuckler, Aberdeen, AB9 2QJ, UK\n \+
E-mail: mi372@mluri.sari.ac.uk\n Tel/Fax: +44 224 318611/311556
\n--------------------------------------------------------------------
------\n--------------------------------------------------------------
------------\n Animals and Grazing Ecology Division, MLURI," }}
{PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 47
"[MUG] release 5 update problem inquiry [dec-98]" }}{EXCHG {PARA 0 ""
0 "" {TEXT -1 167 "This comes from a MUG exchange in Feb 1995 about ds
olve (numeric), leading to a solution that worked at the time but no l
onger works after slight changes in Release 5." }}{PARA 0 "" 0 ""
{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 361 "One would like to create
a function from a numerical solution of a differential equation that \+
one can do other numerical operations to, like integrating a function \+
of that function, or using that function itself in the numerical solut
ion of another differential equation. One must navigate a sea of \"can
not evaluate Boolean\" to do this. Can someone explain why?" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "deq1 := \{diff(y(t),t)=1, y(
0)=0\}:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "soln1 := dsolve(
deq1, y(t), numeric, output=listprocedure):" }}}{EXCHG {PARA 0 "> " 0
"" {MPLTEXT 1 0 27 "Y := rhs(soln1[2]):\nY(1.5);" }}}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 55 "Y_square := proc(t) evalf(yt(t)^2); end:\nY_s
quare(1.5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 92 "evalf(Int(Y_
square(t),t=0..1));\nevalf(Int('Y_square(t)',t=0..1));\nevalf(Int(Y_sq
uare,0..1));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 167 "For us amateurs,
this quoting and boolean error stuff is very frustrating. Is there a \+
way around the problem when using the explicit argument version of thi
s function?" }}{PARA 0 "" 0 "" {TEXT -1 87 "The next line worked at th
e time but neither it nor the double quoted version work now." }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "deq2:= \{diff(z(t),t)='yt(t)
', z(0)=0\}:\ndeq3:= \{diff(z(t),t)=''yt(t)'', z(0)=0\}:" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 119 "soln2 := dsolve(deq2, z(t), numeri
c, output=listprocedure);\nsoln3 := dsolve(deq3, z(t), numeric, output
=listprocedure);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 301 "The obvious \+
solution is to solve the two equations together as a system, suggested
in other threads of this discussion at the time. But since the quotin
g used to work but no longer does, I would like to know the explanatio
n in terms of the boolean error message and whether or not there a wor
k around." }}{PARA 0 "" 0 "" {TEXT -1 254 "Lastly, can some one tell m
e why it is preferable that so many functions get derailed by prematur
e evaluation by default rather than checking for this and delaying eva
luation if necessary? Are there that many examples where you would not
want to do this?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 ""
{TEXT -1 7 "thanks," }}{PARA 0 "" 0 "" {TEXT -1 11 "bob jantzen" }}
{PARA 0 "" 0 "" {TEXT -1 72 "dept of mathematical sciences, villanova \+
university, villanova, pa 19085" }}{PARA 0 "" 0 "" {TEXT -1 53 "http:/
/renoir.vill.edu/faculty/jantzen/html/home.html" }}}}{SECT 1 {PARA 3 "
" 0 "" {TEXT -1 39 "[MUG] reply from Robert Israel [jan-99]" }}{EXCHG
{PARA 0 "" 0 "" {TEXT -1 872 "JANTZEN@UCIS.VILL.EDU (Bob Jantzen, Vill
anova University) wrote:\n\n| One would like to create a function from
a numerical solution of a \n| differential equation that one can do o
ther numerical operations to, \n| like integrating a function of that \+
function, or using that function \n| itself in the numerical solution \+
of another differential equation. \n| One must navigate a sea of \"can
not evaluate Boolean\" to do this. \n| Can someone explain why?\n\nAvo
iding premature evaluation is tricky when things are happening at\nver
y many levels, as occurs in numerical integration and solution of\nd.e
.'s. The most reliable way to avoid this, I think, instead of trying \+
to\nguess how many levels to delay evaluation is to construct\nfunctio
ns that return themselves unevaluated when given non-numeric\nargument
s. In your case, define yt (which I think you want to be the\nsame as
Y) by:\n\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "deq1 := \{di
ff(y(t),t)=1, y(0)=0\}:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "
soln1 := dsolve(deq1, y(t), numeric, output=listprocedure):" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "Y := rhs(soln1[2]):" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "yt:= proc(t) if type(t,numer
ic) then Y(t) else 'yt(t)' fi end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT
-1 19 "Then, for example, " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
28 "evalf(Int(yt(t)^2, t=0..1));" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 120 "soln2:= dsolve(\{diff(z(t),t) = yt(t), z(0)=0\}, z(t
), numeric, output=listprocedure):\n zf:= subs(soln2,z(t)):\n zf(3
);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "
" 0 "" {TEXT -1 329 "I know of no reason why procedures returned by `d
solve/numeric` shouldn't \nbe made to always return unevaluated when g
iven non-numeric arguments.\nIn fact, here's a \"wrapper\" for `dsolve
/numeric` that does so. This uses\nlexical scoping, so it won't work \+
before Release 5, though a Release 4\nversion wouldn't be too hard to \+
write." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 360 "numsolve:= proc(
) local makeok;\n makeok:= proc(p)\n if type(p, procedure) the
n \n proc(t) if type(t,numeric) then p(t) else 'procname'(t)
fi end\n elif type(p, list) then map(makeok, p)\n elif ty
pe(p, equation) then lhs(p) = makeok(rhs(p))\n else p\n fi
\n end;\n readlib(dsolve);\n makeok(`dsolve/NUMERIC`(args))\n \+
end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA
0 "" 0 "" {TEXT -1 145 " You can then use numsolve exactly as you woul
d use dsolve(..., numeric, ...)\n(and the \"numeric\" or \"type=numeri
c\" can be omitted). For example:" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 69 "soln1:=numsolve(\{diff(y(t),t)=1, y(0)=0\},y(t), outp
ut=listprocedure);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "Y:= r
hs(soln1[2]):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "Y(t);" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "Y(1.5);" }}}{EXCHG {PARA 0 "
" 0 "" {TEXT -1 264 "Feedback on any problems with numsolve would be a
ppreciated.\n\nRobert Israel israel@mat
h.ubc.ca\nDepartment of Mathematics http://www.math.ubc.ca/~isr
ael \nUniversity of British Columbia \nVancouver, BC, Canad
a V6T 1Z2\n" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 39 "[Mug] reply from
John Reinmann [jan-99]" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 752 "Bob,\n
\nI'm not a Maple expert, so I'm emailing you off line about my experi
ences\nwith the dismaying \"Cannot evaluate Boolean\" message and the \+
use of single\nquotes. About two months ago I raised questions simila
r to yours to MUG,\nexcept that I was using Release 4. I received sev
eral replies, each one\nbeing a little different. After studying the \+
replies, I was amazed to see\nthe many different ways that people had \+
devised to work around the problem.\n Below, I will give you the metho
d that I found to be both simple and\nBULLETPROOF, so far.\n\nI should
mention that none of the Maple experts that replied said that\nReleas
e 4 and Release 5 worked differently in this regard. \n\nIn looking ov
er your lines of code, I was stumped by the following line:\n\n>" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 ""
{TEXT -1 136 "Y_square:=proc(t) evalf(yt(t)^2);end:\n\nSince yt(t) was
not defined previously, this line didn't make sense. I put\nin your \+
next line \n\n>" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}
{EXCHG {PARA 0 "" 0 "" {TEXT -1 449 "Y_square(1.5)\n\nThis line yieled
the answer yt(1.5)^2, which implies that yt(t) had not\nbeen define
d previously. I don't understand how you got the answer\n2.250000000!
\n\nAssuming Release 4 and Release 5 do work the same way, the follo
wing\napproach has proved BULLETPROOF for all the numeric solutions of
ODE's that\nI have encountered since receiving the MUG expert replies
. In this\napproach, you need never bother with the single quotes agai
n.\n\n>" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "deq1:=\{diff(y(t
),t)=1,y(0)=0\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "soln1:=
dsolve(deq1,y(t),numeric,output=listprocedure);" }}}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 17 "Y:=rhs(soln1[2]);" }}}{EXCHG {PARA 0 "" 0 ""
{TEXT -1 31 "This is the BULLETPROOF method:" }}}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 50 "y:=t->if type(t,numeric) then Y(t) else 'y'(t) f
i;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "Y_square:=proc(t) eva
lf(y(t)^2); end: \n# notice the y(t) rather than yt(t)" }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "evalf(Int(Y_square(t),t=0..1));" }}
}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "deq2:=\{diff(z(t),t)=y(t),z
(0)=0\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "soln2:=dsolve(d
eq2,z(t),numeric,output=listprocedure);" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 17 "Z:=rhs(soln2[2]);" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 71 "z:=t->if type(t,numeric) then Z(t) else 'z'(t) fi; \+
\n# here it is again" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "z(1)
;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "z(2);" }}}{EXCHG {PARA
0 "> " 0 "" {MPLTEXT 1 0 5 "z(3);" }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 5 "z(4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 356 " Carefu
lly study the bulletproof line. I've shown this to others and they\nh
ave typed it incorrectly. The weird part is that you must use 'y'(t) \+
--\nnot 'Y'(t), which would make more sense.\n\nI know it's risky to c
all something BULLETPROOF, so let's say it's been\nbulletproof -- so f
ar.\n\nSincerely,\n\nJohn Reinmann email: j.reinmann@popmail.csuo
hio.edu\n" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0
0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }