summaryrefslogtreecommitdiff
path: root/845/CH6/EX6.11/Ex6_11.sce
diff options
context:
space:
mode:
Diffstat (limited to '845/CH6/EX6.11/Ex6_11.sce')
-rwxr-xr-x845/CH6/EX6.11/Ex6_11.sce35
1 files changed, 35 insertions, 0 deletions
diff --git a/845/CH6/EX6.11/Ex6_11.sce b/845/CH6/EX6.11/Ex6_11.sce
new file mode 100755
index 000000000..4159cc4ee
--- /dev/null
+++ b/845/CH6/EX6.11/Ex6_11.sce
@@ -0,0 +1,35 @@
+//Example 6.11
+
+clc
+clear
+
+x = 0:5;
+y = [-3 3 11 27 57 107];
+
+n = length(x);
+del = %nan*ones(n,4);
+del(:,1) = y';
+for j = 2:4
+ for i = 1:n-j+1
+ del(i,j) = del(i+1,j-1) - del(i,j-1);
+ end
+end
+del(:,1) = [];
+
+X = poly(0, "x");
+h = x(2) - x(1);
+p = (X-x(1)) / h;
+x0 = x(1);
+y0 = y(1);
+dely0 = del(1,:);
+
+Y = y0;
+
+for i = 1:length(dely0)
+ t = 1;
+ for j = 1:i
+ t = t * (p-j+1);
+ end
+ Y = Y + t*dely0(i)/factorial(i);
+end
+disp(Y,"Required cubic polynomial:")