Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Mathematical Modeling

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Modeling, Computers, and Error Analysis

Department of Mathematics, UoM

March 2, 2023

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 1 / 14
Approximations and Round-Off Errors
The error that is produced when a calculator or computer is used to
perform real number calculations is called round-off error.
Numerical round-off errors are directly related to the manner in which
numbers are stored in a computer.
Numbers on the computer are represented with a binary, or base-2,
system.
Real numbers are typically represented in computers using floating-
point form.
Floating point number is stored in computer in following manner: The
first bit is reserved for the sign, the next series of bits for the integer
part,called an exponent or characteristic and the last bits for the
fractional part, called a mantissa or significand.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 2 / 14
In 64-bit (binary digit) representation, the first bit is a sign indicator,
denoted s, followed by an 11-bit exponent, c, and a 52-bit binary
fraction, f . The base for the exponent is 2.
The floating-point number is of the form

(−1)s 2c−1023 (1 + f )

Example
The machine number

0100000000111011100100010000000000000000000000000000000000000000

precisely represents the decimal number

27.56640625

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 3 / 14
The smallest normalized positive number that can be represented has
s = 0, c = 1, and f = 0 and is equivalent to

2−1022 (1 + 0) ≈ 0.22251 × 10−307 ,

and the largest has s = 0, c = 2046, and f = 1−2−52 and is equivalent


to
21023 (2 − 2−52 ) ≈ 0.17977 × 10309 .
Numbers occurring in calculations that have a magnitude less than
2−1022 (1 + 0) result in underflow and are generally set to zero. Num-
bers greater than 21023 (2 − 2−52 ) result in overflow and typically cause
the computations to stop.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 4 / 14
Machine Numbers

Machine numbers are represented in the normalized decimal floating-


point form

±0.d1 d2 . . . dk × 10n , 1 ≤ d1 ≤ 9, and 0 ≤ di ≤ 9,

for each i = 2, . . . , k. Numbers of this form are called k-digit decimal


machine numbers.
Any positive real number can be normalized to the form

y = 0.d1 d2 . . . dk dk+1 dk+2 · · · × 10n .

The floating-point form of y , denoted fl(y ), is obtained by terminating


the mantissa of y at k decimal digits.
There are two common ways of performing this termination.
chopping
rounding

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 5 / 14
chopping: chop off the digits dk+1 dk+2 . . . to produce the floating-
point form
fl(y ) = 0.d1 d2 . . . dk × 10n .
rounding: when dk+1 ≥ 5, add 1 to dk to obtain fl(y ); when dk+1 < 5,
chop off all but the first k digits. Here the floating-point has the form

fl(y ) = 0.δ1 δ2 . . . δk × 10n .

Example
Determine the five-digit (a) chopping and (b) rounding values of the
irrational number π.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 6 / 14
Measuring Errors

Suppose that p∗ is an approximation to p. The absolute error is


p − p∗
|p − p ∗ |, and the relative error is , provided that p 6= 0.
p
The number p∗ is said to approximate p to t significant digits (or
figures) if t is the largest nonnegative integer for which

p − p∗
≤ 5 × 10−t
p

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 7 / 14
Finite-Digit Arithmetic

The arithmetic performed in a computer is not exact.


Assume that the floating-point representations fl(x ) and fl(y ) are given
for the real numbers x and y and that the symbols ⊕, , ⊗, represent
machine addition, subtraction, multiplication, and division operations,
respectively.
x ⊕ y = fl(fl(x ) + fl(y ))
x y = fl(fl(x ) − fl(y ))
x ⊗ y = fl(fl(x ) × fl(y ))
x y = fl(fl(x )/fl(y ))
Accuracy loss due to round-off error can also be reduced by rearranging
calculations.
Example
Evaluate f (x ) = x 3 − 6.1x 2 + 3.2x + 1.5 at x = 4.71 using three-digit
arithmetic.
Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 8 / 14
Loss of Significance error

One of the most common error-producing calculations involves the can-


celation of significant digits due to the subtraction of nearly equal num-
bers.
Consider two numbers p = 3.1415926536 and q = 3.1415957341,
which are nearly equal and both carry 11 decimal digits of precision.
Then, the floating-point form of q − p is 0.30805 × 10−5 .
Since the first 6 digits of p and q are the same, q −p contains 5 decimal
digits of precision. Thus, any further calculations involving q − p retain
the problem of having only 5 digits of significance.
This phenomenon is called loss of significance or subtractive cancella-
tion.
As before, this error can often be avoided by a reformulation of the
calculations.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 9 / 14
Example
The quadratic formula states that the roots of ax 2 + bx + c = 0, when
a 6= 0, are
√ √
−b + b 2 − 4ac −b − b 2 − 4ac
x1 = , x2 =
2a 2a
Consider this formula applied to the equation x 2 + 62.10x + 1 = 0, whose
roots are approximately x1 = −0.01610723 and x2 = −62.08390.
(a) Use quadratic formula and four-digit rounding arithmetic to find the
roots.
(b) Find an equivalent formula for the quadratic formula to avoid loss of
significance.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 10 / 14
Truncation Errors and the Taylor Series

Truncation errors are the errors that result from using approximation
in place of an exact mathematcal procedure.
The mathematical formulation that is used extensively in numerical
methods to approximate functions is the Taylor series.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 11 / 14
Theorem (Taylor’s Theorem)
Suppose f ∈ C n [a, b], that f (n+1) exists on [a, b], and x0 ∈ [a, b]. For
every x ∈ [a, b], there exists a number ξ(x ) between x0 and x with

f (x ) = Pn (x ) + Rn (x ),

where

f 00 (x0 ) f (n)
Pn (x ) = f (x0 ) + f 0 (x0 )(x − x0 ) + (x − x0 )2 + · · · + (x0 )(x − x0 )n
2! n!
n
X f (k) (x0 )
= (x − x0 )k
k=0
k!

and
f (n+1) (ξ(x ))
Rn (x ) = (x − x0 )n+1
(n + 1)!

Here Pn (x ) is called the nth Taylor polynomial for f about x0 , and Rn (x )


is called the remainder term (or truncation error) associated with Pn (x ).
Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 12 / 14
Example
Let f (x ) = cos(x ) and x0 = 0.
(a) Determine the second and third Taylor polynomial for f about x0 .
(b) Approximation cos(0.01).
(c) Determine a bound for the accuracy of the approximation.
Z 0.01
(d) Use third Taylor polynomial to approximate cos(x ) dx and find
0
error bound in this approximation.

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 13 / 14
References

(i) Numerical Analysis, Richard L. Burden, J.Douglas Faires.


(ii) Numerical Methods for Scientific and Engineering Computation, M.K.
Kain, S.R.K. Iyenger, R.K. Jain

Department of Mathematics, UoM Modeling, Computers, and Error Analysis March 2, 2023 14 / 14

You might also like