diff options
Diffstat (limited to '26/CH2')
-rwxr-xr-x | 26/CH2/EX2.1.1/2_1_1.sce | 10 | ||||
-rwxr-xr-x | 26/CH2/EX2.2.1/2_2_1.sce | 5 | ||||
-rwxr-xr-x | 26/CH2/EX2.2.7/2_2_7.sce | 9 | ||||
-rwxr-xr-x | 26/CH2/EX2.3.1/2_3_1.sce | 6 | ||||
-rwxr-xr-x | 26/CH2/EX2.3.33/2_3_33.sce | 10 | ||||
-rwxr-xr-x | 26/CH2/EX2.4.25/2_4_25.sce | 29 | ||||
-rwxr-xr-x | 26/CH2/EX2.5.1/2_5_1.sce | 45 | ||||
-rwxr-xr-x | 26/CH2/EX2.5.13/2_5_13.sce | 19 | ||||
-rwxr-xr-x | 26/CH2/EX2.5.7/2_5_7.sce | 14 | ||||
-rwxr-xr-x | 26/CH2/EX2.6.1/2_6_1.sce | 9 | ||||
-rwxr-xr-x | 26/CH2/EX2.6.7/2_6_7.sce | 15 | ||||
-rwxr-xr-x | 26/CH2/EX2.7.1/2_7_1.sce | 17 | ||||
-rwxr-xr-x | 26/CH2/EX2.7.7/2_7_7.sce | 11 | ||||
-rwxr-xr-x | 26/CH2/EX2.8.23/2_8_23.sce | 20 | ||||
-rwxr-xr-x | 26/CH2/EX2.8.25/2_8_25.sce | 21 | ||||
-rwxr-xr-x | 26/CH2/EX2.8.7/2_8_7.sce | 20 | ||||
-rwxr-xr-x | 26/CH2/EX2.9.13/2_9_13.sce | 22 |
17 files changed, 282 insertions, 0 deletions
diff --git a/26/CH2/EX2.1.1/2_1_1.sce b/26/CH2/EX2.1.1/2_1_1.sce new file mode 100755 index 000000000..31c397c92 --- /dev/null +++ b/26/CH2/EX2.1.1/2_1_1.sce @@ -0,0 +1,10 @@ +A=[2 0 -1;4 -5 2];
+disp('matrix A:')
+disp(A)
+disp('-2A=')
+disp(-2*A)
+disp('matrix B')
+B=[7 -5 1;1 -4 -3];
+disp(B)
+disp('B-2A=')
+disp(B-2*A)
\ No newline at end of file diff --git a/26/CH2/EX2.2.1/2_2_1.sce b/26/CH2/EX2.2.1/2_2_1.sce new file mode 100755 index 000000000..418dcc238 --- /dev/null +++ b/26/CH2/EX2.2.1/2_2_1.sce @@ -0,0 +1,5 @@ +disp('given matrix:')
+a=[8 6;5 4];
+disp(a)
+disp('inverse of the matrix is:')
+disp(inv(a))
\ No newline at end of file diff --git a/26/CH2/EX2.2.7/2_2_7.sce b/26/CH2/EX2.2.7/2_2_7.sce new file mode 100755 index 000000000..3df602ad4 --- /dev/null +++ b/26/CH2/EX2.2.7/2_2_7.sce @@ -0,0 +1,9 @@ +disp('the co-efficient matrix is:')
+a=[1 2;5 12]
+disp(a)
+disp('inverse of the matrix is:')
+disp(inv(a))
+disp('solution is:')
+b=[-1;3];
+c=inv(a);
+disp(c*b)
\ No newline at end of file diff --git a/26/CH2/EX2.3.1/2_3_1.sce b/26/CH2/EX2.3.1/2_3_1.sce new file mode 100755 index 000000000..5b3c61e9e --- /dev/null +++ b/26/CH2/EX2.3.1/2_3_1.sce @@ -0,0 +1,6 @@ +disp('the given matrix is:')
+a=[5 7;-3 -6];
+disp(a)
+disp('the columns are lineraly independent')
+disp('hence, by invertible matrix theorem')
+disp('the matrix A is invertible')
\ No newline at end of file diff --git a/26/CH2/EX2.3.33/2_3_33.sce b/26/CH2/EX2.3.33/2_3_33.sce new file mode 100755 index 000000000..c09bf4b98 --- /dev/null +++ b/26/CH2/EX2.3.33/2_3_33.sce @@ -0,0 +1,10 @@ +disp('matrix A corresponding to transformation T is:')
+A=[-5 9;4 -7];
+disp(A)
+disp('determinant of A is:')
+disp(det(A))
+disp('since det(A) is not equal to zero')
+disp('by IMT, A is invertible')
+disp('hence, the inverse of A exists')
+disp('inverse of A is:')
+disp(inv(A))
\ No newline at end of file diff --git a/26/CH2/EX2.4.25/2_4_25.sce b/26/CH2/EX2.4.25/2_4_25.sce new file mode 100755 index 000000000..985a344eb --- /dev/null +++ b/26/CH2/EX2.4.25/2_4_25.sce @@ -0,0 +1,29 @@ +disp('given matrix is:')
+a=[1 2 0 0 0;3 5 0 0 0;0 0 2 0 0;0 0 0 7 8;0 0 0 5 6];
+disp(a)
+disp('partitioning the matrix into 4 submatrices')
+A11=[a(1,1:2);a(2,1:2)]
+disp(A11,'A11=')
+A22=[a(3,3:5);a(4,3:5);a(5,3:5)]
+disp(A22,'A22=')
+A12=zeros(2,3)
+disp(A12,'A12=')
+A21=zeros(3,2)
+disp(A21,'A21=')
+disp('partitioning A22 into 4 submatrices')
+A221=[2]
+disp(A221)
+B=[A22(2,2:3);A22(3,2:3)]
+disp(B,'B=')
+disp(zeros(1,2))
+disp(zeros(2,1))
+disp('determinant of B=')
+disp(det(B))
+disp('Hence, B is invertible')
+disp('inverse of B is')
+disp(inv(B))
+disp('determinant of inverse of B is:')
+disp(det(inv(B)))
+disp('hence the invese of A22 is:')
+c=[det(inv(B)) zeros(1,2);0 3 -4;0 -2.5 3.5];
+disp(c)
\ No newline at end of file diff --git a/26/CH2/EX2.5.1/2_5_1.sce b/26/CH2/EX2.5.1/2_5_1.sce new file mode 100755 index 000000000..591f40ab1 --- /dev/null +++ b/26/CH2/EX2.5.1/2_5_1.sce @@ -0,0 +1,45 @@ +disp('the lower triangular matrix is:')
+L=[1 0 0;-1 1 0;2 -5 1];
+disp(L)
+disp('the upper triangular matrix is:')
+U=[3 -7 -2;0 -2 -1;0 0 -1];
+disp(U)
+disp('the RHS of the equations are')
+b=[-7;5;2];
+disp(b)
+disp('combining matrices L and b')
+c=[L b];
+disp(c)
+disp('performing row operations')
+disp('R2=R2+R1')
+c(2,:)=c(2,:)+c(1,:)
+disp(c)
+disp('R3=R3-2*R1')
+c(3,:)=c(3,:)-2*c(1,:)
+disp(c)
+disp('R3=R3+5*R2')
+c(3,:)=c(3,:)+5*c(2,:)
+disp(c)
+y=c(:,4)
+disp(y,'y=')
+disp('combining U and y')
+d=[U y];
+disp(d)
+disp('performing row operations')
+disp('R3=R3/-6')
+d(3,:)=d(3,:)/(-1)
+disp(d)
+disp('R2=R2+R3 and R1=R1+2*R3')
+d(2,:)=d(2,:)+d(3,:)
+d(1,:)=d(1,:)+2*d(3,:)
+disp(d)
+disp('R1=R1-3.5*R2')
+d(1,:)=d(1,:)-3.5*d(2,:)
+disp(d)
+disp('R1=R1/3 and R2=R2/-2')
+d(1,:)=d(1,:)/3
+d(2,:)=d(2,:)/(-2)
+disp(d)
+disp('the solution is:')
+x=d(:,4)
+disp(x,'x=')
\ No newline at end of file diff --git a/26/CH2/EX2.5.13/2_5_13.sce b/26/CH2/EX2.5.13/2_5_13.sce new file mode 100755 index 000000000..9f35269eb --- /dev/null +++ b/26/CH2/EX2.5.13/2_5_13.sce @@ -0,0 +1,19 @@ +disp('given matrix is:')
+a=[1 3 -5 -3;-1 -5 8 4;4 2 -5 -7;-2 -4 7 5]
+d=a;
+disp(a)
+disp('performing row operations')
+p21=a(2,1)/a(1,1);p31=a(3,1)/a(1,1);p41=a(4,1)/a(1,1);
+a(2,:)=a(2,:)-p21*a(1,:)
+a(3,:)=a(3,:)-p31*a(1,:)
+a(4,:)=a(4,:)-p41*a(1,:)
+disp(a)
+p32=a(3,2)/a(2,2);p42=a(4,2)/a(2,2)
+a(3,:)=a(3,:)-p32*a(2,:)
+a(4,:)=a(4,:)-p42*a(2,:)
+disp(a)
+disp('thus, lower triangular matrix is:')
+L=[1 0 0 0;p21 1 0 0;p31 p32 1 0;p41 p42 0 1]
+disp(L,'L=')
+disp('Upper triangular matrix is:')
+disp(a,'U=')
\ No newline at end of file diff --git a/26/CH2/EX2.5.7/2_5_7.sce b/26/CH2/EX2.5.7/2_5_7.sce new file mode 100755 index 000000000..22c2cd9ee --- /dev/null +++ b/26/CH2/EX2.5.7/2_5_7.sce @@ -0,0 +1,14 @@ +disp('given matrix is:')
+a=[2 5;-3 -4]
+d=a;
+disp(a)
+disp('performing row operations')
+a(2,:)=a(2,:)-(a(2,1)/a(1,1))*a(1,:)
+disp(a)
+disp(a)
+disp('thus, the upper triangular matrix is')
+U=a;
+disp(U,'U=')
+disp('the lower triangular matrix is:')
+L=[1 0;d(2,1)/d(1,1) 1];
+disp(L,'L=')
\ No newline at end of file diff --git a/26/CH2/EX2.6.1/2_6_1.sce b/26/CH2/EX2.6.1/2_6_1.sce new file mode 100755 index 000000000..206e97991 --- /dev/null +++ b/26/CH2/EX2.6.1/2_6_1.sce @@ -0,0 +1,9 @@ +disp('the consumption matrix is:')
+C=[.1 .6 .6;.3 .2 0;.3 .1 .1];
+disp(C)
+disp('Assuming that agriculture plans to produce 100 units and other units produce nothing')
+disp('the production vector is given by')
+x=[0;100;0];
+disp(x,'x=')
+disp('thus the intermediate demand is:')
+disp(C*x)
\ No newline at end of file diff --git a/26/CH2/EX2.6.7/2_6_7.sce b/26/CH2/EX2.6.7/2_6_7.sce new file mode 100755 index 000000000..39cc4b315 --- /dev/null +++ b/26/CH2/EX2.6.7/2_6_7.sce @@ -0,0 +1,15 @@ +disp('the consumption matrix is:')
+C=[0 .5;.6 .2];
+disp(C)
+disp('the demand for 1 unit of output sector 1')
+d1=[1;0]
+disp(d1)
+disp('the production required to satisfy demand d1 is:')
+x1=inv(eye(2,2)-C)*d1
+disp(x1,'x1=')
+disp('the final demand is:')
+d2=[51;30]
+disp(d2,'d2=')
+disp('the production required to satisfy demand d2 is:')
+x2=inv(eye(2,2)-C)*d2
+disp(x2,'x2=')
\ No newline at end of file diff --git a/26/CH2/EX2.7.1/2_7_1.sce b/26/CH2/EX2.7.1/2_7_1.sce new file mode 100755 index 000000000..2c2dd056b --- /dev/null +++ b/26/CH2/EX2.7.1/2_7_1.sce @@ -0,0 +1,17 @@ +disp('consider the matrix')
+a=[1 .25 0;0 1 0;0 0 1]
+disp(a)
+disp('consider a vector')
+x=[6;8;0]
+disp(x)
+disp('the effect of the matric on the vector is:')
+disp(a*x)
+disp('now consider the matrix:')
+b=[1 .25;0 1]
+disp(b)
+disp('considering the same vector')
+x1=[6;8]
+disp(x1)
+disp('the effect of the new matrix on the vector is:')
+disp(b*x1)
+disp('thus we can see that the two matrices have the same effect on vectors')
\ No newline at end of file diff --git a/26/CH2/EX2.7.7/2_7_7.sce b/26/CH2/EX2.7.7/2_7_7.sce new file mode 100755 index 000000000..2fe440582 --- /dev/null +++ b/26/CH2/EX2.7.7/2_7_7.sce @@ -0,0 +1,11 @@ +disp('the matrix in R2 to rotate a vector by 60 degrees is:')
+a=[cos(%pi/3) -sin(%pi/3);sin(%pi/3) cos(%pi/3)]
+disp(a)
+x=[6;8]
+disp(x,'x=')
+disp('so the 3X3 matrix for rotation about x is:')
+y=[1 0 6;0 1 8;0 0 1]
+z=[1 0 -6;0 1 -8;0 0 1]
+a=[cos(%pi/3) -sin(%pi/3) 0;sin(%pi/3) cos(%pi/3) 0;0 0 1]
+R=y*(a*z)
+disp(R)
\ No newline at end of file diff --git a/26/CH2/EX2.8.23/2_8_23.sce b/26/CH2/EX2.8.23/2_8_23.sce new file mode 100755 index 000000000..14c68ea25 --- /dev/null +++ b/26/CH2/EX2.8.23/2_8_23.sce @@ -0,0 +1,20 @@ +disp('the given matrix is:')
+a=[4 5 9 -2;6 5 1 12;3 4 8 -3]
+disp(a)
+disp('performing row operaions')
+a(2,:)=a(2,:)-(a(2,1)/a(1,1))*a(1,:)
+a(3,:)=a(3,:)-(a(3,1)/a(1,1))*a(1,:)
+disp(a)
+a(3,:)=a(3,:)-(a(3,2)/a(2,2))*a(2,:)
+disp(a)
+a(1,:)=a(1,:)/a(1,1)
+a(2,:)=a(2,:)/a(2,2)
+disp(a)
+for i=1:3
+ for j=i:4
+ if(a(i,j)<>0)
+ disp('is a pivot column',j,'column')
+ break
+ end
+ end
+ end
\ No newline at end of file diff --git a/26/CH2/EX2.8.25/2_8_25.sce b/26/CH2/EX2.8.25/2_8_25.sce new file mode 100755 index 000000000..f66b24d21 --- /dev/null +++ b/26/CH2/EX2.8.25/2_8_25.sce @@ -0,0 +1,21 @@ +disp('the given matrix is:')
+a=[1 4 8 -3 -7;-1 2 7 3 4;-2 2 9 5 5;3 6 9 -5 -2]
+disp(a)
+disp('performing row operations')
+a(2,:)=a(2,:)-(a(2,1)/a(1,1))*a(1,:)
+a(3,:)=a(3,:)-(a(3,1)/a(1,1))*a(1,:)
+a(4,:)=a(4,:)-(a(4,1)/a(1,1))*a(1,:)
+disp(a)
+a(3,:)=a(3,:)-(a(3,2)/a(2,2))*a(2,:)
+a(4,:)=a(4,:)-(a(4,2)/a(2,2))*a(2,:)
+disp(a)
+a(4,:)=a(4,:)-(a(4,4)/a(3,4))*a(3,:)
+disp(a)
+for i=1:4
+ for j=i:5
+ if(a(i,j)<>0)
+ disp('is a pivot column',j,'column')
+ break
+ end
+ end
+end
\ No newline at end of file diff --git a/26/CH2/EX2.8.7/2_8_7.sce b/26/CH2/EX2.8.7/2_8_7.sce new file mode 100755 index 000000000..b764b5efb --- /dev/null +++ b/26/CH2/EX2.8.7/2_8_7.sce @@ -0,0 +1,20 @@ +disp('the given matrix is:')
+A=[2 -3 -4;-8 8 6;6 -7 -7]
+disp(A,'A=')
+disp('the given vector is:')
+p=[6;-10;11]
+disp(p,'p=')
+disp('combining A and p')
+b=[A p]
+disp(b)
+disp('performing row operations')
+b(2,:)=b(2,:)-(b(2,1)/b(1,1))*b(1,:)
+b(3,:)=b(3,:)-(b(3,1)/b(1,1))*b(1,:)
+disp(b)
+b(3,:)=b(3,:)-(b(3,2)/b(2,2))*b(2,:)
+disp(b)
+if(b(3,3)==0 & b(3,4)==0)
+ disp('p lies in column space of A')
+ else
+ disp('p does not lie in column space of A')
+ end
\ No newline at end of file diff --git a/26/CH2/EX2.9.13/2_9_13.sce b/26/CH2/EX2.9.13/2_9_13.sce new file mode 100755 index 000000000..4e0ec53f2 --- /dev/null +++ b/26/CH2/EX2.9.13/2_9_13.sce @@ -0,0 +1,22 @@ +disp('the given matrix is:')
+a=[1 -3 2 -4;-3 9 -1 5;2 -6 4 -3;-4 12 2 7]
+disp(a)
+disp('performing row operations')
+a(2,:)=a(2,:)-(a(2,1)/a(1,1))*a(1,:)
+a(3,:)=a(3,:)-(a(3,1)/a(1,1))*a(1,:)
+a(4,:)=a(4,:)-(a(4,1)/a(1,1))*a(1,:)
+disp(a)
+a(4,:)=a(4,:)-2*a(2,:)
+disp(a)
+a(4,:)=a(4,:)-a(3,:)
+disp(a)
+k=0
+for i=1:4
+ for j=i:4
+ if(a(i,j)<>0)
+ k=k+1
+ break
+ end
+ end
+end
+disp(k,'dimension of the matrix=')
\ No newline at end of file |