Sie sind auf Seite 1von 46

Numerical Methods

Lecture 1

Engr. Gerard Francesco DG. Apolinario


EE Department

Definition: Numerical Analysis

Numerical Analysis is concerned with the


Mathematical derivation, description and analysis of
methods of obtaining numerical solution of Mathematical
problems, many computed problem (Math., Stat., Physics,
) can not be solved, but we can solved by numerical
analysis.

Definition: Errors
One of the most important aspects
of numerical analysis is the error analysis.
Errors may occur at any stage of the
process of solving a problem.
By the error we mean the
difference between the true value and the

Types of Errors
Usually we come across the following types of errors in numerical
analysis:
i. Inherent Errors.
These are the errors involved in the statement of a problem. When the
problem is first presented to the numerical analysis it may contain
certain data or parameters.
ii.

Analytic Error.
These are the errors introduced due to transforming a physical or
mathematical problem into a computational problem.

iii. Rounding and Chopping Errors


The most widely and important errors caused by applying numerical
methods is Error caused by chopping and rounding:
For example
1.
1/3=0.3333
2.
e= 2.718
3.
1.0000

where 1/3=0.333333.
where e=2.7182818.
where 0.99995

iv. Formulation Errors


When solving the problem using mathematical method,
usually a simple model would be used to describe the
source problem, there for some of the factors will be put
away which means simplifying the problems which cause
some error and this error is called Formulation Error.
Force Mass
For example.
Acceleration
the second law Newton F= m.a
where m is a mass of a particle, a is acceleration
In the fact
m0 is initial mass of particle
V is velocity
C is velocity of light
since V < C so V/C
0
and m=m0

iv. Absolute Errors


The absolute error of an approximate number x is the absolute value
of the difference between the corresponding exact number X and the
number x. It denoted by Ex thus:
Ex= |X-x|
v. Relative Errors
The relative error of an approximate number x is the ratio of the
absolute error the number to the absolute value of the corresponding the
exact number X. Where X0, it is denoted by ER.
ER=Ex / |X|.
Define Truncation Errors ?
vi. Error in Arithmetic Operations:
a. Addition Operations:

Ex+y=Ex+Ey
b. Subtraction Operations:
Ex-y=Ex-Ey
c. Multiplication Operations:
d. Deviation Operations:

Locating the Position of Roots

Let f(x) be a continuous function on the interval


[a, b], to locate the position of roots of the
function f ( x) 0 , we divide the interval [a, b] into
n subintervals as:
a x0 x1 x 2 ... x n b
xi x0 i h , i 0,1, 2, ..., n

where
and we must start with an initial interval [a, b],
where f (a) and f (b) have opposite signs, then
there exists c [a, b] which f (c) 0 .

Exercises: Find the approximate interval of the root of the following


function:
1 f ( x) x 3 4 x 1
2 f ( x) 1 e x
3 f ( x) ln( x) x 5
4 f ( x) e x 3 x

Bisection Method

Basis of Bisection Method


Theorem

An equation f(x)=0, where f(x) is a real continuous


function, has at least one root between xl and xu if f(xl)
f(xu) < f(x)
0.

x
xu

Figure 1 At least one root exists between the two points if the
function is real, continuous, and changes sign.

Basis of Bisection Method


f(x)

xu

Figure 2 If functionf x does not change sign between two points,


f x 0
roots of the equation
may still exist between the two
points.

Basis of Bisection Method


f(x)

f(x)

xu

xu
x

Figure 3 If the functionf x does not change sign between two


f x 0
points, there may not be any roots for the equation
between
the two points.

Basis of Bisection Method


f(x)

xu

f x
Figure 4 If the function
changes sign between two points,
more than one root for the equation
may exist between
f x 0
the two points.

Algorithm for Bisection


Method

14

Step 1
Choose xl and xu as two guesses for the root such
that f(xl) f(xu) < 0, or in other words, f(x) changes
sign between xl and xu. This was demonstrated in
f(x)
Figure 1.

x
xu

Figure 1

Step 2
Estimate the root, xm of the equation f (x) = 0 as the
mid point between xl and xu as
f(x)

x xu
xm =
2
x

xm
xu

Figure 5 Estimate of xm

Step 3
Now check the following
a) If f xl f xm ,0then the root lies between x l and
xm; then xl = xl ; xu = xm.

f xl f xm 0
b) If
, then the root lies between x m and
xu; then xl = xm; xu = xu.
f xl f xm 0
c) If
; then the root is x m. Stop the
algorithm if this is true.

