Document

advertisement
Measuring Errors
Major: All Engineering Majors
Authors: Autar Kaw, Luke Snyder
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
1/13/2016
http://numericalmethods.eng.usf.edu
1
Why measure errors?
1) To determine the accuracy of
numerical results.
2) To develop stopping criteria for
iterative algorithms.
2
http://numericalmethods.eng.usf.edu
True Error
Defined as the difference between the true
value in a calculation and the approximate
value found using a numerical method etc.
True Error = True Value – Approximate Value
3
http://numericalmethods.eng.usf.edu
Example—True Error
The derivative, f ′(x) of a function f (x) can be
approximated by the equation,
f ' ( x) ≈
f ( x + h) − f ( x)
h
0.5 x
If f ( x) = 7e and h = 0.3
a) Find the approximate value of f ' ( 2)
b) True value of f ' ( 2)
c) True error for part (a)
4
http://numericalmethods.eng.usf.edu
Example (cont.)
Solution:
a) For x = 2 and h = 0.3
f ( 2 + 0.3) − f ( 2)
0 .3
f ( 2.3) − f (2)
=
0. 3
f ' ( 2) ≈
7e 0.5( 2.3) − 7e 0.5( 2 )
=
0.3
22.107 − 19.028
= 10.263
=
0.3
5
http://numericalmethods.eng.usf.edu
Example (cont.)
Solution:
b) The exact value of f ' ( 2) can be found by using
our knowledge of differential calculus.
f ( x ) = 7 e 0 .5 x
f ' ( x ) = 7 × 0.5 × e 0.5 x
= 3.5e 0.5 x
So the true value of
f ' ( 2) = 3.5e 0.5( 2 )
= 9.5140
f ' ( 2)
is
True error is calculated as
Et = True Value – Approximate Value
= 9.5140 − 10 .263 = −0.722
6
http://numericalmethods.eng.usf.edu
Relative True Error
Defined as the ratio between the true
error, and the true value.
Relative True Error ( ∈t ) =
7
True Error
True Value
http://numericalmethods.eng.usf.edu
Example—Relative True Error
Following from the previous example for true error,
find the relative true error for f ( x) = 7e 0.5 x at f ' (2)
with h = 0.3
From the previous example,
Et = −0.722
Relative True Error is defined as
True Error
True Value
− 0.722
=
= −0.075888
9.5140
∈t =
as a percentage,
∈t = −0.075888 × 100% = −7.5888 %
8
http://numericalmethods.eng.usf.edu
Table of Values
0.5 x
For f ( x) = 7e at x = 2 with varying step size, h
9
h
f ′(2)
∈a
m
0.3
10.263
N/A
0
0.15
9.8800
3.877%
1
0.10
9.7558
1.273%
1
0.01
9.5378
2.285%
1
0.001
9.5164
0.2249%
2
http://numericalmethods.eng.usf.edu
Example: Evaluate the following function at x=1.0002
using Maple 10-digit floating point arithmetic
Naïve calculation:
Find the Taylor polynomial of f(1+h) of degree 3:
10
http://numericalmethods.eng.usf.edu
Error in yesterday’s slides:
The remainder, for c between 1 and 1.0002
So the value is approximately 0.33330247
Confimation using 30-digit evaluation
11
http://numericalmethods.eng.usf.edu
Evaluate by Desmos
Direct:
-3.3030859
Taylor polynomial : -3.0863781
http://numericalmethods.eng.usf.edu
Taylor series by Symbolab
13
http://numericalmethods.eng.usf.edu
Homework:
1. (Maple) For the function
(i)
(ii)
(iii)
(iv)
(v)
(vi)
Evaluate f(2.01) directly in Maple
Find the Taylor polynomial of f(2+h) of degree 5
Evaluate f(2.01) using the Taylor polynomial in (ii)
Find the remainder
Plot the remainder and estimate the error of Taylor polynomial
Evaluate f(2.01) using 30-digit evaluation to confirm
the value and error
2. For a function f(x), we know
f(2.3) = 1.54, f’(2.3) = -3.21, f’’(2.3) = 0, f’’’(2.3) = 6.11
what are the values of f(2.3105) and f(2.2993) approximately?
3. (Maple) How to calculate f(0.524) for f(x) =
accurately using 10-digit, knowing
14
http://numericalmethods.eng.usf.edu
4. (Symbolab and Desmos) For function
compare direct evaluation of f(2.0003) with
aylor polynomial of degree 4, then estimate the error by
the remainder
What is the error and relative error in each case?
15
http://numericalmethods.eng.usf.edu
16
http://numericalmethods.eng.usf.edu
17
http://numericalmethods.eng.usf.edu
Download