Picard Iterations
def picard_iteration(f, a, c, iterations):
if iterations == 0:
return c
if iterations == 1:
x0 = lambda t: c + integral(f(t=s,x=c), s, a, t)
return expand(x0(t))
for i in range(iterations):
x_old = lambda s: picard_iteration(f, a, c, iterations-1).subs(t=s)
x0 = lambda t: c + integral(f(t=s,x=x_old(s)), s, a, t)
return expand(x0(t))
def picarder(n_iterations = slider(0,20,1,default = 2)):
var('x,t,s')
f = lambda t,x:x
html(r"Exact solution to $x' = x$, $x(0) = 1$ is $x = \exp(t)$
")
pic = picard_iteration(f,0,1,n_iterations)
html('The Picard iteration approximation after ' + str(n_iterations) + ' iterations is:
')
html('$'+latex(pic)+'$')
exact = plot(exp(t),(t,0,2))
pic_plot = plot(pic,(t,0,2), rgbcolor = (1,0,0))
show(exact + pic_plot)
This tutorial contains software programs that are free: you can redistribute codes and/or modify scripts under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This tutorial is distributed in the hope that its material and codes will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For full version of GNU General Public License, see https://www.gnu.org/licenses/gpl-3.0.en.html.
This tutorial corresponds to the matlab “m” files that are posted on the APMA 0340 website. You, as the user, are free to use the m files to your needs for learning how to use the matlab program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately. Any comments and/or contributions for this tutorial are welcome; you can send your remarks to <Vladimir_Dobrushkin@brown.edu>
- Keskin, A.U., Ordinary Differential Equations for Engineers: with MATLAB Solutions, Springer; 1st ed. 2019. ISBN-13: 978-3030069995 ISBN-10: 3030069990
Glossary