Sie sind auf Seite 1von 30

Approximation and Errors

Numerical Methods Wen-Chieh Lin 2


Well-Posed Problems
Problem is well-posed if solution
exits
is unique
depends continuously on problem data
Otherwise, problem is ill-posed
Numerical Methods Wen-Chieh Lin 3
Remedy to ill-posed problem
Replace difficult problem by easier one having
same or close enough solution
nonlinear linear
infinite finite
differential algebraic
complicate simple
Solution obtained may only approximate that
of the original problem
Numerical Methods Wen-Chieh Lin 4
Sources of Approximation
Before computation
Modeling
Empirical measurements
Previous computations
During computation
Truncation or discretization
Rounding
Accuracy of final result reflects all these
Uncertainty in input may be amplified by problem
Perturbations during computation may be amplified
by algorithm
From Michael T. Heaths slide
Numerical Methods Wen-Chieh Lin 5
Example: Approximations
Computing surface area of Earth using formula
involves several approximations
Earth is modeled as sphere, idealizing its true
shape
Value for radius is based on empirical
measurements and previous computations
Value forrequires truncating infinite process
Values for input data and results of arithmetic
operations are rounded in computer
2
4 r V =
From Michael T. Heaths slide
Numerical Methods Wen-Chieh Lin 6
Error Definition
Absolute error: |approximate value true value|
Relative error: (absolute error)/(true value)
True value is usually unknown, so we estimate or
bound error than compute it exactly
Relative error often taken relative to approximate
value rather than (unknown) true value
From Michael T. Heaths slide
ion approxiamt current
ion approximat previous - ion approximat current
Numerical Methods Wen-Chieh Lin 7
Truncation Error
Difference between true result and result
produced by given algorithm using exact
arithmetic
Due to approximations such as truncating
infinite series or terminating iterative sequence
before convergence
! 3 ! 2 ! 1
1
3 2
x x x
e
x
+ + + ~

=
+ + + + =
4
3 2
! ! 3 ! 2 ! 1
1
n
n
x
n
x x x x
e
Truncation error
Numerical Methods Wen-Chieh Lin 8
! 1
1
x
e
x
+ ~
1
5 . 0
~ e
1 ~
x
e
5 . 1
5 . 0
~ e
% 3 . 33 % 100
5 . 1
1 5 . 1
=

=
ion approxiamt current
ion approximat previous - ion approximat current
=

=
+ + + + =
4
3 2
! ! 3 ! 2 ! 1
1
n
n
x
n
x x x x
e
Numerical Methods Wen-Chieh Lin 9
! 1
1
x
e
x
+ ~
1
5 . 0
~ e
1 ~
x
e
5 . 1
5 . 0
~ e
% 69 . 7 % 100
625 . 1
1 625 . 1
=

=
+ + + + =
4
3 2
! ! 3 ! 2 ! 1
1
n
n
x
n
x x x x
e
! 2 ! 1
1
2
x x
e
x
+ + ~
625 . 1
5 . 0
~ e
% 3 . 33 =
Numerical Methods Wen-Chieh Lin 10
! 1
1
x
e
x
+ ~
1
5 . 0
~ e
1 ~
x
e
5 . 1
5 . 0
~ e
% 27 . 1 =

