summaryrefslogtreecommitdiff
path: root/964/CH7/EX7.8/7_8.sce
blob: e0b7523ea66affaa6cd2482f903d8a8334558eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
clc;
clear;
function y=f(x)
    y=x-cos(x)
endfunction
x1=0;
if f(x1)<0 then
    x2=x1+0.00001;
    while f(x2)<0
        x2=x2+0.00001;
    end
elseif x2=x1+0.00001;
    while f(x2)>0
        x2=x2+0.00001;
    end
else disp(x1,"The root is=")
end
x=x2-(x2-x1)*f(x2)/(f(x2)-f(x1));
disp(x,"The root is=")