summaryrefslogtreecommitdiff
path: root/149/CH24/EX24.1/ques1.sce
blob: 6c61d4967ed5087e879f5b87917748692e97fade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
clc
clear
x=poly(0,'x');
p=x^3-4*x-9
disp("Finding roots of this equation by bisection method");
disp('f(2) is -ve and f(3) is +ve so a root lies between 2 and 3');
l=2;
m=3;
function y=f(x)
  y=x^3-4*x-9;
endfunction
for i=1:4
    k=1/2*(l+m);
if(f(k)<0)
    l=k;
else 
  m=k; 
  end 
end
disp(k)