if 0 {[Richard Suchenwirth] 2004-03-14 - The '''determinant''' of a square matrix is a scalar number that can be used for characterizing it (see http://mathworld.wolfram.com/Determinant.html : "If the determinant of a matrix is 0, the matrix is said to be singular, and if the determinant is 1, the matrix is said to be unimodular"). Here's some weekend fun code to compute the determinant of a matrix, represented as a list of lists:} proc det matrix { if {[llength $matrix] != [llength [lindex $matrix 0]]} { error "non-square matrix" } switch [llength $matrix] { 2 { foreach {a b c d} [join $matrix] break expr {$a*$d - $b*$c} } default { set i 0 set mat2 [lrange $matrix 1 end] set res 0 foreach element [lindex $matrix 0] { if $element { set sign [expr {$i%2? -1: 1}] set res [expr {$res + $sign*$element* [det [cancelcol $i $mat2]]}] } incr i } set res } } } proc cancelcol {n matrix} { set res {} foreach row $matrix { lappend res [lreplace $row $n $n] } set res } if 0 {Some tests, to see whether this code agrees with the examples in my math book: % det {{5 -3 2} {1 0 6} {3 1 -2}} -88 % det {{1 0 0} {0 1 0} {0 0 1}} 1 % det {{1 2} {3 4}} -2 % det {{2 4} {1 3}} 2 % det {{1 2 -1} {-2 1 3} {3 0 -2}} 11 % det {{1 2 -1 0} {-2 1 3 1} {3 0 -2 2} {1 2 3 4}} -20 % det {{1 1 1} {1 1 1} {1 1 1}} 0 ---- [TV] Not wanting to impose, the above can be seen true by taking the determinant as the product of the eigenvalues. ---- [Artur Trzewik] many years ago I have also plaed with linear algebra. This algorithm is correct but need n!. Because many det are computed multiple times it is posible by saving the results to get 2^n. There is my old tk program that compute also determinates (also for big precision n/m numbers). http://www.xdobry.de/tkmatrix/index.html It can compute det for matrices bigger then 30. The math part is programmed in c++ as tcl-extension. But this one is of course very elegant (as everything from RS) ---- Thank you :) Re performance - if the matrix isn't very sparse or repetitive, I expect that most of the sub-matrices used in calls do ''det'' will be different. But I'm only experimenting with small toy matrices anyway... Re eigenvalues: My math dictionary gives only a brief mention of them, too short for me to serve as "cooking recipe". Who knows better, please teach us, on a Wiki page! ---- [Arts and crafts of Tcl-Tk programming]