MATLAB: Code for determinant.

detdeterminanthomework

I would like to built a code to find the determinant of a 24×24 matrix.I dont want to use the det(X) function,but a fuction that would be quick.
The one i created,whick is too slow for that.

Best Answer

NO NO NO!!!!!
First, you should not be using the determinant here. I don't know why you think you need to use it. But if you don't understand how to efficiently compute a determinant, the probability is 1 that you should not be using the determinant in the first place. There are far better tools to determine is amatrix issingular, which is why you are surely wanting to compute the determinant of a 24x24 matrix.
Ok, why is the code you wrote a an obscenely bad one? Do you understand that the code you wrote will require O(factorial(24)) computations to execute?
factorial(24)
ans =
6.20448401733239e+23
Even the largest supercomputer the NSA owns would grind to a miserable halt.
So, CAN you compute the determinant more efficiently? Well, yes. USE DET! (In fact there are ways to compute the determinant efficiently. But since you should not be using it in the first place, I won't go into details.)
So better yet, don't compute the determianant at all. So instead, you need to learn how to use tools like rank, cond or svd to do what you are trying to do. Of course, we don't really yet know what you are doing.