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/CH9 | |
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/CH9')
-rwxr-xr-x | 1332/CH9/EX9.1/9_1.pdf | bin | 0 -> 6351 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.1/9_1.sce | 11 | ||||
-rwxr-xr-x | 1332/CH9/EX9.2/9_2.pdf | bin | 0 -> 6409 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.2/9_2.sce | 60 | ||||
-rwxr-xr-x | 1332/CH9/EX9.3/9_3.pdf | bin | 0 -> 6364 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.3/9_3.sce | 61 | ||||
-rwxr-xr-x | 1332/CH9/EX9.4/9_4.pdf | bin | 0 -> 6501 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.4/9_4.sce | 34 | ||||
-rwxr-xr-x | 1332/CH9/EX9.5/9_5.pdf | bin | 0 -> 6280 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.5/9_5.sce | 32 | ||||
-rwxr-xr-x | 1332/CH9/EX9.6/9_6.pdf | bin | 0 -> 6611 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.6/9_6.sce | 24 | ||||
-rwxr-xr-x | 1332/CH9/EX9.7/9_7.pdf | bin | 0 -> 7638 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.7/9_7.sce | 47 | ||||
-rwxr-xr-x | 1332/CH9/EX9.8/9_8.pdf | bin | 0 -> 6802 bytes | |||
-rwxr-xr-x | 1332/CH9/EX9.8/9_8.sce | 35 |
16 files changed, 304 insertions, 0 deletions
diff --git a/1332/CH9/EX9.1/9_1.pdf b/1332/CH9/EX9.1/9_1.pdf Binary files differnew file mode 100755 index 000000000..460aca796 --- /dev/null +++ b/1332/CH9/EX9.1/9_1.pdf diff --git a/1332/CH9/EX9.1/9_1.sce b/1332/CH9/EX9.1/9_1.sce new file mode 100755 index 000000000..06416f8c5 --- /dev/null +++ b/1332/CH9/EX9.1/9_1.sce @@ -0,0 +1,11 @@ +//Example 9.1
+//Moore-Penrose Generalized Inverse
+//Page no. 292
+clc;clear;close;
+
+AT=[3,0,3;0,3,3];
+A=AT'; //transpose
+I=inv(AT*A); //inverse
+disp(I,'Inverse of AT*A=',AT*A,'AT*A=',A,'A=',AT,'AT=');
+A#=I*AT;
+disp(A#,'Moore-Penrose Generalized Inverse of A=')
\ No newline at end of file diff --git a/1332/CH9/EX9.2/9_2.pdf b/1332/CH9/EX9.2/9_2.pdf Binary files differnew file mode 100755 index 000000000..81f76b7f6 --- /dev/null +++ b/1332/CH9/EX9.2/9_2.pdf diff --git a/1332/CH9/EX9.2/9_2.sce b/1332/CH9/EX9.2/9_2.sce new file mode 100755 index 000000000..3d0d4911a --- /dev/null +++ b/1332/CH9/EX9.2/9_2.sce @@ -0,0 +1,60 @@ +//Example 9.2
+//Curve Fitting
+//Page no. 293
+clc;clear;close;
+x(1)=0.25;
+for i=2:6
+ x(1,i)=x(1,i-1)+0.25;
+end //x values
+y(1,1)=3.1;y(1,2)=1.7;y(1,3)=1;y(1,4)=0.68;y(1,5)=0.42;y(1,6)=0.26; //y values
+
+//construction of normal equations
+for i=1:6
+ Y(1,i)=log10(y(1,i));
+end
+Ex=0;
+for i=1:6
+ Ex=Ex+x(1,i);
+end
+EY=0;
+for i=1:6
+ EY=EY+Y(1,i);
+end
+Ex2=0;
+for i=1:6
+ Ex2=Ex2+x(1,i)^2;
+end
+ExY=0;
+for i=1:6
+ ExY=ExY+x(1,i)*Y(1,i);
+end
+printf('E x(k)\t\t y(k)\t\tE Y(k)\t\tE x2(k)\t\tE x(k)*Y(k)')
+printf('\n----------------------------------------------------------------------------')
+for i=1:6
+ printf('\n%f\t%f\t%f\t%f\t%f',x(1,i),y(1,i),Y(1,i),x(1,i)^2,x(1,i)*Y(1,i))
+end
+printf('\n----------------------------------------------------------------------------')
+printf('\n%f\t%f\t%f\t%f\t%f',Ex,0,EY,Ex2,ExY)
+printf('\n----------------------------------------------------------------------------\n\n')
+A=[6,Ex;Ex,Ex2]; //system of normal equations
+B=[EY;ExY];
+X=inv(A)*B;
+a=exp(X(1,1));
+b=-1*X(2,1);
+for i=1:2
+ for j=1:2
+ printf('%f ',A(i,j))
+ end
+ if(i==1)
+ printf(' *')
+ end
+
+ printf('\ta%i',i);
+ if(i==1)
+ printf(' =')
+ end
+
+ printf('\t%f\n',B(i,1))
+end
+printf('\n\na1=%f\na2=%f\n\na=%f\nb=%f\n\n',X(1,1),X(2,1),a,b)
+printf('The fitted curve is:\n %fx\ny=%f e',b,a)
\ No newline at end of file diff --git a/1332/CH9/EX9.3/9_3.pdf b/1332/CH9/EX9.3/9_3.pdf Binary files differnew file mode 100755 index 000000000..41156b47d --- /dev/null +++ b/1332/CH9/EX9.3/9_3.pdf diff --git a/1332/CH9/EX9.3/9_3.sce b/1332/CH9/EX9.3/9_3.sce new file mode 100755 index 000000000..9213721c0 --- /dev/null +++ b/1332/CH9/EX9.3/9_3.sce @@ -0,0 +1,61 @@ +//Example 9.3
+//Gram-Schmidt Orthogonalization/Orthonormalization Process
+//Page no. 294
+clc;clear;close;
+deff('y=f(x,a)','y=sqrt(x(1,a)^2+x(2,a)^2+x(3,a)^2+x(4,a)^2)');
+deff('y=f1(g,a,h,b)','y=g(1,a)*h(1,b)+g(2,a)*h(2,b)+g(3,a)*h(3,b)+g(4,a)*h(4,b)');
+
+U=[1/sqrt(3),-2/sqrt(7),1,0,0,0;0,1/sqrt(7),0,1,0,0;1/sqrt(3),1/sqrt(7),0,0,1,0;-1/sqrt(3),-1/sqrt(7),0,0,0,1];
+for i=1:4
+ V(i,1)=U(i,1);
+end
+for i=1:4
+ if(f(V,1)~=0)
+ W(i,1)=V(i,1)/f(V,1);
+ else
+ W(i,1)=0;
+ end
+end
+for j=2:6
+ for i=1:4
+ for l=1:4
+ k(l,1)=0;
+ end
+ for l=1:j-1
+ for m=1:4
+ w(m,1)=W(m,l);
+ end
+ k=k-(f1(U,j,W,l))*w;
+ end
+ V(i,j)=U(i,j)+k(i,1);
+ end
+ for i=1:4
+ if(j~=4)
+ if(f(V,j)~=0)
+ W(i,j)=V(i,j)/f(V,j);
+ else
+ W(i,j)=0;
+ end
+ else
+ W(i,j)=0;
+ end
+ end
+
+end
+disp(U,'U=')
+disp('W=')
+printf('\n')
+for i=1:4
+ for j=1:6
+ printf('%.4f\t\t',W(i,j))
+ end
+ printf('\n')
+end
+disp('V=')
+printf('\n')
+for i=1:4
+ for j=1:6
+ printf('%.4f\t\t',V(i,j))
+ end
+ printf('\n')
+end
\ No newline at end of file diff --git a/1332/CH9/EX9.4/9_4.pdf b/1332/CH9/EX9.4/9_4.pdf Binary files differnew file mode 100755 index 000000000..6996647bf --- /dev/null +++ b/1332/CH9/EX9.4/9_4.pdf diff --git a/1332/CH9/EX9.4/9_4.sce b/1332/CH9/EX9.4/9_4.sce new file mode 100755 index 000000000..624b0e36e --- /dev/null +++ b/1332/CH9/EX9.4/9_4.sce @@ -0,0 +1,34 @@ +//Example 9.4
+//QR Decomposition
+//Page no. 296
+clc;clear;close;
+
+A=[2,1,1;1,3,1;1,1,4];
+B=A*A';
+disp(B,'AT*A=')
+//cholesky factorization to find R
+R(2,1)=0;R(3,1)=0;R(3,2)=0;
+for i=1:3
+ for j=1:3
+ if(i==j)
+ k=0;
+ for m=1:i-1
+ k=k+R(m,i)^2;
+ end
+ R(i,j)=sqrt(B(i,j)-k)
+ end
+ if(j>i)
+ k=0;
+ for m=1:i-1
+ k=k+R(m,j)*R(m,i);
+ end
+ R(i,j)=(B(i,j)-k)/R(i,i)
+ end
+ end
+end
+//cholesky factorization end
+disp(R,'Upper Triangular Matrix (R)=')
+R_1=inv(R);
+disp(R_1,'Inverse of R')
+Q=A*R_1;
+disp(Q,'Orthogonal Matrix Q=')
\ No newline at end of file diff --git a/1332/CH9/EX9.5/9_5.pdf b/1332/CH9/EX9.5/9_5.pdf Binary files differnew file mode 100755 index 000000000..d311586e4 --- /dev/null +++ b/1332/CH9/EX9.5/9_5.pdf diff --git a/1332/CH9/EX9.5/9_5.sce b/1332/CH9/EX9.5/9_5.sce new file mode 100755 index 000000000..b08b08d88 --- /dev/null +++ b/1332/CH9/EX9.5/9_5.sce @@ -0,0 +1,32 @@ +//Example 9.5
+//Vector Computation
+//Page no. 299
+clc;clear;close;
+
+X=[2,3,0,1];
+n=X(1);
+for i=2:4
+ if(n<X(i))
+ n=X(i);
+ end
+end
+printf('\nMaximum Value (n)=%i\n',n)
+for i=1:4
+ X(i)=X(i)/n;
+end
+disp(X,'Normalized X=')
+k=0;
+for i=1:4
+ k=k+X(i)^2;
+end
+sigma=X(1)*abs(1/X(1))*sqrt(k);
+printf('\nsigma=%f\n',sigma);
+X(1)=X(1)+sigma;
+printf('\nModified x1 = %g\n',X(1))
+for i=1:4
+ U(1,i)=X(i);
+end
+disp(U,'U=')
+p=sigma*X(1);sigma=n*sigma;
+printf('\n p = %f\n\n sigma = %f',p,sigma);
+printf('\n\n\nNote : There is a computation error in calculation of U1')
\ No newline at end of file diff --git a/1332/CH9/EX9.6/9_6.pdf b/1332/CH9/EX9.6/9_6.pdf Binary files differnew file mode 100755 index 000000000..36a5c4c29 --- /dev/null +++ b/1332/CH9/EX9.6/9_6.pdf diff --git a/1332/CH9/EX9.6/9_6.sce b/1332/CH9/EX9.6/9_6.sce new file mode 100755 index 000000000..6c9009740 --- /dev/null +++ b/1332/CH9/EX9.6/9_6.sce @@ -0,0 +1,24 @@ +//Example 9.6
+//House Holder Transformation
+//Page no. 300
+clc;clear;close;
+
+A=[4,2,1;2,5,-2;1,-2,7]
+disp(A,'A=')
+k=0;
+for j=2:3
+ k=k+A(j,1)^2;
+end
+a=A(2,1)*abs(1/A(2,1))*sqrt(k);
+disp(a,'alpha=')
+U=[0;a+A(2,1);A(3,1)];
+disp(U,'U=')
+U1=U'*U;
+disp(U1,'UT*U=')
+U2=U*U';
+disp(U2,'U*UT=')
+P=eye(3,3)-(2*U2)/U1;
+disp(P,'P=');
+B=P*A*P;
+disp(B,'B=');
+printf('\n\n\nThere are computation error in the answers given by the book in this example\n\n(a22 value error in U*UT)')
\ No newline at end of file diff --git a/1332/CH9/EX9.7/9_7.pdf b/1332/CH9/EX9.7/9_7.pdf Binary files differnew file mode 100755 index 000000000..b181eceb4 --- /dev/null +++ b/1332/CH9/EX9.7/9_7.pdf diff --git a/1332/CH9/EX9.7/9_7.sce b/1332/CH9/EX9.7/9_7.sce new file mode 100755 index 000000000..cf497efe8 --- /dev/null +++ b/1332/CH9/EX9.7/9_7.sce @@ -0,0 +1,47 @@ +//Example 9.7
+//Givens QR Method
+//Page no. 303
+clc;clear;close;
+
+A=[4,2,1;2,5,-2;1,-2,7]
+deff('y=c(i,j)','y=A(j,j)/sqrt((A(i,j)^2+A(j,j)^2))')
+deff('y=s(i,j)','y=A(i,j)/sqrt((A(i,j)^2+A(j,j)^2))')
+disp(A,'A=')
+R=A;Q=eye(3,3);
+m=1;
+for j=1:2
+ for i=j+1:3
+ for k=1:3 //C matrix evaluation
+ for l=1:3
+ if(k==l)
+ if(k==i | k==j)
+ C(k,l)=c(i,j)
+ else
+ C(k,l)=1
+ end
+ end
+ if(k>l)
+ if(k==i & l==j)
+ C(k,l)=-1*s(i,j)
+ else
+ C(k,l)=0
+ end
+ end
+ if(k<l)
+ if(k==j & l==i)
+ C(k,l)=s(i,j)
+ else
+ C(k,l)=0
+ end
+ end
+ end
+ end
+ printf('\n\n Iteration %i',m)
+ m=m+1
+ disp(C,'C=');
+ R=C*R;
+ Q=Q*C';
+ disp(Q,'Q=',R,'R=')
+ end
+end
+disp(Q*R,'Q*R=A=') //verification
\ No newline at end of file diff --git a/1332/CH9/EX9.8/9_8.pdf b/1332/CH9/EX9.8/9_8.pdf Binary files differnew file mode 100755 index 000000000..47c8cbef2 --- /dev/null +++ b/1332/CH9/EX9.8/9_8.pdf diff --git a/1332/CH9/EX9.8/9_8.sce b/1332/CH9/EX9.8/9_8.sce new file mode 100755 index 000000000..79e5f435f --- /dev/null +++ b/1332/CH9/EX9.8/9_8.sce @@ -0,0 +1,35 @@ +//Example 9.8
+//Recursive Least-Square Method
+//Page no. 308
+clc;clear;close;
+
+A0=[3,0;0,3;3,3];
+B0=[2;2;2];
+A1=[6,3];B1=[6];
+A0T=A0';
+G0=A0T*A0;
+disp(G0,'G0=')
+G0_1=inv(G0);
+disp(G0_1,'Inverse of G0=')
+X0=G0_1*A0T*B0;
+disp(X0,'X0=')
+
+//by recursive least square algorithm
+G1=G0+A1'*A1;
+disp(G1,'G1=');
+G1_1=inv(G1);
+disp(G1_1,'Inverse of G1')
+X1=X0+G1_1*A1'*(B1-A1*X0);
+disp(X1,'X1=')
+
+//verification
+A=[3,0;0,3;3,3;6,3];
+B=[2;2;2;6];
+AT=A';
+G=AT*A;
+disp(G,'G=')
+G_1=inv(G);
+disp(G_1,'Inverse of G=')
+X=G_1*AT*B;
+disp(X,'X=')
+disp('Thus X and X1 are Same')
\ No newline at end of file |