Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Comp Maths Model Solutions 9 1 1. Can choose your own numbers, but here’s my example of how it works: >> a = [1 2 3]; >> b = [3 2 1]; >> c = [2 3 1]; >> cross(a,cross(b,c)) ans = 13 -8 1 >> dot(a,c)*b-dot(a,b)*c ans = 13 -8 1 >> dot(a,cross(b,c))*a ans = 12 24 36 >> cross(cross(a,b),cross(a,c)) ans = 12 24 36 2. So set matrix and RHS vector and then invert >> A = [3 -1 4 ; 0 1 -1; 2 6 -1]; >> b = [0 ; 1 ; 1] >> x = A\b x = 2.22222 -0.88889 -1.88889 3. (a) Here’s the code... a bit long but there are no obvious short-cuts. function r = vecmap(x,alpha,beta,gamma) Rx = zeros(3,3); Ry = zeros(3,3); Rz = zeros(3,3); Rx(1,1) = 1; Rx(2,2) = cos(alpha); Rx(2,3) = -sin(alpha); Rx(3,3) = cos(alpha); Rx(3,2) = sin(alpha); Ry(2,2) = 1; Ry(1,1) = cos(beta); 1 c University of Bristol 2016 This material is copyright of the University of Bristol unless explicitly stated. It is provided exclusively for educational purposes at the University of Bristol and is to be downloaded or copied for your private study only. 1 Ry(1,3) = sin(beta); Ry(3,3) = cos(beta); Ry(3,1) =-sin(beta); Rz(3,3) = 1; Rz(1,1) = cos(gamma); Rz(1,2) =-sin(gamma); Rz(2,2) = cos(gamma); Rz(2,1) = sin(gamma); r = Rz*Ry*Rx*x; end (b) Set x = [1 ; 1 ; 1]; and call r = vecmap(x,pi,pi,pi) to find r = (1, 1, 1)T . So mapping leaves position vector unchanged. Easy to see geometrically that rotation by π around each axis will get you back to the starting position. Alternatively, it’s easy to see from their definition that Rz (π)Ry (π)Rx (π) = I. (c) The condition RT = R−1 is equivalent to RRT = I and for each of the three matrices this is easy to confirm. Indeed, once you can done one of them the others are basically the same. If we have r = Rz (γ)Ry (β)Rx (α)x then it follows that −1 −1 T T T x = R−1 x (α)Ry (β)Rz (γ)r = Rx (α)Ry (β)Rz (γ)r and this is the inverse mapping. 4. (a) Here’s the code A = rand(2,2); d = eig(A) x = [1 ; 1]; inv(eye(2)-A)*x y = x; m = 200; for j=1:m y = x + A*y; end y % % % % % % set A to be a random 2x2 matrix print eigenvalues of A define x to be the column vector (1,1)^T print (I-A)^{-1}x set y to first term the sequence, y_0 set m % update y using the recurrence relation given % print the value of the series (b) Run the script: E.g. of output when eigenvalues (d)less than unity in modulus: d = 0.923550826838525 -0.811043090074474 ans = 12.9566641630964 2 13.2144570358461 y = 12.9566626842223 13.2144555262378 5. det(A) = 0 if and only if det(A − 0I) = 0 and so there is a λ = 0. 6. (a) True. Do >> det(A) and >> d = eig(A); followed by >> d(1)*d(2)*d(3)*d(4) (b) True. >> d = eig(A) and >> e = eig(A’) give the same answers. (c) True. >> d = eig(A) and >> e = eig(inv(A)); followed by >> 1./e to reciprocate the output. (d) False. >> d = eig(A*B) is not the same as >> e = eig(A).*eig(B). (e) False. >> d = eig(A+B) is not the same as >> e = eig(A)+eig(B). 7. This: 0.4 0.2 0 -0.2 -0.4 -1 0 1 2 3 4 5 6 Figure 1: Output from the code given in Q7 with n = 120. Observe two distinct regions of eigenvalues – one occupying a circular domain of fixed radius approximately 0.3 and a set of real eigenvalues which vary in position with n. 3