21.04.2015 Views

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

The Computable Differential Equation Lecture ... - Bruce E. Shapiro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

60 CHAPTER 3. APPROXIMATE SOLUTIONS<br />

for the first data set, and<br />

{ {t 0 , y 0,2 }, {t 1 , y 1,2 }, {t 2 , y 2,2 }, . . . }<br />

for the second data set. We get these from<br />

firstDataSet = Most /@ Flatten /@ r;<br />

secondDataSet = Drop[#, {2}] & /@ Flatten /@ r;<br />

Each “@” symbol is shorthand for the Map function. Thus Most /@Flatten /@r<br />

is equivalent to Map[Flatten[r]]. <strong>The</strong> Map function applies a function to every<br />

element in a list, namely, f/@{a, b, c}is the same as {f[a], f[b], f[c]}.<br />

Putting the whole solution together in one place, here is our program:<br />

y0={1,0};<br />

f[t , y ]:= {y[[2]], -y[[1]]};<br />

r=ForwardEuler[f,{0, y0}, 0.1π, 2π];<br />

firstDataSet = Most /@ Flatten /@ r;<br />

secondDataSet = Drop[#, {2}] & /@ Flatten /@ r;<br />

p1 = JoinedListPlot[FirstDataSet, Red, DisplayFunction->Identity];<br />

p2 = JoinedListPlot[SecondDataSet, Blue, DisplayFunction->Identity];<br />

Show[p1, p2, DisplayFunction -> $DisplayFunction, AspectRatio->0.2]<br />

3.6 Polynomial Approximation<br />

<strong>The</strong>orem 3.9 (Weierstrass Approximation <strong>The</strong>orem). Any continuous function<br />

can be approximated by a polynomial to any desired degree of accuracy. More<br />

specifcally, suppose that f(t) ∈ C(R). <strong>The</strong>n for any ɛ > 0, there exists a polynomial<br />

P (t) such that<br />

‖P − f‖ < ɛ (3.149)<br />

=⇒<br />

=⇒<br />

Proof. We will prove 2 the theorem on [0, 1]; the generalization to any closed interval<br />

[a, b] follows by an algebraic transformation ˆt = (b − a)t + a. We first prove the<br />

2 <strong>The</strong> proof follows the Encyclopedia of Mathematics object number 6145, AMS classification<br />

41A10, online edition only at http://planetmath.org. <strong>The</strong> proof can be skipped without any loss<br />

of continuity.<br />

Math 582B, Spring 2007<br />

California State University Northridge<br />

c○2007, B.E.<strong>Shapiro</strong><br />

Last revised: May 23, 2007

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!