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 /1332/CH12/EX12.6/12_6.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 '1332/CH12/EX12.6/12_6.sce')
-rwxr-xr-x | 1332/CH12/EX12.6/12_6.sce | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/1332/CH12/EX12.6/12_6.sce b/1332/CH12/EX12.6/12_6.sce new file mode 100755 index 000000000..644917648 --- /dev/null +++ b/1332/CH12/EX12.6/12_6.sce @@ -0,0 +1,36 @@ +//Example 12.6
+//Chebyshev Interpolating Polynomial
+//Page no. 407
+clc;close;clear;
+
+deff('y=f(x)','y=1/(1+exp(-x))');
+a=-2;b=2;n=3;
+D=%pi/(2*n+2)
+for k=0:n
+ t(k+1)=-cos(D*(2*k+1))
+ x(k+1)=((a+b)/2)+(b-a)*t(k+1)/2
+ y(k+1)=f(x(k+1))
+ C(k+1)=0
+end
+for j=0:n
+ for k=0:n
+ L=(2*k+1)*D
+ C(j+1)=C(j+1)+y(k+1)*cos(j*L)
+ end
+end
+C(1)=C(1)/(n+1);
+for j=1:n
+ C(j+1)=2*C(j+1)/(n+1)
+end
+
+x=poly(0,"x")
+T(1)=1;T(2)=x;
+for j=1:n-1
+ T(j+2)=2*x*T(j+1)-T(j)
+end
+P=C(1)*T(1)
+for j=1:n
+ P=P+C(j+1)*T(j+1)
+end
+disp(P,'P3(x)=')
+printf('\n\n\nNote : Book has Calculation errors in calculation of coefficients')
\ No newline at end of file |