0% found this document useful (0 votes)
6 views28 pages

Fixed Point Iteration Method in MATLAB

The document contains a MATLAB script for implementing the bisection method to find roots of a function. It prompts the user for initial guesses and an estimated error, then iteratively refines the guess until the estimated error is within the specified limit. If the initial guesses do not bracket a root, it outputs an error message.

Uploaded by

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

Fixed Point Iteration Method in MATLAB

The document contains a MATLAB script for implementing the bisection method to find roots of a function. It prompts the user for initial guesses and an estimated error, then iteratively refines the guess until the estimated error is within the specified limit. If the initial guesses do not bracket a root, it outputs an error message.

Uploaded by

ghaith2132004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

21

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
f= @(x) (-13- 20*x + 19*x*x -3*x^3);
xl=input('ENTER INITIAL GUESS xl: ');
xu=input('ENTER INITIAL GUESS xu: ');
es=input('ENTER your estimated error: ');

fxl=f(xl);
fxu=f(xu);

if fxl*fxu<0
xr=xu-(fxu*(xl-xu)/(fxl-fxu));
ea=1000;
fprintf('xr: ');disp(xr);
fprintf('ea: ');disp(ea);

while ea>es
fxr=f(xr);
if fxl*fxr<0
xu=xr;
fxu=fxr;
fprintf('xu: ');disp(xu);
else
xl=xr;
fxl=fxr;
fprintf('xl: ');disp(xl);
end

xrprev=xr;
xr=xu-(fxu*(xl-xu)/(fxl-fxu));
ea=abs(((xrprev-xr)/xr)*100);

fprintf('xr: ');disp(xr);
fprintf('ea: ');disp(ea);
end
else
fprintf('Entered your initial guesses are wrong!\n');
end

40
Fixed Point Iteration (None bracketing methods)

41
42
43
44
45
46
47
48

You might also like