2-Graphical and Bisection Method-22!07!2022

You might also like

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

CHE3001 Computational Methods in

Process Engineering

Instructor: Dr. Rima Biswas


School of Chemical Engineering (SCHEME)
VIT University Vellore
Date: 3 Feb 2021

1
Nonlinear algebraic Equations

What is non-linear equation?


An equation in which one or more terms have a variable of degree
2 or higher is called a nonlinear equation. A nonlinear system of
equations contains at least one nonlinear equation.
Non linear equation can be solved in these ways-
1. Bisection method
2. False position method.
3. Newton Raphson method.
4. Secant method.
Roots of a equation
o Roots Cannot be obtained by direct methods
• e.g. f(x)= e-x-x
o Alternative methods
• Graphical methods Roots of the equation may be
either real or complex
• Trial and error methods
o Type of functions in root finding

• Algebraic
• e.g. Polynomials are simple class of algebraic functions

• Transcendental – non algebraic functions, which includes trigonometric, exponential, logarithmic and less
familiar functions
• e.g. ,

3
Finding roots of quadratic equation
Solve x2 – 3x – 4 = 0 Solve x2 – 4 = 0

For a Quadratic equation of ax2 + bx + c, the solution or the roots of the equation is

4
Graphical solutions

Graphical solution of x2 – 3x – 4 = 0 Graphical solution of x2 – 4 = 0

Trial and error Method: 0, +1, -1 +2, -2, +3, -3, +4, -4, +5, -5……

5
Example – Quadratic equation
A brick is thrown from a top of a building at a speed of 25 m/s and the building is
150 m height. Derive an equation to find the time at which the brick reaches the
ground
Solution: The distance covered by the brick is given by

So the above expression becomes

9.81
150 = 25𝑡 + 𝑡
2

This is of the form


150
ax2 + bx + c

6
Bisection Method
• The Bisection method in mathematics is a root finding method which repeatedly bisects an interval and then
selects a subinterval in which a root must lie for further processing.

• Bracketing - Two initial guesses are required


• Bisection Method (also named as interval halving, binary chopping, Bolzano’s Method)

• An equation f(x) =0
f (x)
Theorem

If function f(x) is a real and


continuous between the interval xl
and xu

 If f(xl) and f(xu) have opposite


sign i.e. if f(xl) f(xu) < 0 - there is xℓ
x
atleast one real root between xl xu
and xu

7
f (x)
Theorem
If function f(x) is a real and continuous
between the interval xl and xu

 If f(xl) and f(xu) does not change sign


between two points i.e. if f(xl) f(xu) > 0 ,
roots of the equation f(x) = 0 may still x
xℓ xu
exist between the two points

Theorem
If function f(x) is a real and continuous
between the interval xl and xu

 If f(xl) and f(xu) does not change sign


between two points i.e. if f(xl) f(xu) > 0,
there may not be any roots for the
equation f(x) = 0 between the two points

8
Theorem
If function f(x) is a real and continuous
between the interval xl and xu

 If f(xl) and f(xu) changes sign between


two points i.e. if f(xl) f(xu) < 0, more than
one root for the equation f(x) = 0 may
exist between the two points

Solve
Please check
(1) x3 + 2x2 + 3 x - 4 = 0 with in the limits [0,1]
what will happen
if the Limits of
(2) x3 - 2.7 x2 + 4.5 x – 6 = 0 with in the limits [1,3]
the problem (2)
becomes [1.5, 4]

9
Advantages and drawbacks BS Method
Advantages
• Always convergent
• Error can be controlled - guaranteed

Drawbacks

• convergence is slow, if
one of the initial guesses
is close to the root
•e.g. f(x) = sin(x)
For case 1: Take the limits [2, 4]
For case 2: Take the limits [3, 4]

Check which one requires more


iteration to converge

10
Drawbacks BS Method

o 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

e.g. f(x) =x2

o Function changes sign but root


does not exist i.e. root may be a
singularity point

e.g. f(x)=1/x

11
Algorithm for the bisection method
Step - 1
Choose x and xu as two guesses for the root such that f (x ) f (xu )  0 , or in other words,
f (x) changes sign between x and xu

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

Step - 3
Now check the following
a) If f (x  ) f (x m )  0 , then the root lies between x and xm ; then x  x and
xu  x m .
b) If f (x  ) f (x m )  0 , then the root lies between xm and xu ; then x  xm and
xu  xu .
c) If f (x  ) f (x m )  0 ; then the root is xm . Stop the algorithm if this is true.
12
Step - 4
Find the new estimate of the root
x x
xm =  u
2

Step - 5
Find the absolute relative approximate error as
x nme w - x oml d
a =  100
x nme w
where
xmnew = estimated root from present iteration
xmold = estimated root from previous iteration

Compare the absolute relative approximate error a with the pre-specified relative error tolerance s

If a s , then go to Step 3, else stop the algorithm.

13
Finding roots using simple commands
Use “fzero” command in Matlab
o
o Use “Goal Seek” option in Excel

>> x0=[1 3];

>> x = fzero(@(x)x^3-2.7*x^2+4.5*x-6,x0);
One can also use
“solver” option in
MS - Excel

o Use “root” option in Mathcad


One can also use “fsolve”
option in Matlab to find the
root
Analyze the difference
between fzero and fsolve
command
Hint: use Help command in
Matlab
e.g. >>help fsolve
14

You might also like