Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Numerical Methods - Chapter Two

Uploaded by

Abdulaziz Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Numerical Methods - Chapter Two

Uploaded by

Abdulaziz Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Chapter Two

Roots of Nonlinear Equations in One Variable

By Belete A.

፳፻፲፬ ዓ.ም 1
• Contents of lecture:
I. Algebraic method
II. Graphic method
III. Numerical method it consist
1. Bracketing method includes
1. Bisection & False position.
2. Open method includes
1. Fixed point, Newton Raphson & Secant

2
Introduction
• Equations need to be solved in all areas of science and engineering in the form
of f (x) = 0 are said to be non-linear where the degree of the equation is greater
than one (variable change b/n two entities)
• The solutions (values of x) are known as the roots of the equation f (x) = 0, or the
zeroes of the function f (x).
 This is generally said to be Solving non-linear Equations.

Fig: Illustration of equations with no, one, or several solutions.


3
Algebraic method
• This method is solving the equations that are in the form of
ax2 +bx +c=0 or that can be reduced to this form easily.
To solve f ( x )  ax 2  bx  c  0,
it is clear that we use quadratic equation soln method.
E.g. find the root of f(x)=2x2+6x+4=0

• The quadratic formula is Algorithm for solving for the real roots of a quadratic
equation.
• There are many other functions for which the root cannot be determined so
easily. For this cases, the graphical or numerical methods provide efficient to
obtain the answer.
4
Graphical method
• A simple method for obtaining an estimate of the root of the equation f (x)=0 is to make a
plot of the function and observe where it crosses the x-axis.
Example: Obtain an initial By plotting the graph f (x) Vs X on an Excel we can estimate the
approximation to a root of the crossing point
Equation f(x)=cos x – x ex =0

From the graph we can approximate


From the table we find that the function f (x)=
the crossing point between 0.4 – 0.6
0 has at least one root in the interval (0.5 -1). 5
While the exact root is 0.517757363
Numerical Methods
• The root of non linear equation in one variable can be solved by two broad
methods. These are:
1. Bracketing method includes
a. Bisection
b. False position.
• Bracketing methods: is based on the fact that a function typically changes sign in
the vicinity of a root. Require two starting values of Xl and Xu values that
necessarily bracket the root.
• Open Methods: require only a single starting values of X or two values that do
not necessarily bracket the root.

6
Bisection Method
• The basic algorithm for the bisection method relies on repeated application
of the intermediate value theorem.
• If f (x) is a continuous function on some interval [a,b] and f(a)*f(b) < 0, then
the equation f(x) = 0; has at least one real root or an odd number of roots in
the interval [a,b].
i.e. Given the interval (a, b) in which solution exists:
Then : c = (a + b)/2,
if f(c)= 0, then c is an exact solution,
else if f(a)*f(c) < 0 then the root lies in the interval (a, c), else the root lies in
the interval (c, b).

7
Steps For Bisection Method
• 1. Choose xl and xu as two guesses for the root
such that f(xl) f(xu) < 0
2. Estimate the root, xm of the equation f (x) = 0 as
the mid-point between xl and xu as:

3. Now check the following


If f(xl) f(xm) < 0, then the root lies between xl and xm; then xl = xl ; xu = xm.
If f(xl) f(xm) > 0, then the root lies between xm and xu; then xl = xm ; xu = xu
If f(xl) f(xm) = 0; then the root is xm. Stop the step if this is true.

8
Cont..
• 4. New estimate:

Approximate relative Error:

9
Advantage
• Always convergent.
• The root bracket gets halved with each iteration – error minimization is
guaranteed.
• Possible to estimate the number of iteration required.

10
Disadvantage
• 1. Slow convergence; If one of the initial guesses is close to
the root.
Multiple roots in an interval [a1, b1] if f(a1)f(b1)<0

2. 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.

3. Function changes sign but


root does not exist

11
Example 1
• Determine the drag coefficient c (by using Bisection Method) needed for a
parachutist of mass m = 68.1 kg to have a velocity of 40 m/s after free-falling for
time t = 10 s. Note: The acceleration due to gravity is 9.8 m/s2. until the
approximate error falls below a stopping criterion of ε = 0.5%. Use Newton’s
s

