summaryrefslogtreecommitdiff
path: root/1670/CH5/EX5.37
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1670/CH5/EX5.37
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 '1670/CH5/EX5.37')
-rwxr-xr-x1670/CH5/EX5.37/5_37.sce29
1 files changed, 29 insertions, 0 deletions
diff --git a/1670/CH5/EX5.37/5_37.sce b/1670/CH5/EX5.37/5_37.sce
new file mode 100755
index 000000000..121b25afe
--- /dev/null
+++ b/1670/CH5/EX5.37/5_37.sce
@@ -0,0 +1,29 @@
+//Example 5.37
+//Lagranges Interpolation Method
+//Page no. 177
+clc;close;clear;
+
+x=[0,1,2,5]
+y=[2,3,12,147]
+x0=poly(0,'x')
+printf('\tx\ty=f(x)\n-----------------------\n')
+for i=1:4
+ printf('x%i\t%i\t %i\n',i-1,x(i),y(i))
+end
+p=1;p1=1;i=1;
+for k=1:4
+ for j=1:4
+ if k~=j then
+ p=p*(x0-x(j))
+ p1=p1*(x(k)-x(j))
+ end
+end
+L(k)=p/p1
+p=1;p1=1;
+end
+p=0;
+for i=1:4
+ disp(L(i),"L(x) = ")
+ p=p+L(i)*y(i)
+end
+disp(p,"P(x) = ") \ No newline at end of file