summaryrefslogtreecommitdiff
path: root/964/CH13/EX13.1/13_1.sce
blob: 6085f8a7468b505f0ef713cb44684cd78a33fb93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//clc()
//f(x) = 2sinx - x^2/10
xl(1) = 0;
xu(1) = 4;
for i = 1:10
    d(i) = ((5)^(0.5) - 1)*(xu(i) - xl(i))/2;
    x1(i) = xl(i) + d(i);
    x2(i) = xu(i) - d(i);
    m(i) = 2*sin(x1(i)) - (x1(i)^2)/10;
    n(i) = 2*sin(x2(i)) - (x2(i)^2)/10;
    if n(i) > m(i) then
        xu(i+1) = x1(i);
        xl(i+1) = xl(i);
    else
        xl(i+1) = x2(i);
        xu(i+1) = xu(i);
    end
end
disp(xl,"xl = ")
disp(x2,"x2 = ")
disp(x1,"x1 = ")
disp(xu,"xu = ")