Chap1 ERROR

You might also like

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

ERROR

ELECTRONIC LECTURE

Dau The Phiet


HCMUT-OISP

TP. HCM — 2020.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 1 / 21


Approximation-error

ERROR DEFINITIONS

DEFINITION
In a computational model, let assign a be the
approximate value and A be the true value, denote
a ≈ A . We will use a ( instead of A ) in calculations.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 2 / 21


Approximation-error

THE ABSOLUTE ERROR

DEFINITION
Suppose that a is an approximation of A . The
absolute error is ∆a = |a − A|

REMARK
We often cannot find ∆a accurately, instead, we find a
positive number M such that ∆a ≤ M , in other word,
we estimate an upper bound for the absolute error
which give us a “worst-case”.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 3 / 21


Approximation-error

EXAMPLE
We measure the lengths of a bridge and a rivet and
come up with 9999cm and 9 cm , respectively, and
obtain the same absolute error with 0.5cm . The
measurement in which case is more accurate?

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 4 / 21


Approximation-error

RELATIVE ERROR

DEFINITION
∆a
The relative error of an approximation a is δa = .
|A|

The relative error is more meaningful because it


takes into account the size of the value.
In the above formula, the true value A we cannot
find, so we replace A by its approximation a , i.e
∆a
δa =
|a|

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 5 / 21


Approximation-error

REPRESENTATION OF A DECIMAL NUMBER

DEFINITION
Every real number a can be written in the form:
m
d k × 10k
X
a = ±d m d m−1 ...d 1 d 0 .d −1 d −2 ...d −n = ±
k=−n

where dm ∈ {1, ..., 9}, dk ∈ {0, ..9}.


The digits dk , k = −n, ..m are called significant digits
or significant figures of a decimal number.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 6 / 21


Approximation-error

EXAMPLE
How many significant digits each below number has?
1
a = 0.01230
2
a = 2.31200
The trailling zeros ( those to right of the last non-zero
digit ) are significant because they provide the
information about the place that it is precise.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 7 / 21


Approximation-error

ROUNDING DECIMAL NUMBER

DEFINITION
Suppose a is an approximation of a true value A , but
in calculations, we need to replace a by another
number ae which is simpler than a and nearest to a by
cutting some digits after the decimal point from the
right of a . This procedure is called rounding a .

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 8 / 21


Approximation-error

DEFINITION
The error that results from the rounding approximate
value a to ae is called round-off error and denote
θae = |a − a|
e

REMARK
∆ae ≥ ∆a
∆ae ≤ θae + ∆a

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 9 / 21


Approximation-error

ROUNDING FOR EQUALITY

To round a number at k t h place after the decimal


point (digit dk ), look at the (k + 1)t h place digit d k+1 , if
d k+1 < 5, simply drop all digits on the right of
d k (round down), if d k+1 ≥ 5, add d k to 1 and drop all
digits on the right of dk (round up)
EXAMPLE
The number π = 3.14159265359 is rounded to two,
three, four decimal places will be 3.14, 3.142, 3.1416,
respectively

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 10 / 21


Approximation-error

ROUNDING FOR INEQUALITY

For inequalities, the rule of rounding depends on


their direction and specific purpose.
EXAMPLE
For inequality a ≤ 4.5628, rounding to two decimal
places means rounding up ⇒ a ≤ 4.57.
For inequality a > 4.5628, rounding to two decimal
places means rounding down ⇒ a > 4.56

Importance: In calculation of error, the result is


always rounded up

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 11 / 21


Approximation-error

EXAMPLE
The number a = 4.56756 has error δa = 0.56%, find the
absolute error of a . Round the result to four decimal
digits.

EXAMPLE
The number a = 4.56756 has error δa = 0.56%. Round a
to two decimal digits to obtain ae. Find the round-off
error θae

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 12 / 21


Approximation-error

THE REPRESENTATION OF AN APPROXIMATE VALUE IN


NUMERICAL METHOD

A true value A with approx a and absolute error ∆a is


expressed in the form:

A = a ± ∆a

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 13 / 21


Error of function

FUNCTION OF TWO VARIABLES

Consider function u = f (x, y).


