Lesson 5 Incremental Search Method

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

LESSON 5A: INCREMENTAL SEARCH METHOD: THE ROOTSEARCH

Summary:

1. The approximate locations of the roots are best determined by plotting the function.
2. Another useful tool for detecting and bracketing roots is the incremental search method. The basic
idea is as follows: if f(x1) and f(x2) have opposite signs, then there is at least one root in the
interval(x1, x2). If the interval is small enough, it is likely to contain a single root. Thus the zeros of
f(x) can be detected by evaluating the function at the interval x and look for a change in sign.
3. Drawbacks of Incremental search method: (1) It is possible to miss two closely spaced roots if the
search increment x is larger than the spacing of the roots. (2) A double root (two roots that
coincide will not be detected. (3) Certain singularities (poles) of f(x) can be mistaken for roots.
(Poles are locations that do not cross the x-axis) (Kiusalaas, 2010).

Example:

Use the incremental search method with x = 0.2 to bracket the smallest positive zero of f(x) = x 3 10x2 + 5
from the range 0.0 to 1.0.

Solution:

(1) Set a = 0.0, b = 1.0

(2) Solve for f(0) = 5 f(0.2) = (0.2)3 10 (0.2)2 + 5 = 4.608 f(0.4) = (0.4)3 10 (0.4)2 + 5 = 3.464

f(0.6) = (0.6)3 10 (0.6)2 + 5 = 1.616 f(0.8) = (0.2)3 10 (0.2)2 + 5 = -0.888

(3) Since there was a change of sign, we can say that there is/are root/s between these points (0.6 and 0.8)

Program Used:

function [x1,x2,f1,f2] = rootsearch(func,a,b,dx) %incrementsearch_1


% Incremental search for a root of f(x). f = inline('x^3-10*x^2+...
% USAGE: [x1,x2] = rootsearch(func,a,d,dx) 5','x');
% INPUT: a = 0.0;
% func = handle of function that returns f(x). b = 1.0;
% a,b = limits of search. d = 0.2;
% dx = search increment. [x1, x2,f1, f2] =
% OUTPUT: rootsearch(f,a,b,d)
% x1,x2 = bounds on the smallest root in (a,b);
% set to NaN if no root was detected
x1 = a; f1 = feval(func,x1);
x2 = a + dx; f2 = feval(func,x2);
while f1*f2 > 0.0
if x1 > = b
x1 = NaN; x2 = NaN; return
end
x1 = x2; f1 = f2;
x2 = x1 + dx; f2 = feval(func,x2);
end

You might also like