# How to calculate determinant in PCA?

2 views (last 30 days)
Tanya on 16 Feb 2014
Commented: Roger Stafford on 17 Feb 2014
Im going to program PCA, but for that, I have to calculate the Eigen Vector and Eigen Value.
My question is in calculate the eigen value we have to calculate the determinant of the matrix which all the (diagonal value - lamda).
In this case we can consider the number of lamda Depends on the matrix dimension.
I can program it manually for the matriks before the diagonal substracted by lamda.
But for the diagonal after substracted by lamda, how to calculate it??
Because, eventually we have to do factorisation to get the lamda (x1,x2,..,xn).
Here is the example :
Matriks =[ 3 5 6
5 7 4
3 8 9]
Then we have to substract the diagonal value with eigen value, in this case because we havent knoen it, we will consider it as x.
Matrix_New=[ 3-x 5 6
5 7-x 4
3 8 9-x]
And the determinant is (3-x)(7-x)(9-x).
I already tried to multiply it, but matlab gives error. Do u know how to do calculation (3-x)(7-x)(9-x) ??
I know there is matlab function, but Im not allowed to use it!!
I really appriciate any help :)

Roger Stafford on 16 Feb 2014
To say "calculate the eigen value we have to calculate the determinant of the matrix which all the (diagonal value - lamda)" is saying things a little backwards. What you need to do is to determine the possible values of lambda that would make that determinant equal to zero.
Your attempt to find an expression for the determinant is flawed. It would really be:
(3-x)*(7-x)*(9-x)+5*4*3+6*8*5-(3-x)*8*4-(7-x)*3*6-(9-x)*5*5
= 42-36*x+19*x^2-x^3 = 0
So then you need to find the three values of x which are roots of this last equation. These will be your eigenvalues. That is not so easy to do. You can either use matlab's 'roots' function, or if you are not allowed to do that, there does exist a rather complicated solution to cubic equations which you can find on the internet.
http://en.wikipedia.org/wiki/Cubic_function
##### 2 CommentsShowHide 1 older comment
Roger Stafford on 17 Feb 2014
You cannot solve (3-x) numerically if x is unknown. That is obvious. However, you can use matlab's symbolic toolbox to simplify the expression for your determinant in terms of x. In fact that is what I did to obtain 42-36*x+19*x^2-x^3. As I mentioned before, your task is not to evaluate this determinant, but to find the value or values of x which give the determinant a value of zero. These x values will be your eigenvalues.