You are on page 1of 30

Galat dalam Metode

Numerik

Kuliah 2 Metode Numerik 1


Computational Errors
• The computational error comes from:
– Machine representation
• Number representation
• Round off errors
– Rounding
– Chopping
– Rounding up
– Rounding down
– Formula for the problem
• Truncation error
Kuliah 2 Metode Numerik 2
Computational Errors
• Roundoff errors
– finite precision numbers present infinite
precision numbers
0 ∞
-∞
real number
– The result of an operation on two
machine-representable numbers is not
necessarily a machine-representable
number.

Kuliah 2 Metode Numerik 3


Computational Errors11 digits
e.g. : a = 9.99*104 and b = 9.99*10-4
a + b = (9.99+9.99*10-8)*104 =9.9900000999*104.
Suppose the machine only computes to 6-
digits.Then, The reason will be
a + b = 9.99*104 discussed later

=> b has no effect !! (why ?)


However,
a/b = 10 8 6-digit representation is
OK with the result

a*b = 99.8001 are still valid (why ?)


Kuliah 2 Metode Numerik 4
Computational Errors
• Truncation error
– Occurs when applying a formula

Truncation error

Kuliah 2 Metode Numerik 5


Taylor Theorem

Please review how to


calculate the derivatives
for some common functions
e.g. ex, sinx, logx

Kuliah 2 Metode Numerik 6


Taylor Theorem
• Pn(x) is the nth Taylor polynomial for f
about x0
• Rn(x) is the remainder term (or
truncation error) associated with Pn(x).
• The infinite series obtained by taking n
∞ is called the Taylor series for x
about x0
• When x0 = 0, the Taylor polynomial is
often called a Maclaurin polynomial and
the Taylor series is called a Maclaurin
series. Kuliah 2 Metode Numerik 7
Taylor Theorem -
Example
• Determine (a) the second and (b) the
third Taylor polynomials for f(x) =
cosx about x0 = 0 and use these
polynomials to approximate cos(0.01)
• (a)

Kuliah 2 Metode Numerik 8


Taylor Theorem -
Example

(b) exercise.
Kuliah 2 Metode Numerik 9
Computational Errors
approximation of derivative of function f.
Let f be a function. Obtain the derivative
at a where f is cont. on [a-h, a+h].

Kuliah 2 Metode Numerik 10


Computational Errors

Kuliah 2 Metode Numerik 11


actual f ’(a)

approximate f ’(a)

a-h a a+h

Kuliah 2 Metode Numerik 12


Computational Errors
• The more terms use to estimate, the
more accurate the answer is

Kuliah 2 Metode Numerik 13


Computational Errors
• Absolute v.s. relative errors
– If P* is an approximation to P,
• |P*-P| is the absolute error.
• | P*-P |/|P| where |P|≠0 is the relative error.
• Error tolerance
– A computation is acceptable if the error
(absolute or relative) is no more than a
specific error tolerance.
– |computed solution – exact solution| <
tolerance
i.e. | P*-P | < tol or |P*-P|/|P| < tol. 14
Kuliah 2 Metode Numerik
Computational Errors
– Error tolerances should be part of the
specifications of an algorithm.
– High accuracy usually needs high cost!
• Accuracy
– appr.

Kuliah 2 Metode Numerik 15


Computational Errors
– The number of decimal places of accuracy, d,
for fixed error, |error| = 10-d is given by d =
-log10|error|, i.e. the approximation has d
accurate decimal places.
– example

Kuliah 2 Metode Numerik 16


Computational Errors

Kuliah 2 Metode Numerik 17


Computational Errors
– example

Kuliah 2 Metode Numerik 18


Error Propagation
• Error Propagation (overall)

Kuliah 2 Metode Numerik 19


Error Propagation

Kuliah 2 Metode Numerik 20


Error Propagation
• The sensitivity of a problem is
indicated by the relative dependence
of output error to input error.
• Definition:

Kuliah 2 Metode Numerik 23


Error Propagation in Basic
Arithmetic Operations
• Error Propagation in Arithmetic
Operations

Kuliah 2 Metode Numerik 24


Error Propagation in Basic
Arithmetic Operations

Kuliah 2 Metode Numerik 25


Error Propagation in Basic
Arithmetic Operations

(1+x)-1 = 1-x+x2+…

Kuliah 2 Metode Numerik 26


Error Propagation in Basic
Arithmetic Operations
• Avoiding cancellation errors
– Rationalization
– Taylor expansion
(two nearly equal numbers)

Kuliah 2 Metode Numerik 27


Error Propagation in Basic
Arithmetic Operations
– Rationalization

Kuliah 2 Metode Numerik 28


Error Propagation in Basic
Arithmetic Operations

Kuliah 2 Metode Numerik 29


Error Propagation in Basic
Arithmetic Operations
– Taylor expansion

Kuliah 2 Metode Numerik 30


Error Propagation in Basic
Arithmetic Operations

Kuliah 2 Metode Numerik 31


Error Propagation in Basic
Arithmetic Operations
• Cancellation error

Kuliah 2 Metode Numerik 32

You might also like