cBook‎ > ‎

Positive/negative definite matrix

How to identify a matrix is Positive Definite

posted Sep 28, 2015, 10:04 AM by Javad Taghia

Matlab Code: http://www.mathworks.com/matlabcentral/answers/101132#answer_140036

A = [1,0;0,2]; % Example matrix
eig_A = eig(A);
flag = 0;
for i = 1:rank(A)
if eig_A(i) <= 0 
flag = 1;
end
end
if flag == 1
disp('the matrix is not positive definite')
else
disp('the matrix is positive definite')
end

Pivoting

posted Feb 23, 2015, 6:35 PM by Javad Taghia   [ updated Jul 2, 2015, 5:26 AM ]

Matlab code:
function R = pivot(M, r, c) % r and c are pivoting point 
[d, w] = size(M); % Get matrix dimensions
R = zeros(d, w); % Initialize to appropriate size
R(r,:) = M(r, :) / M(r,c); % Copy row r, normalizing M(r,c) to 1
for k = 1:d % For all matrix rows
if (k ~= r) % Other then r
R(k,:) = M(k,:) ... % Set them equal to the original matrix
- M(k,c) * R(r,:); % Minus a multiple of normalized row r, making R(k,c)=0
end
end
end

eg: A = [1 2 3; 2 3 4]; B = pivot(A, 1, 1); 

YouTube Video




Definition for 2 by 2

posted Feb 23, 2015, 4:37 PM by Javad Taghia   [ updated Feb 23, 2015, 5:26 PM ]

Theorem:
A= (a,b;c,d) is a 2 × 2 symmetric matrix A if:


1. positive definite if and only if a > 0 and det(A) > 0 
2. negative definite if and only if a < 0 and det(A) > 0
3. indefinite if and only if det(A) < 0 



YouTube Video


YouTube Video




1-3 of 3