Question 2
% Basis vectors
v1 = [0; 1; 2; 1];
v2 = [1; 5; 0; 1];
v3 = [2; 3; 6; 4];
v4 = [1; 3; -1; -1];
% Construct the basis matrix
B = [v1, v2, v3, v4];
% Calculate the transition matrix PS->B
PS_to_B = inv(B);
% Given vector x
x = [1; 2; 3; 4];
% Calculate the coordinates of x in the new basis B
x_B = PS_to_B * x;
% Print answers for part (a)
disp('Transition matrix PS->B:')
disp(PS_to_B)
disp('Coordinates of x in basis B:')
disp(x_B)
% Define the linear mapping L
L = @(x1, x2, x3, x4) [x2 + 5*x4; x1 - x3; x1 + x2 + x3 + x4; 0];
% Calculate the images of the basis vectors under L
L_B = [L(v1(1), v1(2), v1(3), v1(4)), L(v2(1), v2(2), v2(3), v2(4)), ...
L(v3(1), v3(2), v3(3), v3(4)), L(v4(1), v4(2), v4(3), v4(4))];
% Transition matrix to the new basis B
L_B = PS_to_B * L_B;
% Print the matrix [L]_B
disp('Matrix [L]_B:')
disp(L_B)
% Calculate the image of (x_B) under the linear map [L]_B
Lx_B = L_B * x_B;
% Print the image of (x_B)
disp('Image of (x_B) under [L]_B:')
disp(Lx_B)