Step 4

Find the new estimate of the root


x xu
xm =
2

Find the absolute relative approximate error


a

old
x new

x
m
m

new
m

100

where
xmold previous estimate of root
xmnew current estimate of root

Step 5

Compare the absolute relative approximate error


a
with the pre-specified errortolerance
.
s
Yes

Go to Step 2 using
new upper and lower
guesses.

No

Stop the algorithm

Is a s ?

Note one should also check whether the number


of iterations is more than the maximum number of
iterations allowed. If so, one needs to terminate
the algorithm and notify the user about it.

Example 1
You are working for DOWN THE TOILET COMPANY
that makes floats for ABC commodes. The floating
ball has a specific gravity of 0.6 and has a radius of
5.5 cm. You are asked to find the depth to which the
ball is submerged when floating in water.

Figure 6 Diagram of the floating ball

Example 1 Cont.
The equation that gives the depth x to which the ball
is submerged under water is given by
x 3 0.165 x 2 3.993 10 4 0

a) Use the bisection method of finding roots of


equations to find the depth x to which the ball is
submerged under water. Conduct three iterations to
estimate the root of the above equation.
b) Find the absolute relative approximate error at the
end of each iteration, and the number of significant
digits at least correct at the end of each iteration.

Example 1 Cont.

From the physics of the problem, the ball would be


submerged between x = 0 and x = 2R,
where R = radius of the ball,
that is
0 x 2R

0 x 2 0.055
0 x 0.11

Figure 6 Diagram of the floating ball

Example 1 Cont.

Solution

To aid in the
understanding of how
this method works to find
the root of an equation,
the graph of f(x) is shown
to the right,

x x 3 0.165 x 2 3.993 10- 4


fwhere
Figure 7 Graph of the function f(x)

Example 1 Cont.

Let us assume

x 0.00
xu 0.11
Check if the function changes sign between xl
and xu .
3
2
4

f xl f 0 0 0.165 0 3.993 10 3.993 10 4


f xu f 0.11 0.11 0.165 0.11 3.993 10 4 2.662 10 4
3

Hence

f xl f xu f 0 f 0.11 3.993 10 4 2.662 10 4 0

So there is at least on root between xl and xu, that is between 0


and 0.11

Example 1 Cont.

Figure 8 Graph demonstrating sign change between


initial limits

Example 1 Cont.

Iteration 1
The estimate of the root isxm

x xu 0 0.11

0.055
2
2

f xm f 0.055 0.055 0.165 0.055 3.993 10 4 6.655 10 5


3

f xl f xm f 0 f 0.055 3.993 10 4 6.655 10 5 0

Hence the root is bracketed between xm and xu, that is,


between 0.055 and 0.11. So, the lower and upper limits of the
new bracket
are , x 0.11
x 0.055
l

At this point, the absolute relative approximate error


cannot be calculated as we do not have a previous
approximation.

Example 1 Cont.

Figure 9 Estimate of the root for Iteration 1

Example 1 Cont.

Iteration 2
xm
The estimate of the root is

x xu 0.055 0.11

0.0825
2
2

f x m f 0.0825 0.0825 0.165 0.0825 3.993 10 4 1.622 10 4


3

f xl f x m f 0.055 f (0.0825) 1.622 10 4 6.655 10 5 0

Hence the root is bracketed between xl and xm, that is,


between 0.055 and 0.0825. So, the lower and upper limits of
the new
x bracket
0.055, xare 0.0825
l

Example 1 Cont.

Figure 10 Estimate of the root for Iteration 2

Example 1 Cont.

The absolute relative approximate error


a
Iteration 2 is

at the end of

xmnew xmold
a
100
new
xm

0.0825 0.055
100
0.0825
33.333%

None of the significant digits are at least correct in the estimate


root of xm = 0.0825 because the absolute relative approximate
error is greater than 5%.

Example 1 Cont.

x xu 0.055 0.0825

0.06875
2
2

Iteration 3
The estimate of the root xism

f xm f 0.06875 0.06875 0.165 0.06875 3.993 10 4 5.563 10 5


3

f xl f xm f 0.055 f 0.06875 6.655 10 5 5.563 10 5 0

Hence the root is bracketed between xl and xm, that is,


between 0.055 and 0.06875. So, the lower and upper limits of
the new
x bracket
0.055, xare
0.06875
l

Example 1 Cont.

