diff options
Diffstat (limited to '964/CH18/EX18.3/18_3.sce')
-rwxr-xr-x | 964/CH18/EX18.3/18_3.sce | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/964/CH18/EX18.3/18_3.sce b/964/CH18/EX18.3/18_3.sce new file mode 100755 index 000000000..9ac650f7d --- /dev/null +++ b/964/CH18/EX18.3/18_3.sce @@ -0,0 +1,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 = ")
|