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

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

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

CHAPTER 5. APPROXIMATION THEORY 180<br />

2. How do we f<strong>in</strong>d a, b that gives the l<strong>in</strong>e <strong>with</strong> the "best" approximation?<br />

Observe that for each x i , there is the correspond<strong>in</strong>g y i of the data po<strong>in</strong>t, and f(x i ) =<br />

ax i + b, which is the predicted value by the l<strong>in</strong>ear approximation. We can measure error by<br />

consider<strong>in</strong>g the deviations between the actual y coord<strong>in</strong>ates and the predicted values:<br />

(y 1 − ax 1 − b), (y 2 − ax 2 − b), ..., (y m − ax m − b)<br />

There are several ways we can form a measure of error us<strong>in</strong>g these deviations, and each<br />

approach gives a different l<strong>in</strong>e approximat<strong>in</strong>g the data. The best approximation means<br />

f<strong>in</strong>d<strong>in</strong>g a, b that m<strong>in</strong>imizes the error measured <strong>in</strong> one of the follow<strong>in</strong>g ways:<br />

• E =max i {|y i − ax i − b|} ; m<strong>in</strong>imax problem<br />

• E = ∑ m<br />

i=1 |y i − ax i − b|; absolute deviations<br />

• E = ∑ m<br />

i=1 (y i − ax i − b) 2 ; least squares problem<br />

In this chapter we will discuss the least squares problem; the simplest one among the three<br />

options. We want to m<strong>in</strong>imize<br />

E =<br />

m∑<br />

(y i − ax i − b) 2<br />

i=1<br />

<strong>with</strong> respect to the parameters a, b. For a m<strong>in</strong>imum to occur, we must have<br />

∂E<br />

∂a<br />

=0and<br />

∂E<br />

∂b =0.<br />

We have:<br />

m<br />

∂E<br />

∂a = ∑<br />

i=1<br />

∂E<br />

∂b = m<br />

∑<br />

i=1<br />

∂E<br />

∂a (y i − ax i − b) 2 =<br />

∂E<br />

∂b (y i − ax i − b) 2 =<br />

m∑<br />

(−2x i )(y i − ax i − b) =0<br />

i=1<br />

m∑<br />

(−2)(y i − ax i − b) =0<br />

i=1<br />

Us<strong>in</strong>g algebra, these equations can be simplified as<br />

m∑ m∑<br />

b x i + a x 2 i =<br />

i=1<br />

bm + a<br />

i=1<br />

m∑<br />

x i =<br />

i=1<br />

m∑<br />

x i y i<br />

i=1<br />

m∑<br />

y i ,<br />

i=1

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

Saved successfully!

Ooh no, something went wrong!