Lecture 3 - Solving Non-Linear Equations (BiSection) 1
Lecture 3 - Solving Non-Linear Equations (BiSection) 1
Bisection Method
Prof. Osama Abdel Raouf
Roots of Equation
• Equation : 𝑓 𝑥 = 𝑎𝑥 2 + 𝑏𝑥 + 𝑐
• Roots of equation represent the values of x that make 𝑓 𝑥 =0 ➔
also called the zeros of the equation
• Analytical Method-> Exact solutions:
• The handy Quadratic formula for solving 𝑓 𝑥 is :
−𝑏± 𝑏2 −4𝑎𝑐
• X= 2𝑎
• There are many other functions for which the root cannot
be determined so easily ➔ numerical methods
• Ex: 𝑓 𝑥 = 𝑒 𝑥 − 𝑥
a= input('a=');
b= input('b=');
c= input('c=');
%Analytical (Exact solution)
x1=-b+sqrt(b^2-4*a*c)/(2*a)
x2=-b-sqrt(b^2-4*a*c)/(2*a)
Roots of Equation
• Equation : 𝑓 𝑥 = 𝑎𝑥 2 + 𝑏𝑥 + 𝑐
• Roots of equation represent the values of x that make 𝑓 𝑥 =0 ➔
also called the zeros of the equation
• Numerical Method-> approximation solutions:
• F(x)=5x-10=0
• root(f(x)) is x=2 ➔ f(2)=5*2-10=0
• F(X) =5x2+3x-4=0
• There are two roots
−𝑏+ 𝑏2 −4𝑎𝑐
• X1= = -2.0566
2𝑎
−𝑏− 𝑏2 −4𝑎𝑐
• X2= = -3.9434
2𝑎
P1.m Matlab code
a= input('a=');
b= input('b=');
c= input('c=');
x1=-b+sqrt(b^2-4*a*c)/(2*a)
x2=-b-sqrt(b^2-4*a*c)/(2*a)
Problem Statement. Newton’s second law
• Problem
• Newton’s second law, used for calculation the parachutist’s velocity:
𝑐
𝑔𝑚 − 𝑚 𝑡
•𝑣= (1 − 𝑒 ) v as a function of t
𝑐
• Given
• Parachutist’s mass m
• drag coefficient c
• freefalling time t
• gravity is 9.81 m/s2.
• You can easily find the parachutist's velocity after freefalling for time t
• Direct substitution
• Open Methods
• The Newton-Raphson Method
• The Secant Method
Solving non-linear equation using Bisection Method
f (b) 0
f ( x)
a b
f (a) 0
The root at which f ( x ) = 0
Solving non-linear equation using Bisection Method
Step 1: Choose lower 𝑥𝑙 and upper 𝑥𝑢 guesses for the root such that the function
changes sign over the interval. This can be checked by ensuring that 𝑓(𝑥𝑙 ) 𝑓(𝑥𝑢 ) < 0.
if subs(fx,xl)*subs(fx,xr)<0
xu=xr;
else
xl=xr;
end
xrold=xr;
end
t=uitable('ColumnName',names,'Data',data,'Position',[100
100 410 200]);
else
disp('no solution')
end
Problem Statement. Newton’s second law
• Problem
• Using Bisection Method on the interval [12,16], determine the drag coefficient c
needed for a parachutist of mass m=68.1 kg to have a velocity of v=40 m/s after
freefalling for time t=10 s. Where, the parachutist’s velocity
𝑐
𝑔𝑚 − 𝑚 𝑡
• 𝑣= 𝑐
(1 − 𝑒 ) v as a function of t
• Note: The acceleration due to gravity is 9.81 m/s2.
• Error= 0.5%
Drawbacks of Bisection Method
Drawbacks
• Converges very slowly
• Requires two guess points
Notes
Illustration of a number of general ways that a root may
occur in an interval prescribed by a lower bound xl and an
upper bound xu.
• Parts (a) and (c) indicate that if both f (xl) and f
(xu) have the same sign, either there will be no
roots or there will be an even number of roots
within the interval.