summaryrefslogtreecommitdiff
path: root/845/CH6/EX6.8/Ex6_8.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /845/CH6/EX6.8/Ex6_8.sce
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '845/CH6/EX6.8/Ex6_8.sce')
-rwxr-xr-x845/CH6/EX6.8/Ex6_8.sce41
1 files changed, 41 insertions, 0 deletions
diff --git a/845/CH6/EX6.8/Ex6_8.sce b/845/CH6/EX6.8/Ex6_8.sce
new file mode 100755
index 000000000..5e4ae1d5a
--- /dev/null
+++ b/845/CH6/EX6.8/Ex6_8.sce
@@ -0,0 +1,41 @@
+//Example 6.8
+
+clc
+clear
+
+x = 10:10:50;
+y = [46 66 81 93 101];
+
+n = length(x);
+del = %nan*ones(n,5);
+del(:,1) = y';
+for j = 2:5
+ for i = 1:n-j+1
+ del(i,j) = del(i+1,j-1) - del(i,j-1);
+ end
+end
+del(:,1) = [];
+
+X = 15; //input
+for i = 1:n
+ if X>x(i) then
+ h = x(i+1) - x(i);
+ p = (X-x(i)) / h;
+ x0 = x(i);
+ y0 = y(i);
+ dely0 = del(i,:);
+ dely0(isnan(y0)) = [];
+ end
+end
+
+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
+Y = round(Y*10^4)/10^4;
+disp(Y,"f(15) = ")