The Computable Differential Equation Lecture ... - Bruce E. Shapiro
The Computable Differential Equation Lecture ... - Bruce E. Shapiro
The Computable Differential Equation Lecture ... - Bruce E. Shapiro
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
CHAPTER 2. SUCCESSIVE APPROXIMATIONS 27<br />
the IVP:<br />
φ(t) =<br />
∞∑<br />
k=0<br />
where the last step follows from Taylor’s theorem.<br />
t k<br />
k! = et (2.12)<br />
Picard iteration is quite easy to implement in Mathematica; here is one possible<br />
implementation that will print out the first n iterations of the algorithm.<br />
Picard[f ,t , t0 , y0 , n ]:=<br />
Module[{i, y=y0}<br />
Print[Subscript["φ", 0], "=", y0];<br />
For[i=0, is}]) ds;<br />
t0<br />
y=ynext;<br />
Print[Subscript["φ", i+1], "=", y];<br />
];<br />
Return[Expand[y]]<br />
]<br />
Function Picard has five arguments (f, t, t0, y0, n) and two local variables ⇐=<br />
(i, y)<br />
Picard[f ,t , t0 , y0 , n ]:=<br />
Module[{i, y=y0},<br />
. . .<br />
]<br />
<strong>The</strong> local variable y is initialized to the value of the parameter y0 in the list of<br />
variable declarations. This is equivalent to initializing the value of the variable in<br />
the first line of the program. <strong>The</strong> first line of the program prints the initial iteration<br />
as φ 0 =value of parameter y 0 ,<br />
Print[Subscript["φ", 0], "=", y0];<br />
<strong>The</strong> output will be displayed on the console in an “output cell.” <strong>The</strong> next line of<br />
the program is a For loop. A For statement takes on four arguments:<br />
For[initialization,<br />
test,<br />
increment,<br />
statement;<br />
]<br />
.<br />
statement;<br />
<strong>The</strong> For loop takes the following actions:<br />
c○2007, B.E.<strong>Shapiro</strong><br />
Last revised: May 23, 2007<br />
Math 582B, Spring 2007<br />
California State University Northridge