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 56<br />

Step 1 : To start, we need to pick an <strong>in</strong>terval [a, b] that conta<strong>in</strong>s the root, that is, f(a)f(b) < 0.<br />

From the plot, it is clear that [0, 4] is a possible choice. In the next few steps, we<br />

will be work<strong>in</strong>g <strong>with</strong> a sequence of <strong>in</strong>tervals. For convenience, let’s label them as<br />

[a, b] =[a 1 ,b 1 ], [a 2 ,b 2 ], [a 3 ,b 3 ], etc. Our first <strong>in</strong>terval is then [a 1 ,b 1 ]=[0, 4]. Next we<br />

f<strong>in</strong>d the midpo<strong>in</strong>t of the <strong>in</strong>terval, p 1 =4/2 =2, and use it to obta<strong>in</strong> two sub<strong>in</strong>tervals<br />

[0, 2] and [2, 4]. Only one of them conta<strong>in</strong>s the root, and that is [2, 4].<br />

Step 2: From the previous step, our current <strong>in</strong>terval is [a 2 ,b 2 ]=[2, 4]. We f<strong>in</strong>d the midpo<strong>in</strong>t 1<br />

p 2 = 2+4<br />

2<br />

=3, and form the sub<strong>in</strong>tervals [2, 3], [3, 4]. The one that conta<strong>in</strong>s the root is<br />

[3, 4].<br />

Step 3: We have [a 3 ,b 3 ]=[3, 4]. The midpo<strong>in</strong>t is p 3 =3.5. We are now pretty close to the<br />

root visually, and we stop the calculations!<br />

In this simple example, we did not consider<br />

• Stopp<strong>in</strong>g criteria<br />

• It’s possible that the stopp<strong>in</strong>g criterion is not satisfied <strong>in</strong> a reasonable amount of time.<br />

We need a maximum number of iterations we are will<strong>in</strong>g to run the code.<br />

Remark 27. 1. A numerically more stable formula to compute the midpo<strong>in</strong>t is a + b−a<br />

2<br />

(see Example 20).<br />

2. There is a convenient stopp<strong>in</strong>g criterion for the bisection method that was not mentioned<br />

before. One can stop when the <strong>in</strong>terval [a, b] at step n is such that |a − b|

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

Saved successfully!

Ooh no, something went wrong!