Figure 11 Estimate of the root for Iteration 3

Example 1 Cont.
The absolute relative approximate error
a
Iteration 3 is

at the end of

xmnew xmold
a
100
new
xm

0.06875 0.0825

100
0.06875
20%
Still none of the significant digits are at least correct in the
estimated root of the equation as the absolute relative
approximate error is greater than 5%.
Seven more iterations were conducted and these iterations are
shown in Table 1.

Table 1 Cont.
Table 1 Root of f(x)=0 as function of number of iterations for
bisection method.

Table 1 Cont.
Hence the number of significant digits at least correct is given
by the largest value or m for which

a 0.5 10 2 m
0.1721 0.5 10 2 m
0.3442 10 2 m

log 0.3442 2 m

m 2 log 0.3442 2.463

So

m2

The number of significant digits at least correct in the


estimated root of 0.06241 at the end of the 10th iteration is 2.

Advantages

Always convergent
The root bracket gets halved with each
iteration - guaranteed.

Drawbacks

Slow convergence
If one of the initial guesses is close to
the root, the convergence is slower

Drawbacks (continued)

If a function f(x) is such that it just


touches the x-axis it will be unable to find
the lower and upper guesses.
f(x)

f x x
x

Drawbacks (continued)

Function changes sign but root does


not exist
f(x)

1
f x
x
x

Examples: Using Bisection method to find the root of the following


equations:

Regula-Falsi Method

Regula-Falsi Method
Type of Algorithm (Equation Solver)
The Regula-Falsi Method (sometimes called the False Position Method) is a
method used to find a numerical estimate of an equation.
This method attempts to solve an equation of the form f(x)=0. (This is very
common in most numerical analysis applications.) Any equation can be written in
this form.
Algorithm Requirements
This algorithm requires a function f(x) and two points a and b for which f(x) is
positive for one of the values and negative for the other. We can write this
condition as f(a)f(b)<0.
If the function f(x) is continuous on the interval [a,b] with f(a)f(b)<0, the algorithm
will eventually converge to a solution.
This algorithm can not be implemented to find a tangential root. That is a root
that is tangent to the x-axis and either positive or negative on both side of the root.
For example f(x)=(x-3)2, has a tangential root at x=3.

Regula-Falsi Algorithm
The idea for the Regula-Falsi method is to connect the points (a,f(a)) and (b,f(b))
with a straight line.
Since linear equations are the simplest equations to solve for find the regulafalsi point (xrfp) which is the solution to the linear equation connecting the
endpoints.
Look at the sign of f(xrfp):
If sign(f(xrfp)) = 0

equation of line:

then end algorithm

else If sign(f(xrfp)) = sign(f(a)) then set a = xrfp

y f (a)

else set b = xrfp

f (b) f (a )
x a
ba

solving for xrfp


f(b)
f(x)
xrfp
a
f(a)

f (b) f (a )
xrfp a
ba
f ( a ) b a
xrfp a
f (b) f (a )
f ( a ) b a
xrfp a
f (b) f (a )

0 f (a)
x-axis
actual root

Example
Lets look for a solution to the equation x3-2x-3=0.
We consider the function f(x)=x3-2x-3
On the interval [0,2] the function is negative at 0 and positive at 2. This means
that a=0 and b=2 (i.e. f(0)f(2)=(-3)(1)=-3<0, this means we can apply the
algorithm).

xrfp

f ( 0) 2 0
3(2)
6 3
0

f ( 2) f ( 0)
1 3
4
2

3 21
f ( xrfp ) f
8
2
xrfp

This is negative and we will make the a =3/2


and b is the same and apply the same thing
to the interval [3/2,2].

3 f 32 2 32 3 821 12 3 21 54


3
21
2 f ( 2) f 2 2 1 8
2 58 29

54
f ( xrfp ) f
0.267785
29

This is negative and we will make the a =54/29


and b is the same and apply the same thing to
the interval [54/29,2].

Stopping Conditions
Aside from lucking out and actually hitting the root, the stopping condition is
usually fixed to be a certain number of iterations or for the Standard Cauchy Error
in computing the Regula-Falsi Point (xrfp) to not change more than a prescribed
amount (usually denoted ).

Examples: Find the approximate value of the following:

1
2
3
4
5

x3 4x 1 0

where 0.001

e x 3x 0
x cos( x) 0
x tan( x) 1
f ( x) log( x) x 5

Das könnte Ihnen auch gefallen