=
+ + + + =
4
3 2
! ! 3 ! 2 ! 1
1
n
n
x
n
x x x x
e
! 2 ! 1
1
2
x x
e
x
+ + ~
625 . 1
5 . 0
~ e
% 3 . 33 =
% 69 . 7 =
! 3 ! 2 ! 1
1
3 2
x x x
e
x
+ + + ~
645833333 . 1
5 . 0
~ e
Numerical Methods Wen-Chieh Lin 11
Round-off Error
Difference between result produced by given
algorithm using exact arithmetic and result
produced by same algorithm using limited
precision arithmetic
Due to inexact representation of real numbers
and arithmetic operations upon them
Computational error = truncation error +
round-off error
Numerical Methods Wen-Chieh Lin 12
Propagated Error
An error in the succeeding steps of a process
due to an occurrence of an earlier error
Numerical Methods Wen-Chieh Lin 13
calc
x
Forward and Backward Error
Suppose we want to compute y=f(x), where f is a real
value function, but obtain approximate value
Forward error
Backward error
calc
y
) (x f y
exact
=
x
) (
1
calc calc
y f x

=
calc
y
exact
y
exact calc fwd
y y E =
x x E
calc backw
=
Numerical Methods Wen-Chieh Lin 14
x
Forward and Backward Error
Suppose we want to compute y=f(x), where f is a real
value function, but obtain approximate value
Forward error
Backward error
y
) (x f y =
x
) (
1
y f x

=
y
y
y y y = A
x x x = A
Numerical Methods Wen-Chieh Lin 15
Backward Error Analysis
Idea: approximate solution is exact solution to
modified problem
How much must original problem change to
give result actually obtained?
How much data error in input would explain
all error in computed result?
Approximate solution is good if it is exact
solution to near problem
From Michael T. Heaths slide
Numerical Methods Wen-Chieh Lin 16
Example: Backward Error Analysis
Approximating cosine function by truncating
Taylor series after two terms gives
Forward error is given by
Backward error is given by , where
2 1 ) (

2
x x f y = =
) cos( 2 1 ) ( ) (

2
x x x f x f y y = =
) arccos( ) (
1
y y f x = =

x x
Numerical Methods Wen-Chieh Lin 17
Example (cont.)
For x=1,
Forward error:
Backward error:
5 . 0 2 1 1 ) 1 (

2
= = = f y
5403 . 0 ) 1 cos( ) 1 ( ~ = = f y
0472 . 1 ) 5 . 0 arccos( ) arccos( ~ = = y x
0403 . 0 5403 . 0 5 . 0 = ~ = A y y y
0472 . 0 1 0472 . 1 = ~ = A x x x
Numerical Methods Wen-Chieh Lin 18
Sensitivity and Conditioning
Problem is insensitive or well-conditioned, if relative
change in input causes similar change in solution
Problem is sensitive or ill-conditioned, if relative
change in solution can be much larger than that in
input
Condition number
x x x
x f x f x f
) (
) ( )] ( ) ( [
| data input in chage relative |
| solution in change relative |
cond

=
=
Numerical Methods Wen-Chieh Lin 19
Sensitivity and Conditioning (cont.)
Problem is sensitive or ill-conditioned, if
cond >> 1
A well-posed problem can be ill-conditioned
Computational algorithm should not make
sensitivity worse
Numerical Methods Wen-Chieh Lin 20
Condition Number
Condition number is amplification factor relating
relative forward error to relative backward error
Condition number is usually not known exactly and
may vary with input, so rough estimate or upper
bound is used
x x
y y
x x x
x f x f x f
A
A
=

=
) (
) ( )] ( ) ( [
cond
Numerical Methods Wen-Chieh Lin 21
) (
) ( '
) ( ) ( '
) (
) ( )] ( ) ( [
) (
) ( )] ( ) ( [
| data input in chage relative |
| solution in change relative |
cond
x f
x xf
x h
x f x hf
x x h x
x f x f h x f
x x x
x f x f x f
= ~
+
+
=

=
=
Example: Evaluating Function
Evaluating function f for approximate input
) ( ' ) ( ) ( x hf x f h x f + ~ +
h x x + =
h x x + =
Numerical Methods Wen-Chieh Lin 22
Example: Sensitivity
Tangent function is sensitive for arguments
near /2
For
5
10 58058 . 1 ) 57079 . 1 tan( ~
4
10 58058 . 6 ) 57078 . 1 tan( ~
5
10 48275 . 2 cond , 57079 . 1 ~ = x
Numerical Methods Wen-Chieh Lin 23
Stability
Algorithm is stable if result produced is relatively
insensitive to perturbations during computation
Stability of algorithm is analogous to conditioning of
problems
From viewpoint of backward error analysis,
algorithm is stable if result produced is exact solution
to nearby problem
For stable algorithm, effect of computational error is
worse than effect of small data error in input
From Michael T. Heaths slide
Numerical Methods Wen-Chieh Lin 24
Accuracy
Accuracy: closeness of computed solution to true
solution of problem
Stability alone does not guarantee accurate results
Accuracy depends on conditioning of problem as well
as the stability of algorithm
Inaccuracy can result from applying
stable algorithm to ill-conditioned problem
unstable algorithm to well-conditioned problem
Applying stable algorithm to well-conditioned
problem yields accurate solution
From Michael T. Heaths slide
Numerical Methods Wen-Chieh Lin 25
Floating-Point Arithmetic
Floating-point number is represented by
sign
fraction (mantissa)
exponent
E
p
p
d
d d
x 2 )
2 2 2
1 (
1
1
2
2 1

+ + + + =
U E L p i d
i
s s = s s and , 1 , , 1 , 1 0 where
Numerical Methods Wen-Chieh Lin 26
Machine Numbers
Not all real numbers exactly representable;
those that are are called machine numbers
Machine numbers are unequally spaced
If a real number is not exactly repersentable,
then it is approximated by a nearby machine
number causing round-off error
Numerical Methods Wen-Chieh Lin 27
Machine Precision
Accuracy of floating-point system
characterized by unit round-off (or machine
precision or machine epsilon)
Smallest number such that
If
1 ) 1 ( > + eps float

= + + ) 1 (
= + + ) ( 1
eps <
Numerical Methods Wen-Chieh Lin 28
Machine Precision
Accuracy of floating-point system
characterized by unit round-off (or machine
precision or machine epsilon)
Smallest number such that
If
1 ) 1 ( > + eps float

1 ) 1 ( = + +
= + + ) ( 1
eps <
Numerical Methods Wen-Chieh Lin 29
Machine Precision
Accuracy of floating-point system
characterized by unit round-off (or machine
precision or machine epsilon)
Smallest number such that
If
1 ) 1 ( > + eps float

1 ) 1 ( = + +
1 ) ( 1 > + +
eps <
Numerical Methods Wen-Chieh Lin 30
Summary
Well-posed problem
Computational error
truncation error
round-off error
Sensitivity (conditioning) of problem
Condition number
Stability of algorithm

Das könnte Ihnen auch gefallen