06.09.2021 Views

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 2. SOLUTIONS OF EQUATIONS: ROOT-FINDING 81<br />

end<br />

pr<strong>in</strong>tln("Did not converge. The last estimate is p=$pzero.")<br />

Out[1]: fixedpt (generic function <strong>with</strong> 1 method)<br />

Let’s f<strong>in</strong>d the fixed-po<strong>in</strong>t of g(x) =x where g(x) =(2x 2 +1) 1/3 , <strong>with</strong> p 0 =1. We<br />

studied this problem <strong>in</strong> Example 43 where we found that 23 iterations guarantee an<br />

estimate accurate to <strong>with</strong><strong>in</strong> 10 −4 . We set ɛ =10 −4 ,andN =30, <strong>in</strong> the above code.<br />

In [2]: fixedpt(x->(2x^2+1)^(1/3.),1,10^-4.,30)<br />

p is 2.205472095330031 and the iteration number is 19<br />

The exact value of the fixed-po<strong>in</strong>t, equivalently the root of x 3 −2x 2 −1, is 2.20556943.<br />

Then the exact error is:<br />

In [3]: 2.205472095330031-2.20556943<br />

Out[3]: -9.733466996930673e-5<br />

A take home message and a word of caution:<br />

• The exact error, |p n − p|, is guaranteed to be less than 10 −4 after 23 iterations from<br />

Corollary 42, but as we observed <strong>in</strong> this example, this could happen before 23 iterations.<br />

• The stopp<strong>in</strong>g criterion used <strong>in</strong> the code is based on |p n − p n−1 |,not|p n − p|, so the<br />

iteration number that makes these quantities less than a tolerance ɛ will not be the<br />

same <strong>in</strong> general.<br />

Theorem 44. Assume p is a solution of g(x) =x, and suppose g(x) is cont<strong>in</strong>uously differentiable<br />

<strong>in</strong> some <strong>in</strong>terval about p <strong>with</strong> |g ′ (p)| < 1. Then the fixed-po<strong>in</strong>t iteration converges to p,<br />

provided p 0 is chosen sufficiently close to p. Moreover, the convergence is l<strong>in</strong>ear if g ′ (p) ≠0.<br />

Proof. S<strong>in</strong>ce g ′ is cont<strong>in</strong>uous and |g ′ (p)| < 1, there exists an <strong>in</strong>terval I = [p − ɛ, p + ɛ]<br />

such that |g ′ (x)| ≤ k for all x ∈ I, for some k < 1. Then, from Remark 39, weknow<br />

|g(x) − g(y)| ≤k|x − y| for all x, y ∈ I. Next, we argue that g(x) ∈ I if x ∈ I. Indeed, if<br />

|x − p|

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

Saved successfully!

Ooh no, something went wrong!