second law formula that helps to predict the parachutist’s velocity:


• Solution: Iteration 1
• Step 1: The first step in bisection is to guess two values of the unknown that give
values for f(c) with different signs. The function changes sign between values of
12 and 16 (i.e. xl = 12 and xu = 16).
So, f(xl) * f(xu) < 0. You can check it.

12
Cont..
• Step-2: Estimate the root (xr):
• Since the is no previous value xr in the first iteration, you can skipped ɛa
computation for first iteration.
• Step-3: Evaluate in which subinterval the root lies for the second iteration by
checking the following condition.
Is f(xr) * f(xl) > 0 ?, < 0 ? Or = 0?
• So, the function value at the lower bound and at the midpoint:
f(12) *f(14) = 6.067(1.569) = 9.517, > 0 so, the root lies in the upper
subinterval.
Set xl = xr = 14 for the next iteration to find new estimate of the root (xr).

13
Cont..
• Iteration 2
• Step 2;
• Now let us compute approximate percent relative error (ɛa ) as;

• checking the following condition.


Is f(xr) * f(xl) > 0 ?, < 0 ? Or = 0?
• f(14) f(15) = 1.569(-0.425) = -0.666, so the root lies in the lower subintervals. As a result
The upper bound is redefined as xu = xr = 15
Iteration 3
• Calculate by yourself

14
Cont..
• Summarized results

• After six iterations ɛa finally falls below ɛs = 0.5%, and the computation can be
terminated.
• Therefore the root is: xr = 14.8125 with an approximate error (ɛa) of 0.422%

15
False position
• This method is similar to the bisection method in that requires two initial guesses
values. However, instead of simply dividing the region in two, a linear
interpolation is used to obtain a new point which is (hopefully, but not
necessarily) closer to the root than the equivalent estimate for the bisection
method.
If a real root is bounded by xl and xu of f(x)=0, then we can approximate the
solution by doing a linear interpolation between the points [xl, f(xl)] and [xu, f(xu)]
to find the xr value such that f(xr)=0, f(x) is the linear approximation of f(x).

16
Cont..
• An alternative method that exploits this graphical insight is to join f(Xl) and f(Xu)
by a straight line. The intersection of this line with the x-axis is represents an
improved estimate of the root.
• The fact that the replacement of the curve by a straight line gives a “false
position” of the root is the origin of the name.

17
Cont..
• The procedure is similar to the Bisection method; the only difference is the method
used for calculating the root (Xm)

1. Find a pair of values of x, xl and xu such that fl=f(xl)<0 and fu=f(xu) >0.
2. Estimate the value of the root from the following formula given and evaluate
f(xr) ~~0

or

18
Cont..
• 3. Use the new point to replace one of the original points, keeping the two
points on opposite sides of the x axis.
If f(xr)<0 then xl=xr == > fl=f(xr)
If f(xr)>0 then xu=xr == > fu=f(xr)
If f(xr)=0 then you have found the root and do not need to go further!

4. See if the new xl and xu are close enough for convergence to be declared. If they
are not go back to step 2.

Eg1. f(x)=6x2+12x-30=0, Eg2. 2-x+lnx=0, find at least one root?

19
Cont..
• Why bracketing method?
– Faster
– Always converges for a single root.
• Note: Always check by substituting estimated root in the original equation to
determine whether f(xr) ≈ 0. Otherwise, the relative error can miss-lead us.
• Generally In the bracketing method:
 the root is located within an interval prescribed by a lower and an upper
bound.
 Repeated application of these methods always results in closer estimates of the
true value of the root.
 Such methods are said to be convergent, because they move closer to the truth
as the computation progresses. 20
Example
• Solve Example-1 by False-position method and compute an approximate percent
relative error ɛa. Continue the iterations until the approximate error falls below a
stopping criterion of ɛs = 1%. initiate the computation with guesses of x = 12 and x
l u

= 16.
• Solution; Iterative 1: step 2;

• Iterative 2 ; check f(xl) f(xr) <0; f(xl) f(xr) = -1.5426


the root lies in the first subinterval, and xr becomes the upper limit for the next
iteration, xu = 14.9113:

