diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1670/CH5/EX5.38/5_38.sce | |
download | Scilab-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.38/5_38.sce')
-rwxr-xr-x | 1670/CH5/EX5.38/5_38.sce | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/1670/CH5/EX5.38/5_38.sce b/1670/CH5/EX5.38/5_38.sce new file mode 100755 index 000000000..3a8ea0257 --- /dev/null +++ b/1670/CH5/EX5.38/5_38.sce @@ -0,0 +1,29 @@ +//Example 5.38
+//Lagranges Interpolation Method
+//Page no. 178
+clc;close;clear;
+
+x=[1,2,3,4,7]
+y=[2,4,8,16,128]
+x0=5
+printf('\tx\ty=f(x)\n-----------------------\n')
+for i=1:5
+ printf('x%i\t%i\t %i\n',i-1,x(i),y(i))
+end
+p=1;p1=1;i=1;
+for k=1:5
+ for j=1:5
+ 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:5
+ printf('\n L%i (x) = %g\n',i-1,L(i))
+ p=p+L(i)*y(i)
+end
+disp(p,"P(5) = ")
\ No newline at end of file |