Download presentation
Presentation is loading. Please wait.
Published byLynn Preston Modified over 6 years ago
1
Solution of Nonlinear Equations (Root finding Problems
2
Bisection Method When f(x) is continuous in the environment of a single root r, then f(x) changes sign through r. There is a small interval [a,b] including r such that f(a).f(b) < 0. Taking the midpoint m of [a,b], there are three possibilities. f(m) = 0 ; then m is the root r. f(m).f(a) < 0 ; then the root r is in [a,m] f(m).f(b) < 0 ; then the root r is in [m,b]
3
Now we can restart the procedure with the smaller interval [a,m] or [m,b]. The interval becomes smaller and smaller, so we can find an approximation of the root r. Example t t = 0 has a positive root r in [0,1]. f(0)<0 and f(1)>0.
4
Since f(0.5) = 0.125 the root is in [0, 0.5].
and so we approach the root
6
Algorithm Input: Continuous function f(x) Interval ends a,b
Output: root of function f(x) in the interval [a,b], i.e. find x ∈ [a,b] such that f(x)=0 Assumptions: f(x) is continuous on [a,b] f(a) f(b) < 0
7
Steps: Loop 1. Compute the midpoint c=(a+b)/2 2. Evaluate f(c ) if f(c)==0, stop c is the root 3. If f(a) f(c) < 0 then new interval [a, c] If f(a) f( c) > 0 then new interval [c, b] End loop
8
Example Find the root of f(x)=x2 -7x+10 n the interval [1,4] with accuracy 0.01 1. Check the assumptions: f(x) is continuous on [a,b] -> yes f(1)f(4)=(12-7 X 1 +10)(42-7 X )=4 X -2=-8 < 0
9
Apply the Algorithm
11
Program function [x,n]=bisection(f,a,b) TOL=1e-2; %tolerance NO=100; %maximum number of iterations fx=2; n=0; % initial values while (abs(fx)>TOL)&&(n<=NO) n=n+1; x=a; fa=eval(f);
12
x=(a+b)/2; fx=eval(f);
if (sign(fx)==sign(fa)) a=x; else b=x; end
13
end if n>NO x=[]; n='No zeros in given interval';
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.