summaryrefslogtreecommitdiff
path: root/964/CH6/EX6.8/6_8.sce
blob: 0f44bec043805e156d8dcdcd85a0bc404216cb9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//clc()
del = 0.01;
z = 0.56714329
x1 = 1;
//f(x) = exp(-x) - x
disp(x1,"x1 = ")
for i = 1:4
    if i == 1 then
        x(i) = 1
    else 
        w = x(i-1);
        m = exp(-x(i-1)) - x(i-1);
        x(i-1) = x(i-1)*(1+del);
        n = exp(-x(i-1)) - x(i-1);
        x(i) = w - (x(i-1)- w) * m/(n-m);
        em = (z - x(i))*100/z;
         disp(x(i),"x = ")
        disp("%",em,"error = ")
    end
end