










































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











































Approximations Computer Arithmetic Mathematical Software
Chapter 1 – Scientific Computing
Prof. Michael T. Heath
Department of Computer Science
University of Illinois at Urbana-Champaign
Copyright c© 2002. Reproduction permitted
for noncommercial, educational use only.
Approximations Computer Arithmetic Mathematical Software
(^1) Introduction
(^2) Approximations
(^3) Computer Arithmetic
(^4) Mathematical Software
Approximations Computer Arithmetic Mathematical Software
Problem is well-posed if solution
exists
is unique
depends continuously on problem data
Otherwise, problem is ill-posed
Even if problem is well posed, solution may still be
sensitive to input data
Computational algorithm should not make sensitivity worse
Approximations Computer Arithmetic Mathematical Software
Replace difficult problem by easier one having same or
closely related solution
infinite → finite
differential → algebraic
nonlinear → linear
complicated → simple
Solution obtained may only approximate that of original
problem
Approximations Computer Arithmetic Mathematical Software
Computing surface area of Earth using formula A = 4πr
2
involves several approximations
Earth is modeled as sphere, idealizing its true shape
Value for radius is based on empirical measurements and
previous computations
Value for π requires truncating infinite process
Values for input data and results of arithmetic operations
are rounded in computer
Approximations Computer Arithmetic Mathematical Software
Absolute error : approximate value − true value
Relative error : (absolute error) / (true value)
Equivalently, approx value = (true value) × (1 + rel error)
True value usually unknown, so we estimate or bound
error rather than compute it exactly
Relative error often taken relative to approximate value,
rather than (unknown) true value
Approximations Computer Arithmetic Mathematical Software
Truncation error : difference between true result (for actual
input) and result produced by given algorithm using exact
arithmetic
Due to approximations such as truncating infinite series or
terminating iterative sequence before convergence
Rounding 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 is sum of truncation error and
rounding error, but one of these usually dominates
Approximations Computer Arithmetic Mathematical Software
Error in finite difference approximation
f
′ (x) ≈
f (x + h) − f (x)
h
exhibits tradeoff between rounding error and truncation
error
Truncation error bounded by M h/ 2 , where M bounds
|f
′′ (t)| for t near x
Rounding error bounded by 2 /h, where error in function
values bounded by
Total error minimized when h ≈ 2
Error increases for smaller h because of rounding error
and increases for larger h because of truncation error
Approximations Computer Arithmetic Mathematical Software
Suppose we want to compute y = f (x), where f : R → R,
but obtain approximate value yˆ
Forward error : ∆y = ˆy − y
Backward error : ∆x = ˆx − x, where f (ˆx) = ˆy
Approximations Computer Arithmetic Mathematical Software
As approximation to y =
2 , yˆ = 1. 4 has absolute forward
error
|∆y| = |yˆ − y| = | 1. 4 − 1. 41421... | ≈ 0. 0142
or relative forward error of about 1 percent
Since
1 .96 = 1. 4 , absolute backward error is
|∆x| = |xˆ − x| = | 1. 96 − 2 | = 0. 04
or relative backward error of 2 percent
Approximations Computer Arithmetic Mathematical Software
Approximating cosine function f (x) = cos(x) by truncating
Taylor series after two terms gives
y ˆ =
f (x) = 1 − x
2 / 2
Forward error is given by
∆y = ˆy − y =
f (x) − f (x) = 1 − x
2 / 2 − cos(x)
To determine backward error, need value xˆ such that
f (ˆx) =
f (x)
For cosine function, xˆ = arccos(
f (x)) = arccos(ˆy)
Approximations Computer Arithmetic Mathematical Software
For x = 1,
y = f (1) = cos(1) ≈ 0. 5403
yˆ =
f (1) = 1 − 1
2 /2 = 0. 5
ˆx = arccos(ˆy) = arccos(0.5) ≈ 1. 0472
Forward error: ∆y = ˆy − y ≈ 0. 5 − 0 .5403 = − 0. 0403
Backward error: ∆x = ˆx − x ≈ 1. 0472 − 1 = 0. 0472
Approximations Computer Arithmetic Mathematical Software
Condition number is amplification factor relating relative
forward error to relative backward error
relative
forward error
= cond ×
relative
backward error
Condition number usually is not known exactly and may
vary with input, so rough estimate or upper bound is used
for cond, yielding
relative
forward error
/ cond ×
relative
backward error
Approximations Computer Arithmetic Mathematical Software
Evaluating function f for approximate input xˆ = x + ∆x
instead of true input x gives
Absolute forward error: f (x + ∆x) − f (x) ≈ f
′ (x)∆x
Relative forward error:
f (x + ∆x) − f (x)
f (x)
f
′ (x)∆x
f (x)
Condition number: cond ≈
f
′ (x)∆x/f (x)
∆x/x
xf
′ (x)
f (x)
Relative error in function value can be much larger or
smaller than that in input, depending on particular f and x