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 | |
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')
-rwxr-xr-x | 1332/CH12/EX12.1/12_1.pdf | bin | 0 -> 6134 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.1/12_1.sce | 30 | ||||
-rwxr-xr-x | 1332/CH12/EX12.2/12_2.pdf | bin | 0 -> 6048 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.2/12_2.sce | 20 | ||||
-rwxr-xr-x | 1332/CH12/EX12.3/12_3.pdf | bin | 0 -> 6167 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.3/12_3.sce | 37 | ||||
-rwxr-xr-x | 1332/CH12/EX12.4/12_4.pdf | bin | 0 -> 6136 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.4/12_4.sce | 24 | ||||
-rwxr-xr-x | 1332/CH12/EX12.5/12_5.pdf | bin | 0 -> 7665 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.5/12_5.sce | 111 | ||||
-rwxr-xr-x | 1332/CH12/EX12.6/12_6.pdf | bin | 0 -> 6171 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.6/12_6.sce | 36 | ||||
-rwxr-xr-x | 1332/CH12/EX12.7/12_7.pdf | bin | 0 -> 6234 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.7/12_7.sce | 36 | ||||
-rwxr-xr-x | 1332/CH12/EX12.8/12_8.pdf | bin | 0 -> 6366 bytes | |||
-rwxr-xr-x | 1332/CH12/EX12.8/12_8.sce | 32 |
16 files changed, 326 insertions, 0 deletions
diff --git a/1332/CH12/EX12.1/12_1.pdf b/1332/CH12/EX12.1/12_1.pdf Binary files differnew file mode 100755 index 000000000..fb31c296f --- /dev/null +++ b/1332/CH12/EX12.1/12_1.pdf diff --git a/1332/CH12/EX12.1/12_1.sce b/1332/CH12/EX12.1/12_1.sce new file mode 100755 index 000000000..d4fd65b8d --- /dev/null +++ b/1332/CH12/EX12.1/12_1.sce @@ -0,0 +1,30 @@ +//Example 12.1
+//Linear Interpolation Technique
+//Page no. 372
+clc;close;clear;
+
+printf('x: ')
+f=[1,4,9,16,25];
+for i=1:5
+ printf('%i\t',i)
+end
+printf('\nf(x): ')
+for i=1:5
+ printf('%i\t',f(i))
+end
+x=2.5;
+x1=2;x2=3;printf('\n\nfor (2,4) and (3,9)')
+f(2.5)=f(x1)+(f(x2)-f(x1))*(x-x1)/(x2-x1)
+printf('\nf(2.5) = %.1f',f(2.5))
+
+x=2.5;
+x1=2;x2=4;printf('\n\nfor (2,4) and (4,16)')
+f(2.5)=f(x1)+(f(x2)-f(x1))*(x-x1)/(x2-x1)
+printf('\nf(2.5) = %.1f',f(2.5))
+
+x=2.5;
+x1=1;x2=3;printf('\n\nfor (1,1) and (3,9)')
+f(2.5)=f(x1)+(f(x2)-f(x1))*(x-x1)/(x2-x1)
+printf('\nf(2.5) = %.1f',f(2.5))
+
+printf('\n\nExact value = %.2f',2.5^2)
\ No newline at end of file diff --git a/1332/CH12/EX12.2/12_2.pdf b/1332/CH12/EX12.2/12_2.pdf Binary files differnew file mode 100755 index 000000000..f4b941b25 --- /dev/null +++ b/1332/CH12/EX12.2/12_2.pdf diff --git a/1332/CH12/EX12.2/12_2.sce b/1332/CH12/EX12.2/12_2.sce new file mode 100755 index 000000000..0f30446c9 --- /dev/null +++ b/1332/CH12/EX12.2/12_2.sce @@ -0,0 +1,20 @@ +//Example 12.2
+//Lagarangian Method
+//Page no. 373
+clc;close;clear;
+
+xk=[-1,0,2,5];
+yk=[10,7,7,22];
+
+P=0;
+x=poly(0,"x");
+for k=0:3
+ p=yk(k+1)
+ for j=0:3
+ if(j~=k)
+ p=p*((x-xk(j+1))/(xk(k+1)-xk(j+1)))
+ end
+ end
+ P=P+p;
+end
+disp(P,'P=')
\ No newline at end of file diff --git a/1332/CH12/EX12.3/12_3.pdf b/1332/CH12/EX12.3/12_3.pdf Binary files differnew file mode 100755 index 000000000..0faac3a60 --- /dev/null +++ b/1332/CH12/EX12.3/12_3.pdf diff --git a/1332/CH12/EX12.3/12_3.sce b/1332/CH12/EX12.3/12_3.sce new file mode 100755 index 000000000..f92656654 --- /dev/null +++ b/1332/CH12/EX12.3/12_3.sce @@ -0,0 +1,37 @@ +//Example 12.3
+//Aitken-Neville's Method
+//Page no. 378
+clc;close;clear;
+
+function [x,y,z]=tran(a,b) // function for exchanging values
+ z=a;y=b;x=z;
+endfunction
+deff('y=P(a,b,c,d,e)','y=(c(d)*b(d+1)-c(d+e)*b(d))/(a(d+e)-a(d))') //function for finding polynomials
+xi=[0.8,1,1.2,1.4,1.6];
+yi=[2.2255,2.7183,3.3201,4.0552,4.9530];
+x=1.23
+[xi(5),xi(1),a]=tran(xi(1),xi(5))
+[xi(4),xi(1),a]=tran(xi(1),xi(4))
+[xi(3),xi(2),a]=tran(xi(2),xi(3))
+[xi(2),xi(1),a]=tran(xi(1),xi(2))
+[yi(5),yi(1),a]=tran(yi(1),yi(5))
+[yi(4),yi(1),a]=tran(yi(1),yi(4))
+[yi(3),yi(2),a]=tran(yi(2),yi(3))
+[yi(2),yi(1),a]=tran(yi(1),yi(2))
+for i=1:5
+ x_xi(i)=x-xi(i);
+end
+printf('xi x-xi yi\n')
+printf('------------------------\n')
+for i=1:5
+ printf('%.1f %.2f\t%f\n',xi(i),x_xi(i),yi(i))
+end
+printf('\n\nPolynomials\n')
+printf('-----------\n')
+for i=1:4
+ for j=1:5-i
+ printf('%f\n',P(xi,yi,x_xi,j,i))
+ yi(j)=P(xi,yi,x_xi,j,i)
+ end
+ printf('\n\n\n')
+end
\ No newline at end of file diff --git a/1332/CH12/EX12.4/12_4.pdf b/1332/CH12/EX12.4/12_4.pdf Binary files differnew file mode 100755 index 000000000..d2532215e --- /dev/null +++ b/1332/CH12/EX12.4/12_4.pdf diff --git a/1332/CH12/EX12.4/12_4.sce b/1332/CH12/EX12.4/12_4.sce new file mode 100755 index 000000000..817582c27 --- /dev/null +++ b/1332/CH12/EX12.4/12_4.sce @@ -0,0 +1,24 @@ +//Example 12.4
+//Newton's Divided Difference Interpolation
+//Page no. 381
+clc;close;clear;
+
+x=[0,1,2,3,4,5]
+y=[1,2,5,10,17,26];
+y1=y;
+deff('yi=P(a,b,d,e)','yi=(b(d+1)-b(d))/(a(d+e)-a(d))') //function for finding polynomials
+for i=1:3
+ for j=1:6-i
+ z(j,i)=P(x,y,j,i)
+ y(j)=z(j,i)
+ end
+end
+z(6,1)=0;
+printf('x y f(x0,x1) f(x0,x1,x3) f(x0,x1,x2,x3)\n')
+printf('---------------------------------------------------------\n')
+ for j=1:6
+ printf(' %i %i \t%i\t\t%i\t\t%i\n',x(1,j),y1(1,j),z(j,1),z(j,2),z(j,3))
+ end
+x1=2.6;
+f=y1(4)+(x1-x(4))*(z(4,1))+(x1-x(4))*(x1-x(5))*z(4,2)
+printf('\n\nf(2.6)=%.2f',f)
\ No newline at end of file diff --git a/1332/CH12/EX12.5/12_5.pdf b/1332/CH12/EX12.5/12_5.pdf Binary files differnew file mode 100755 index 000000000..1cf78509a --- /dev/null +++ b/1332/CH12/EX12.5/12_5.pdf diff --git a/1332/CH12/EX12.5/12_5.sce b/1332/CH12/EX12.5/12_5.sce new file mode 100755 index 000000000..8d07e690a --- /dev/null +++ b/1332/CH12/EX12.5/12_5.sce @@ -0,0 +1,111 @@ +//Example 12.5
+//Interpolation Methods
+//Page no. 403
+clc;close;clear;
+
+x=[0,1,2,3,4];
+y=[0,1,8,27,64];
+
+//Inverse lagrange Method
+P=0;
+y1=20;
+for k=0:4
+ p=x(k+1)
+ for j=0:4
+ if(j~=k)
+ p=p*((y1-y(j+1))/(y(k+1)-y(j+1)))
+ end
+ end
+ P=P+p;
+end
+disp(P,'Inverse Lagrange interpolation x=')
+
+
+//Newton's divide difference interpolation
+x1=x;
+deff('xi=P(a,b,d,y)','xi=(b(d+1)-b(d))/(a(d+y)-a(d))') //function for finding polynomials
+for i=1:2
+ for j=1:5-i
+ z(j,i)=P(y,x,j,i)
+ x(j)=z(j,i)
+ end
+end
+z(5,1)=0;
+printf('\n\n y\tx f(y0,y1) f(y0,y1,y3)\n')
+printf('------------------------------------------\n')
+ for j=1:5
+ printf(' %i\t%i \t%i\t\t%i\t\n',y(1,j),x1(1,j),z(j,1),z(j,2))
+ end
+y1=20;
+f=x1(4)+(y1-y(4))*(z(4,1))+(y1-y(4))*(y1-y(5))*z(4,2)
+printf('\n\nNewton Divide Difference x(20)=%.2f',f)
+
+x=x1;
+//Iterated Linear Interpolation
+function [x,y,z]=tran(a,b) // function for exchanging values
+ z=a;y=b;x=z;
+endfunction
+deff('y=P(a,b,c,d,e)','y=(c(d)*b(d+1)-c(d+e)*b(d))/(a(d+e)-a(d))') //function for finding polynomials
+y1=20
+
+[y(4),y(1),a]=tran(y(1),y(4))
+[y(3),y(2),a]=tran(y(2),y(3))
+[x(4),x(1),a]=tran(x(1),x(4))
+[x(3),x(2),a]=tran(x(2),x(3))
+for i=1:5
+ y1_y(i)=y1-y(i);
+end
+printf('y\ty1-y\tx\n')
+printf('------------------\n')
+for i=1:5
+ printf('%.1f\t%i\t%i\n',y(i),y1_y(i),x(i))
+end
+printf('\n\nPolynomials\n')
+printf('-----------\n')
+for i=1:4
+ for j=1:5-i
+ printf('%f\n',P(y,x,y1_y,j,i))
+ x(j)=P(y,x,y1_y,j,i)
+ end
+ printf('\n\n')
+end
+printf('Iterated Linear Interpolation x(20) = %f',x(j))
+
+x=[0,1,2,3,4];
+y=[0,1,8,27,64];
+y1=y;
+//Suggested Interpolation
+
+for i=1:4
+ for j=1:5-i
+ z(j,i)=y(j+1)-y(j);
+ y(j)=z(j,i)
+ end
+end
+printf('\n\n\n x\ty\tdy\td2y\td3y\td4y\n')
+printf('--------------------------------------------\n')
+for i=1:5
+ printf(' %i\t%i\t%i\t%i\t%i\t%i\n',x(i),y1(i),z(i,1),z(i,2),z(i,3),z(i,4))
+end
+s=poly(0,'s')
+p=y1(4);k=3;
+for i=1:3
+ r=1;
+ for j=1:i
+ r=r*(s+(j-1))
+ end
+ r=r*z(k,i)/factorial(j);
+ k=k-1;
+ p=p+r;
+ printf('\n\nStage %i :',i)
+ disp(p)
+end
+s0=-7/19;
+disp(s0,'s0=');
+s1=(-7-s0*(s0+1)*6)/19
+disp(s1,'s1=')
+disp(3+s1,'x1=')
+s2=(-7-s1*(s1+1)*6-s1*(s1+1)*(s1+2))/19
+disp(s2,'s2=')
+x2=3+s2;
+disp(x2,'Suggested Interpolation x(20)=');
\ No newline at end of file diff --git a/1332/CH12/EX12.6/12_6.pdf b/1332/CH12/EX12.6/12_6.pdf Binary files differnew file mode 100755 index 000000000..743c584fb --- /dev/null +++ b/1332/CH12/EX12.6/12_6.pdf 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 diff --git a/1332/CH12/EX12.7/12_7.pdf b/1332/CH12/EX12.7/12_7.pdf Binary files differnew file mode 100755 index 000000000..4f5e2dc04 --- /dev/null +++ b/1332/CH12/EX12.7/12_7.pdf diff --git a/1332/CH12/EX12.7/12_7.sce b/1332/CH12/EX12.7/12_7.sce new file mode 100755 index 000000000..587443fa3 --- /dev/null +++ b/1332/CH12/EX12.7/12_7.sce @@ -0,0 +1,36 @@ +//Example 12.7
+//Double Interpolation
+//Page no. 409
+clc;close;clear;
+
+x=[0,1,2,3,4];
+y=[0,1,2,3,4];
+z=[0,1,8,27,64;1,3,11,31,69;4,7,16,37,76;9,13,23,45,85;16,21,32,55,96];
+printf('y / x')
+for i=1:5
+ printf('\t%i',x(i))
+end
+for i=1:5
+ printf('\n %i',y(i))
+ for j=1:5
+ printf('\t%i',z(j,i))
+ end
+end
+printf('\n\n\n')
+for i=1:5
+ x=2.5;
+ x1=2;x2=3;
+ z1(1,i)=z(i,x1+1)+(z(i,x2+1)-z(i,x1+1))*(x-x1)/(x2-x1)
+end
+printf('Values of z at x=2.5:\n\n y')
+for i=1:5
+ printf('\t%i',y(i))
+end
+printf('\n z')
+for i=1:5
+ printf('\t%g',z1(i))
+end
+y=1.5;
+y1=1;y2=2;
+z2=z1(y1+1)+(z1(y2+1)-z1(y1+1))*(y-y1)/(y2-y1)
+printf('\n\nValue of z at x=2.5 and y=1.5 : %g',z2)
\ No newline at end of file diff --git a/1332/CH12/EX12.8/12_8.pdf b/1332/CH12/EX12.8/12_8.pdf Binary files differnew file mode 100755 index 000000000..7d644984a --- /dev/null +++ b/1332/CH12/EX12.8/12_8.pdf diff --git a/1332/CH12/EX12.8/12_8.sce b/1332/CH12/EX12.8/12_8.sce new file mode 100755 index 000000000..06f597812 --- /dev/null +++ b/1332/CH12/EX12.8/12_8.sce @@ -0,0 +1,32 @@ +//Example 12.8
+//Spline Interpolation
+//Page no. 414
+clc;close;clear;
+
+xi=[0.10,0.11,0.12,0.13,0.14,0.15,0.16,0.17];
+yi=[0.1110,0.1234,0.1361,0.1491,0.1623,0.1759,0.1897,0.2038];
+h=0.01;
+
+pi(1)=0;qi(1)=0;pi(8)=0;qi(8)=0;
+for i=2:7
+ pi(i)=-1/(4+pi(i-1))
+ qi(i)=((6/h^2)*(yi(i+1)-2*yi(i)+yi(i-1))-qi(i-1))/(4+pi(i-1))
+end
+si2(8)=0;
+si2(1)=0;si1(8)=0;
+si1(1)=0;
+for i=7:-1:2
+ si2(i)=pi(i)*si2(i+1)+qi(i)
+end
+for i=2:8
+ si1(i)=si1(i-1)+h*(si2(i)+si2(i-1))/2
+end
+printf('\n i\t xi\t fi\t pi\t\t qi\t\t si2\t\t si1')
+printf('\n---------------------------------------------------------------------------------')
+for i=1:8
+ printf('\n %i\t%g\t%g\t%f\t%f\t%f\t%f',i,xi(i),yi(i),pi(i),qi(i),si2(i),si1(i))
+end
+x=0.1325;
+i=4;
+s=yi(i)+(x-xi(i))*si1(i)+(si2(i)*(x-xi(i))^2)/2+((si2(i+1)-si2(i))/(xi(i+1)-xi(i)))*((x-xi(i))^3)/6
+printf('\n\nSpline Interpolated Value of s(0.1325) is : %f',s)
\ No newline at end of file |