0% found this document useful (0 votes)
56 views2 pages

Lecture Note of False Position Method

The false position method is used to find the root of a function between two bounds. The function f(x)=x^3 - x^2 - 10x - 8 is defined and the initial lower and upper bounds of 3.75 and 5 are given. The method iteratively calculates a new root estimate until the error is below 0.5% or the maximum 20 iterations is reached. The approximate root is found to be 3.9937 after 3 iterations.

Uploaded by

azlanazman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views2 pages

Lecture Note of False Position Method

The false position method is used to find the root of a function between two bounds. The function f(x)=x^3 - x^2 - 10x - 8 is defined and the initial lower and upper bounds of 3.75 and 5 are given. The method iteratively calculates a new root estimate until the error is below 0.5% or the maximum 20 iterations is reached. The approximate root is found to be 3.9937 after 3 iterations.

Uploaded by

azlanazman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

%Example of false position method =

F = inline('x^3 - x^2 - 10*x - 8'); % %Define a function using


inline
xl =
xu =
imax
es =
xr =

3.75;
5;
= 20;
0.5;
0; % Dummy value for xr.

Fl=F(xl);
Fu=F(xu);
if Fl*Fu > 0

% Define all initial value

% Define lower and upper function


% Positive value

disp('Error: The function has the same sign at


points xl and xu.')
else
fprintf('-------------------------------------\n');
fprintf(' i
xl
xu
xr
Fr
ea\n');
fprintf('-------------------------------------\n');
for i = 1:imax
xrold = xr;
xr = xu-((Fu*(xu - xl))/(Fu-Fl));

% False Position
Equation

Fr=F(xr);
ea=abs((xr-xrold)/xr)*100;

% Error calculation

fprintf('%3i %11.4f %11.4f %11.4f %10.4f


%10.4f\n',i, xl, xu, xr, Fr, ea)

if Fr == 0
fprintf('An exact solution x =%11.6f was
found',xr)

end

break

if ea < es
break
end
if i == imax
fprintf('Solution was not obtained in %i
iterations',imax)
break
end
if Fl*Fr
xu =
else
xl =
Fl =
end

< 0
xr;
xr;
Fr;

end
fprintf('The approximate solution is x = %8.4f \n ',xr)
end

ANSWER
------------------------------------------------------------i
xl
xu
xr
Fr
ea
------------------------------------------------------------1
3.7500
5.0000
3.9248
-2.1942
100.0000
2
3.9248
5.0000
3.9782
-0.6493
1.3419
3
3.9782
5.0000
3.9937
-0.1874
0.3895
The approximate solution is x =
3.9937

You might also like