1
x is approx value of exact value X . Let ∆x = |X − x|
2
y is approx value of exact value Y . Let ∆ y = |Y − y|
3
u = f (x, y) is approx value of exact value of
U = f (X , Y ).
Find absolute error và relative error of function
u = f (x, y)?

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 14 / 21


Error of function

∆u = |U − u| = | f (X , Y ) − f (x, y)|
¯ ∂u ∂u
¯ ¯
¯
≈ ¯¯ (x, y).∆x + (x, y).∆ y ¯¯
∂x ∂y
¯ ∂u ¯ ∂u
¯ ¯ ¯ ¯
¯ ¯
É ¯¯ (x, y)¯¯ .∆x + ¯¯ (x, y)¯¯ .∆ y
∂x ∂y
Then
¯ ∂u ¯ ∂u
¯ ¯ ¯ ¯
¯ ¯
absolute error of u ≤ ¯¯ (x, y)¯¯ .∆x + ¯¯ (x, y)¯¯ .∆ y
∂x ∂y

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 15 / 21


Error of function

Relative error of u
¯ ∂u ¯ ∂u
¯ ¯ ¯ ¯
¯ ¯
¯ (x, y)¯ .∆x + ¯ (x, y)¯ .∆ y
∆u ¯ ∂x ¯ ¯ ∂y ¯
δu = =
|u| |u|
¯∂ ¯∂
¯ ¯ ¯ ¯
¯ ¯
= ¯¯ ln f (x, y)¯¯ .∆x + ¯¯ ln f (x, y)¯¯ .∆ y
∂x ∂y

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 16 / 21


Error of function

ERROR OF FUNCTIONS OF MULTIVARIABLES

Given continous differential function of


multivariables y = f (x 1 , x 2 , . . . , x n ) and absolute errors
∆xi of variables x i (i = 1..n). Let X i , Y và x i , y (i = 1..n)
are the true and approx values of function and
variables , respectively. Then

|Y − y| = | f (X 1 , X 2 , . . . , X n ) − f (x 1 , x 2 , . . . , x n )|
n ¯
∂ n ¯

¯ ¯ ¯ ¯
X f ¯
¯ .|X i − x i | É ¯
X f ¯
¯ .∆x .
É ¯¯
∂x
i =1
¯
i
¯ ∂x ¯ i
i =1 i

n ¯ ∂f ¯
¯ ¯
So absolute error of y É ¯¯
P ¯ .∆x
i =1 ∂x i
¯ i
Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 17 / 21
Error of function

Relative error of y
n ¯ ∂f ¯
¯ ¯
P ¯ .∆
∆ y i =1 ¯ ∂x i ¯ xi
¯
δy = =
|y| |f |
X¯ ∂
n
¯ ¯
¯
= ¯¯ ln f (x 1 , x 2 , . . . , x n )¯¯ .∆xi
i =1 ∂x i

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 18 / 21


Error of function

EXAMPLE
Find the absolute and relative error for volume
1
V = πd 3 of a sphere whose diameter is
6
d = 3.70cm ± 0.05cm and π = 3.14 ± 0.0016.

EXAMPLE
Find absolute and relative error of y = a − b + c with
a = −47.132 ± 0.003; b = 47.111 ± 0.02; c = 45.234 ± 0.5.

EXAMPLE
Given f (x, y) = x 2 − x y + y 2 , where x = 2.3 ± 0.0056,
y = 0.45 ± 0.0012. Estimate the absolute and relative
error of f .
Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 19 / 21
Error of function

EXAMPLE
Given f = abc , where a = 2.3 ± 0.035, b = −3.4 ± 0.0231,
c = 4.5 ± 0.0023. Find absolute and relative error of f .
Rounding to four decimal digits.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 20 / 21


Error of function

DEFINITION
An algorithm is a procedure which describes a finite
sequence steps to approximate a solution to a given
problem.

DEFINITION
Suppose we use algorithm (A) to build an
approximate sequence of solutions x n , if x n → x ,
where x is the exact solution of the problem, then we
say that the algorithm (A) converges.

Dau The Phiet (BK TPHCM) ERROR TP. HCM — 2020. 21 / 21

You might also like