Advanced Mathematical Physics
Advanced Mathematical Physics
Advanced Mathematical Physics
Teachers Remarks
COMPUTATIONAL LAB FILE
SGTB KHALSA COLLEGE
UNIVERSITY OF DELHI
Advanced Mathematical Physics Signature
08/29/2020 10:27
Aim :
Code :
clear;clc; dett=s;
A=[0 1 2; 1 2 3;3 1 1 ] ; //defining matrix end
function [dett]=determinant(A) //function for determinant end
[n,m]=size(A); //dimension of matreix endfunction
if n==1 function [minor,cofactor]=mc(A) //function for minor,
dett=A(1,1); //determinant for 1X1 matrix cofactors
else if n==2 then [n,m]=size(A);
dett=A(1,1)*A(2,2)-A(1,2)*A(2,1); //determinant for 2X2 matrix for i=1:n
else for j=1:n
s=0; //inital value M_ij=A; //definig a matrix
A_ij=A; M_ij(i,:)=[] //deleting row
A_ij(1,:)=[]; //deletinG row D_ij=M_ij //Storing value of M_ij in D_ij
for i=1:n D_ij(:,j)=[] //deleting column
C_ij=A_ij; //storing value of A_ij in C_ij minor(i,j)=determinant(D_ij); //minor function
C_ij(:,i)=[]; //deleting column cofactor(i,j)=((-1)^(i+j))*minor(i,j) //cofactor function
s=s+((-1)^(i+1))*A(1,i)*determinant(C_ij); //formula of determinant end
for higher matrix end
end endfunction
disp(A,'Orignal matrix=')
dettt=determinant(A) //putting value of determinant in dettt
disp(dettt,'determinant=')
d_in=det(A) //inbuilt value of determinant
disp(d_in,'determinant inbuilt')
[m,c]=mc(A)
adj=(c)' //adjoint formula
if dettt==0 then
disp('inverse isnt exist') //inverse doesnt exist as determinant is 0
else
inverse=adj/dettt; //if determinant nonzero then inverse exist,
disp(inverse,'inverse=')
end
invv=inv(A); //inbuilt inverse value
disp(invv,'inverse inbuilt=')
disp(m,'minor=') //minor
disp(c,'cofactor=') //cofactor
disp(adj,'adjoint=') //adjoint
I=A*inverse //checking up A^-1*A
disp(I,'A*A^-1=')
Plots :
Comments :