21
Cont..
• approximate relative errors; =0.79%
Here | ɛa | < ɛs = 1%

22
Open method
Basic Concepts in open methods
• Open methods:
 are based on formulas that require only a single starting values of X or two values
that do not necessarily bracket the root.
As such, they sometimes diverge.
When the open methods converge, they usually do so much more quickly than the
bracketing methods.
• Types of the method:
Fixed-point, Newton-Raphson Method and The Secant Method

23
Fixed-point Iteration
 Fixed-point iteration (one-point iteration or successive substitution) rearrange the
function f(x)=0 so that x is on the left-hand side of the equation like:
x = g(x)
Algebraic manipulation or simply adding x to both sides of the original equation.
Given an initial guess at the root xi, then x = g(x) can be used to compute a new
estimate xi+1 as expressed by the iterative formula
xi+1 = g(xi)
e.g solve f(x) =2-x+lnx=0,
Solution: X0=0, f(0)=2
hint x=2+lnx X1=2, f(2)=2.693
X2=2.693, f(2.693)=2.991
X3=2.991, f(2.991)= 3.096
ᵋa= (3.096-2.991)*100/3.096 =3.4% 24
Newton-Raphson Method
• Newton Raphson method is the Most widely used method.
Based on Taylor series expansion: Is convenient method for functions whose
derivatives can be evaluated analytically.

25
Cont..
• Geometrically, Xi+1 can be interpreted as the value of X at which a line, passing through
the point (Xn,f(Xn)) and tangent to the curve f(x) at that point, crosses the y axis.
• If we continue the process we get the following scheme

26
Cont..
• Iterative formula can be generalized as:

27
Cont..
• Termination Criteria & Error Estimates

 Is as small number as 10-3 or 10-6


• Requires derivative of the function: f’= df/dx
• Very fast convergence in most cases (Quadratic convergence) !!
• May not converge if the estimate is far off.
• May not converge if the derivative (slope) at an estimate is close to zero. 28
Newton Rapson Method
•• Requires derivative of the function: f’= df/dx

• Very fast convergence in most cases (Quadratic convergence) !!

• May not converge if the estimate is far off.

• May not converge if the derivative (slope) at an estimate is close to zero.

29
Cont..
• If the local min/max is selected as an initial guess,

30
Example
• Use the Newton-Raphson method to estimate the root of f(x) = e-x - x, employing
an initial guess of x0 = 0.
Solution. The first derivative of the function can be evaluated as

Starting with an initial guess of x0 = 0, this


iterative equation can be applied to compute

31
The Secant Method
• A potential problem implementing the Newton – Raphson method is the

evaluation of the derivative.

For these cases the derivative can be approximated by a backward finite


divided difference.

The first derivative of the function f can be approximated using the finite
difference method(FDM).

32
Cont..
• Substituting this approximation in the Newton – Raphson formula, to yield the
following iterative equation.

f ( xi ) xi  xi 1
xi 1  xi  '  xi  f ( xi )( ), xi  2,3, 4,...
f ( xi ) f ( xi )  f ( xi 1 )
 Requires two initial estimates of x; like: x0, x1.
 Because f(x) is not required to change signs between estimates, it is not
classified as a “bracketing” method.
 Has the same properties as Newton’s method and
 Convergence is not guaranteed for all x0, f(x). 33
Cont..

Convergence of the root using the secant method to exact root

34
e.g. solve f(x) =2-x+lnx, hint xi-1 =0 & x=3
Cont..
• Advantages of secant method:
• It converges at faster than a linear rate, so that it is more rapidly convergent than
the bisection method.
• It does not require use of the derivative of the function, something that is not
available in a number of applications.
• It requires only one function evaluation per iteration, as compared with
Newton’s method which requires two.
Disadvantages of secant method:

• It may not converge.


• There is no guaranteed error bound for the computed iterates.
• It is likely to have difficulty if f ‘(α) = 0. This means the x-axis is tangent to the
graph of y = f (x) at x = α. 35
Example
• Use the secant method to estimate the root of f(x) = e-x- x. Start with initial
estimates of x-1 = 0 and x0 = 1.0. Take Ɛs = 1%
• Solution. Recall that the true root is 0.56714329.

36

You might also like