summaryrefslogtreecommitdiff
path: root/964/CH18/EX18.3/18_3.sce
blob: 9ac650f7dafffe37149bf0968cd9472499299f9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//clc()
x = 2;
x0 = 1;
m = 0;
x1 = 4;
n = 1.386294;
x3 = 5;
p = 1.609438;
x2 = 6;
o = 1.791759;
f01 = (m - n)/(x0 - x1);
f12 = (n - o)/(x1 - x2);
f23 = (p - o)/(x3 - x2);
f210 =  (f12 - f01)/(x2 - x0);
f321 = (f23 - f12)/(x3 - x1);
f0123 = (f321 - f210) / (x3 - x0);
b0 = m;
b1 = f01;
b2 = f210;
b3 = f0123;
disp(b0,"b0 = ")
disp(b1,"b1 = ")
disp(b2,"b2 = ")
disp(b3,"b3 = ")
f = b0 + b1*(x - x0) + b2*(x - x0)*(x - x1) + b3*(x - x0)*(x - x1)*(x - x2);
disp(f,"f(2) = ")
r = log(2);
e = (r -f)*100/r;
disp("%",e,"error = ")