EE103 Lecture Notes, Winter 2009, Prof S.E. Jacobsen
Section 1
1
SECTION 1: INTRODUCTION
This section contains several examples that demonstrate a few issues that arise in the area
of engineering and scientific computing.
Motivation Example 1
1
:
We are all familiar with the quadratic formula for finding the roots of the quadratic
equation,
2
ax
bx
c
0,a
0
++
=
≠
.
Of course, the two roots are given by the expression
2
b
b4
a
c
2a
−±
−
.
Leta
1, b
62.1, c
1
==
=
.
The roots of the equation
2
62.1
1
0
xx
+
+=
are, approximately (to seven decimal places),
12
r =-0.0161072 and r
-62.0838928
=
.
Now, assume we have a finite precision machine (computer, calculators, etc.) that only
can provide "four digit arithmetic" (to be defined later) to compute the two roots.
Of
course, we'd hope that the answers would be close to the two roots given above,
expressed in "four digit arithmetic".
That is, we'd like the answers to be close to
1
r
0.01611
=
and
2
r
62.08
= −
.
Now, using only four digit arithmetic, we compute
22
b
4ac
(62.1)
4.0 = 3856-4.0
3852
62.06
−=
−
=
=
.
We'll use the notation
1
fl(r ) , for the four digit approximation to the root
1
r , to emphasize
the fact that the answer is an approximation ("fl" stands for "floating point").
We then
have that
1
fl(r )
(
62.1 62.06)/2
0.02
=−
+
.
Therefore, the
absolute
error is given
by
11
|fl(r )
r|
| 0.02
0.01611|
0.00389
−
+
=
, but the
relative
or
percentage
error, using
four digit arithmetic, is given by
1
1
|fl(r )
0.00389
2.4x10
|r|
0.01611
−
−
=≈
.
That is, the
percentage error
is approximately 24%, an error that is clearly unacceptable.
However, note that we may write