One can easily find the determinant of a matrix using recursion, but I was wondering if it is easy to calculate the determinant without using recursion, because recursion is very slow. Or is it too difficult to find the determinant without recursion?
Asked
Active
Viewed 3,360 times
-3
-
4Recursion isn't notably slower than iteration in a modern programming language. – zwol Jan 24 '14 at 15:47
-
Really? I don't believe so. You would use tons of stack for recursion. It would work for matrices upto certain sizes, but what about a 20x20 matrix? – MetallicPriest Jan 24 '14 at 15:47
-
1Yes, the determinant can readily get calculated without recursion with great difficulty. – chux - Reinstate Monica Jan 24 '14 at 15:49
-
Who said you have to copy the matrix every time you recurse? – zwol Jan 24 '14 at 15:51
-
What is up with this downvoting. It is a legit question! – MetallicPriest Jan 24 '14 at 15:52
-
2Your question seems to be soliciting a discussion, which isn't what StackOverflow is about. Either that or it could be percieved as a veiled attempt at "plz to be sending teh codez." – John Dibling Jan 24 '14 at 15:55
-
No, its not soliciting discussion. I am just asking if someone knows a more efficient solution for finding matrix determinant than recursion. – MetallicPriest Jan 24 '14 at 15:56
-
4I am not really a fan of the duplicate-question mechanism, but if you recast your question as "how do I compute a determinant efficiently" then it has already been answered here: https://stackoverflow.com/questions/2435133/what-is-the-best-matrix-determinant-algorithm and here: https://stackoverflow.com/questions/1886280/how-to-find-determinant-of-large-matrix The good algorithms are based on deep mathematical insights, not just "hey, this naive recursion uses too much stack." – zwol Jan 24 '14 at 15:57
1 Answers
1
Recursion can always be transformed into iteration and vice versa

Paul Evans
- 27,315
- 3
- 37
- 54
-
2Ya, but that transformation is usually very ugly. I want something neater. – MetallicPriest Jan 24 '14 at 15:49