ME5011A Mathematics for Engineers
Assignment - 5
Name: Dhanasekaran M
Roll no: 132514003
Ph.D Mechanical
3.b. Matlab code is given below:
%define a matrix Q
Q =1/3* [1 2 2;2 1 -2;2 -2 1];
format rational
% display the matrix Q
disp('The matrix Q is:')
disp(Q)
%define a diagonal matrix D (with the eigen values as diagonal element)
D = [3 0 0;0 3 0; 0 0 -6];
%calculate the inverse of Q
Qinv = inv(Q);
%define a matrix S
S= (Q*D)*(Qinv);
format rational
% display the matrix S
disp('The symmetric matrix S is:')
disp(S)
Matlab output:
The matrix Q is: The symmetric matrix S is:
1/3 2/3 2/3 -1 4 -2
2/3 1/3 -2/3 4 -1 2
-2 2 2
2/3 -2/3 1/3
7. Matlab code is given below:
%define a identity matrix I
I = [1 0 0 0;0 1 0 0;0 0 1 0; 0 0 0 1];
%define a matrix P
P =I;
P(2,:) = I(4,:);
P(4,:) = I(2,:);
%display the matrix P
disp('The matrix P is:')
disp(P)
% checkMatrixType Determines if a square matrix is symmetric, skew-symmetric, or
orthogonal.
% Check for Symmetric Matrix
if isequal(P', P)
disp('The matrix is Symmetric.')
end
% Check for Skew-Symmetric Matrix
if isequal(P',-P)
disp('The matrix is Skew-Symmetric.')
end
% Check for Orthogonal Matrix
if isequal(P',inv(P))
disp('The matrix is Orthogonal.')
end
%define a identity matrix B
B = [5 0 0 0; 0 15/2 0 -5/2; 0 0 5 0; 0 -5/2 0 15/2];
C=P'* B * P;
[V,D] = eig(C);
% Display eigen vectors of C
disp('The eigen vectors of C are:')
disp(V)
lamda = diag(D);
% Display eigen values of C
disp('The eigen values of C are:')
disp(lamda)
Matlab output:
The matrix P is: The eigen vectors of C are:
1 0 0 0 1 0 0 0
0 0 -985/1393 -985/1393
0 0 0 1 0 1 0 0
0 0 -985/1393 985/1393
0 0 1 0
0 1 0 0
The matrix is Symmetric.
The matrix is Orthogonal.
The eigen values of C are: The 4 invariants of the matrix C are:
5 5 5 10 I1: 25 I2: 225 I3: 875 I4: 1250
12.b. Matlab code is given below:
% Define range of a value to test the symmetric matrix
a_values = -20:0.01:20;
valid_a = [ ];
for a = a_values
%Define a symmetric form matrix A for the given quadratic equation
A = [1 -a/2; -a/2 4];
e = eig(A); % eigenvalues
if all(e >= -1e-5) % provide allowance for eigen value
valid_a = [valid_a a];
end
end
% Display result
fprintf('The given quadratic form is positive semi-definite for a in [%.2f, %.2f]\n', ...
min(valid_a), max(valid_a));
Matlab output:
The given quadratic form is positive semi-definite for a in [-
4.00, 4.00]
13.c.
%define a matrix A
A = [1 0 1;2 0 2];
%display the matrix Q
disp('The matrix A is:')
disp(A)
% Singular value decomposition of A is
[U,S,V] = svd(A)