University of Palestine
Gaza Strip
Civil Engineering College
Numerical analysis
CIVL 3309
Dr. Suhail Lubbad
TextBook
download link
http://s.hbeteam.net/numerical_methods_for_engineers_for_engineers_chapra_canale_6th_edition.pdf
Numerical analysis
CIVL 3309
Formerly CVL 3308
We start from Chapter 5
Lecture Ch5.1: Introduction
+ Ch5.2: Bracketing method: Bisection
The roots of a function
Recall the solution of the function
2
f ,x-=a x *b x*c=0
Could be found by the relation
−b± + b −4 a c
2
x=
2a
Those values of x satisfying the above function are called
ROOTS or ZEROS of the equation
Algebraic basis function y=f(x):
is a function that can be expressed as
n n−1
f y *f
n n−1
y *⋯*f y*f =0
1 0
For some polynomial f of order n
Transcendental (Non-algebraic) Function :
trigonometric, exponential, logarithmic
And other unfamiliar
A transcendental function: an analytic function that does
not satisfy a polynomial equation, in contrast to an algebraic
function,that is, cannot be expressed in terms of a finite
sequence of the algebraic operations of addition,
multiplication, and root extraction.
Roots of algebraic equations could be solved directly
(algebraically)
But
There is no analytic way to solve for the roots of the function
of the form :
−x
f ,x-=e −x
Thus approximation methods are Required
Graphical Methods
Plot the function and obtain approximation solution for the
roots:
Where f(x) crosses the x-axis
Graphic methods are a good rough estimates for the Zeros of
an equation (roots)
But precision is not low
Alternative methods
Trial and error
Guess for the roots and check if f(x)=0
If not right, make a new guess and check
repeat until f(x) is close to zero with the required precision
We consider now studying some adequate systematic methods
Example: the parachutist velocity:
gm
, , -- −c
− t
v= 1−e m
v: velocity (dependent variable)
Independent parameters
t: time, g: gravity constant, c: drag coefficient,
and m: mass
The former function can`t be explicitly expressing the drag
coefficient c as a function of all other parameters !
Try it
To solve the problem numerically,
re-express the equation
subtract the dependent variable v from both sides of
the equation to give
gm
, 1−e - −v
, - −c
− t
0= m
c
This is true if we know the exact value of c.
But c is a measurement value, i.e. we will have many
values from a lab !
A way around
Define a function of c as follows
gm
, , -- −c
− t
f ,c-= 1−e −v
m
c
The value of c that makes f (c) = 0 is therefore the root of the
equation.
This value should be the exact value of c we are looking for.
5.1 Graphical Method
an estimate of the root of the equation f (x) = 0
How? plot the function
observe where it crosses the x axis
EXAMPLE 5.1
t=10, g=9.8, v=40,∧m=68.1
9.8×68.1
, 1−e - −40
−10c
f ,c -= 68.1
c
c f ,c-
4 34.115
8 17.653
12 6.067
16 −2.269
20 − 8.401
Check the function close to c=14.75
Graphical techniques are of a limited practical value
Why? not precise
graphical methods can be utilized to obtain rough estimates of
roots
Starting point to help for numerical methods
graphical interpretations help understanding the properties of
the functions
Help realize whether roots occur or are absent in an interval
[x ,x ]
l u
where x is the lower limit value and
l
x is the upper limit value
u
Check next slide for the benefit of graphing a function
For continuous non-tangential Functions
If f(xl) and f(xu) have opposite signs,
there are an odd number of roots in the interval.
if f(xl) and f(xu) have the same sign,
there are either no roots or an even number of roots
Can anyone explain this using graphs?
Exceptions
Discontinuous or tangential functions
Fig 5.3
Note: Tangential function means multiple root at the point of tangency
Exercise
Example 5.2 in textbook
Use Matlab to Locate Roots
We will come to introducing some skills of matlab and Excel, in
discussion classes, to be used later
THE BISECTION METHOD
binary chopping
if f(x) is real and continuous in the interval from xl to xu and f(xl)
and f(xu) have opposite signs, i.e.,
f(xl) f(xu) < 0
At least one real root between xl and xu .
Locate an interval where the function changes sign
Interval halving, interval is divided in halves for incremental
search method .
Evaluate the function value at the midpoint
Root is then determined at the midpoint of the subinterval
within which the sign change occurs
The process is repeated to obtain refined estimate
Example 5.3
Terminations and Error estimate
An error estimate that is not dependent on foreknowledge of
the root.
an approximate percent relative error εa can be calculated from
∣ ∣
new old
x −x
/=
a
100 %
r
new
r
x r
A true percent relative error εt can be calculated from
∣ ∣
new
x− x
/= t r
100 %
t
x t
Error Estimates for Bisection
Continue Example 5.3 until the approximate error falls
below astopping criterion of es = 0.5%.
(note that the true value of the root is 14.8011)
(note that the first relative approximate error
can't be calculated, why?)
Check this but remember it is only for bisection approach
new x −x old
x −x = u l
r
2 r
and
x *x
new
x = l u
2
r
thus
/=
a
x −x
x *x∣ ∣
×100 %
u
u
l
Recall from last slide, approximate error for first iteration was not done!
But using this new relation in Bisection, we can now calculate it:
εa1 = | (16 – 12)/(16+12)| 100% = 14.29%
This is how one calculates the approximate error for the first round when
using Bisection method
Each succeeding iteration halves the absolute error,
a general formula relating the absolute error and the number
of iterations, n, is
0
n.x
E=a n
2
0 0 0
. x =X −X
u l
“0” means the value at the start
0
.X
Generally
n
E=
a n
2
If Ea,d is the desired absolute error, then the number of
iteration can be computed before we know the ROOT
, -
0
.x
log
E a, d
n=
log , 2-
Example: if the desired error in 5.3 is 6.25% = 0.0625
How may iterations or rounds we will mostly need to perform?
n=
log
, - ,
. x0
Ea , d
=
log
16−12
0.0625
=6
-
log ,2- log ,2-
Next class we explain the so called pseudo code
And explain how to implement it in both Excel and Matlab
That is why in discussions, we will explain the mostly needed
tricks in both Excel and Matlab
Pick up some Exercises from the text book
Recommended, first 5 exercises