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 4. NUMERICAL QUADRATURE AND DIFFERENTIATION 172<br />

The correct answer is cos 0.1 =0.995004.<br />

To estimate f ′ (0.3) we can use the midpo<strong>in</strong>t formula:<br />

f ′ (0.3) ≈ 1 (0.38942 − 0.19867) = 0.95375.<br />

0.2<br />

The correct answer is cos 0.3 =0.955336 and thus the absolute error is 1.59 × 10 −3 . If we use<br />

the endpo<strong>in</strong>t formula to estimate f ′ (0.3) we set h = −0.1 and compute<br />

f ′ (0.3) ≈ 1 (−3(0.29552) + 4(0.19867) − 0.09983) = 0.95855<br />

−0.2<br />

<strong>with</strong> an absolute error of 3.2 × 10 −3 .<br />

Exercise 4.6-1: In some applications, we want to estimate the derivative of an unknown<br />

function from empirical data. However, empirical data usually come <strong>with</strong> "noise", that is,<br />

error due to data collection, data report<strong>in</strong>g, or some other reason. In this exercise we will<br />

<strong>in</strong>vestigate how stable the difference formulas are when there is noise <strong>in</strong> the data. Consider<br />

the follow<strong>in</strong>g data obta<strong>in</strong>ed from y = e x . The data is exact to six digits. We estimate f ′ (1.01)<br />

x 1.00 1.01 1.02<br />

f(x) 2.71828 2.74560 2.77319<br />

us<strong>in</strong>g the three-po<strong>in</strong>t midpo<strong>in</strong>t formula and obta<strong>in</strong> f ′ (1.01) = 2.77319−2.71828 =2.7455. The<br />

0.02<br />

true value is f ′ (1.01) = e 1.01 =2.74560, and the relative error due to round<strong>in</strong>g is 3.6 × 10 −5 .<br />

Next, we add some noise to the data: we <strong>in</strong>crease 2.77319 by 10% to 3.050509, and<br />

decrease 2.71828 by 10% to 2.446452. Here is the noisy data:<br />

x 1.00 1.01 1.02<br />

f(x) 2.446452 2.74560 3.050509<br />

Estimate f ′ (1.01) us<strong>in</strong>g the noisy data, and compute its relative error. How does the<br />

relative error compare <strong>with</strong> the relative error for the non-noisy data?<br />

We next want to explore how to estimate the second derivative of f. A similar approach to<br />

estimat<strong>in</strong>g f ′ can be taken and the second derivative of the <strong>in</strong>terpolat<strong>in</strong>g polynomial can be<br />

used as an approximation. Here we will discuss another approach, us<strong>in</strong>g Taylor expansions.<br />

Expand f about x 0 , and evaluate it at x 0 + h and x 0 − h:

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

Saved successfully!

Ooh no, something went wrong!