summaryrefslogtreecommitdiff
path: root/1332/CH21/EX21.2/21_2.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1332/CH21/EX21.2/21_2.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 '1332/CH21/EX21.2/21_2.sce')
-rwxr-xr-x1332/CH21/EX21.2/21_2.sce36
1 files changed, 36 insertions, 0 deletions
diff --git a/1332/CH21/EX21.2/21_2.sce b/1332/CH21/EX21.2/21_2.sce
new file mode 100755
index 000000000..d9ba4eb82
--- /dev/null
+++ b/1332/CH21/EX21.2/21_2.sce
@@ -0,0 +1,36 @@
+//Example 21.2
+//Lagrange Interpolation in Parallel Computing
+//Page no. 723
+clc;close;clear;
+
+xi=[-1,0,2,5];
+yi=[9,5,3,15];
+s=["x=1","n=4","Data:","(-1,9)","(0,5)","(2,3)","(5,15)"]
+for i=1:4
+ printf('\tProcessor\t')
+end
+printf('\n')
+for i=1:4
+ printf('\t N%i\t\t',i)
+end
+printf('\n')
+for i=1:7
+ for j=1:4
+ printf(' %s\t\t',s(i))
+ end
+ printf('\n')
+end
+
+x=1;T=0;
+for k=0:3
+ p=yi(k+1)
+ for j=0:3
+ if(j~=k)
+ p=p*((x-xi(j+1))/(xi(k+1)-xi(j+1)))
+ end
+ end
+ T=T+p;
+ printf('\nT(%i) = %g',k+1,p)
+end
+printf('\n\nT = %g',T)
+