diff options
Diffstat (limited to '260/CH10/EX10.6/10_6.sce')
-rw-r--r-- | 260/CH10/EX10.6/10_6.sce | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/260/CH10/EX10.6/10_6.sce b/260/CH10/EX10.6/10_6.sce new file mode 100644 index 000000000..050d86723 --- /dev/null +++ b/260/CH10/EX10.6/10_6.sce @@ -0,0 +1,54 @@ +//Eg-10.6
+//pg-440
+
+clear
+clc
+close()
+
+X = [3;5;6;9];
+
+Y = [293;508;585;764];
+
+T = zeros(4,4);
+
+T(:,1) = Y;
+
+for(j = 2:4)
+ for(i = 1:4+1-j)
+ T(i,j) = (T(i+1,j-1) - T(i,j-1))/(X(j-1+i) - X(i));
+ end
+end
+
+//disp(T)
+
+//p3 = a0 + a1 * (x-3) + a2 * (x-3)*(x-5) + a3 * (x-3)*(x-5)*(x-6)
+
+a0 = T(1,1);
+a1 = T(1,2);
+a2 = T(1,3);
+a3 = T(1,4);
+
+//p3 = b0 + b1*x + b2*x^2 + b3*x^3
+
+b0 = a0 + 15*a2 - 3*a1 -90*a3;
+b1 = a1 - 8*a2 + 63*a3;
+b2 = a2 - 14*a3;
+b3 = a3;
+
+//disp(b0,b1,b2,b3)
+
+deff('out = func(in)','out = b0 + b1*in + b2*in^2 + b3*in^3')
+
+x = 3:9;
+y = func(x);
+plot(x,y)
+
+plot(X,Y,'db')
+
+legend('Divided difference polynomial of order 3','Experimental data')
+
+xlabel('F')
+ylabel('P')
+
+
+
|