From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 1670/CH5/EX5.37/5_37.sce | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 1670/CH5/EX5.37/5_37.sce (limited to '1670/CH5/EX5.37') 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 -- cgit