Math 449 - Homework 3 - Solutions 1) Exercise 1 (iii), section 3.1, p. 108. Given the vectors X=(4, -8, 1), Y=(1, -12, -11), (a) X + Y = (5, -20, -10); (b) X - Y = (3, 4, 12); (c) 3*X = (12, -24, 3); (d) ||X|| = (4^2+(-8)^2+1^2)^(1/2) = 9; (e) 7*Y - 4*X = (7, -84, -77) - (16, -32, 4) = (-9, -52, -81); (f) X.Y = 4*1 + (-8)*(-12) + 1*(-11) = 89; (g) ||7*Y - 4*X|| = ((-9)^2 + (-52)^2 + (-81)^2)^(1/2) = (9346)^(1/2) (approx. = 96.675); ************************************************************************** 2) Exercise 6 of section 3.1, page 109. (a) and (c) are symmetric, but (b) and (d) are not. ************************************************************************** 3) Exercise 8 of section 3.2, page 109. The inverse matrix of A*B is the unique matrix D such that D*(A*B)=I. So it suffices to show that B^(-1)*A^(-1) has this property. And, in fact, (B^(-1)*A^(-1))*(A*B) = B^(-1)*(A^(-1)*(A*B)) = B^(-1)*((A^(-1)*A)*B) = B^(-1)*(I*B) = B^(-1)*B = I ************************************************************************** 4) Exercise 14 of section 3.2, page 109. The (i,j)-entry of the matrix (A*B)' is equal to the (j,i)-entry of A*B, which is (A*B)(j,i) = A(j,1)*B(1,i) + A(j,2)*B(2,i) + ... + A(j,n)*B(n,i), whereas the (i,j)-entry of B'*A' is (B'*A')(i,j) = B'(i,1)*A'(1,j) + B'(i,2)*A'(2,j) + ... + B'(i,n)*A'(n,j) = B(1,i)*A(j,1) + B(2,i)*A(j,2) + ... + B(n,i)*A(j,n) = A(j,1)*B(1,i) + A(j,2)*B(2,i) + ... + A(j,n)*B(n,i). Since the two expressions agree for all (i,j), we must have (A*B)'=B'*A'. ************************************************************************** 5) Do Algorithms and Programs 2 of section 3.2, page 120. Let Rx(a), Ry(b), Rz(c) be the rotation matrices about the x, y, z-axes by angles a, b, c, respectively, as shown on page 115. We wish to transform the cube under the rotation matrix R=Rz(pi/6)*Rx(pi/12). Thus we have Rz=[cos(pi/6) -sin(pi/6) 0; sin(pi/6) cos(pi/6) 0; 0 0 1]; Rx=[1 0 0; 0 cos(pi/12) -sin(pi/12); 0 sin(pi/12) cos(pi/12)]; R=Rz*Rx; The vertices of the cube in initial position are v0=[0 0 0]; v1=[0 0 1]; v2=[0 1 0]; v3=[0 1 1]; v4=[1 0 0]; v5=[1 0 1]; v6=[1 1 0]; v7=[1 1 1]; We can draw the cube by tracing the polygonal curve along the edges of the cube in the order of the rows of the matrix A below. (Can you find a more efficient way? Note that I'm tracing a few edges more than once.) A = [v0; v1; v3; v2; v6; v4; v5; v7; v6; v4; v0; v2; v3; v7; v5; v1]; You can plot the cube in initial position using the Matlab command: >>plot3(A(:,1), A(:,2), A(:,3)) >>axis equal >>grid To plot the rotated cube by Rx, note that (Rx*A')'=A*Rx' gives the edge-path of the cube in this new position. So, write >>A=A*Rx'; and use the same plot command above. Similarly, the third position is given by the edge-path >>A=A*Rz'; ************************************************************************** 6) Exercise 6 of section 3.3, page 124. We want to solve the system 5*x_1 =-10 x_1 + 3*x_2 = 4 3*x_1 + 4*x_2 + 2*x_3 = 2 -x_1 + 3*x_2 - 6*x_3 - x_4 = 5 Let A be the lower triangular matrix of coefficients for the above system. It is immediate that det(A)=5*3*2*(-1) = -30, so there is a unique solution. The solution is: x_1 = -10/5 =-2 x_2 = (4 - x_1)/4 = (4 + 2)/3 = 2 x_3 = (2 - 3*x_1 - 4*x_2)/2 = (2 + 6 - 8)/2 = 0 x_4 = (5 + x_1 - 3*x_2 + 6*x_3)/(-1) = -(5 - 2 - 6 + 0) = 3. ************************************************************************** 7) Algorithms and Programs 2 and 3 of section 3.3, page 125. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % function X=forsub(A,B) %Input - A is a n x n lower-triangular nonsingular matrix % - B is a n x 1 matrix %Output - X is the solution to the linear system AX = B % n=length(B); X=zeros(n,1); X(1)=B(1)/A(1,1); for k=2:n X(k)=(B(k)-A(k,1:k-1)*X(1:n))/A(k,k); end % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% We now apply this to the system AX=B, where A is the 20 x 20 matrix whose (i,j)-entry is i+j if i>=j and 0 otherwise; and B is the 20 x 1 matrix whose (i,1)-entry is i. Thus, A=zeros(20,20); for i=1:20 for j=1:i A(i,j)=i+j; end end for i=1:20 B(i)=i; end Setting X=forsub(A,B) we obtain X=[ 0.5000; 0.1250; 0.0625; 0.0391; 0.0273; 0.0205; 0.0161; 0.0131; 0.0109; 0.0093; 0.0080; 0.0070; 0.0062; 0.0055; 0.0050; 0.0045; 0.0041; 0.0038; 0.0035; 0.0032] **************************************************************************