This is a Java Script calculator that evaluates a 5 by 5 determinant. To operate the calculator, enter the values of the elements of the determinant. Press the Compute button to evaluate the determinant. On invalid entries, the Value window will display:
Error
Return to Contents
The Java Script source code for this program can be viewed by using the View|Source command of your web browser.
You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitability of this source code for your use.
Return to Contents
The determinant is an algebraic operation that transforms a square matrix into a scalar. This operation has many useful and important properties. For example, the determinant is zero if and only if the corresponding system of homogeneous equations is singular. Also, when the rows correspond to vectors it gives the area of a parallelogram and the volume of a parallelepiped.
definition
The determinant is the algebraic sum of all possible products where the number of factors in each product is the same as the number of rows or columns, each factor in a given product is taken from a different row and column. For each factor, if the order of the rows was achieved by an even number of swaps, it is positive; if odd, it is negative. For example:
A 2 x 2 determinant requires (2-1)·2! = 2 multiplications
det(A) = a11a22 - a12a21
A 3 x 3 determinant requires (3-1)·3! = 12 multiplications
det(A) = a11a22a33 - a11a23a32
+ a12a23a31 - a12a21a33
+ a13a21a32 - a13a22a31
A 4 x 4 determinant requires (4-1)·4! = 72 multiplications
det(A) = a11a22a33a44 - a11a22a34a43 + a11a23a34a42 - a11a23a32a44 + a11a24a32a43 - a11a24a33a42
- a12a23a34a41 + a12a23a31a44 - a12a24a31a43 + a12a24a33a41 - a12a21a33a44 + a12a21a34a43
+ a13a24a31a42 - a13a24a32a41 + a13a21a32a44 - a13a21a34a42 + a13a22a34a41 - a13a22a31a44
- a14a21a32a43 + a14a21a33a42 - a14a22a33a41 + a14a22a31a43 - a14a23a31a42 + a14a23a32a41
using recursion
The determinant of a square matrix can be calculated by using expansion by minors.
A minor Mij of the matrix A is the determinant of the n-1 by n-1 matrix formed by removing the ith row and the jth column from matrix A.
The determinant is calculated from the sum of minors multiplied by cofactors taken over a single row or column:
In which Cij is the cofactor of aij is, Cij = (-1)i+j·Mijdet(A) = ∑ aij·Cij
Any row or column can be chosen across which to take the sum, when computing manually it is best to choose the row or column with the most zeros to minimize the amount of work. If the first row is chosen for the sum then the determinant in terms of the minors would be,
det(A) = a11·M11 - a12·M12 + a13·M13 - . . . + a1n·M1n
The recursive process to calculate a determinant is to apply the formula above to the determinant, then to each minor of the determinant, then to each minor of the minor of the preceeding step until a simple calculation can be performed. A recursive algorithm for finding the determinant of a matrix is as follows:
function det( a, n )
if n = 2 then
d := a11·a22 - a12·a21
else
d := 0
for i := 1...n do
M1i <-- A with row 1 and column i deleted
d := d + (-1)(i-1)·a1i·det( M1i, n - 1 )
end for
end if
return d
end function
The number of multiplications required can be calculated from the sequence
By doing some algebra,m2 = 2 mk = k·mk-1 + k
we get the explicit formula:mk = k·k-1·...·2 + k·k-1·...·3 + k·k-1·...·4 . . . + k mk = k!·[1/1! + 1/2! + 1/3! + . . . + 1/(k - 1)!]
As k becomes large, mk --> k!·(e - 1). The amount of computation for increases asymptotically as fast as n! - where n is the dimension of the determinant. As shown above, directly calculating all the permutations requires n!·(n - 1) computations; recursion reduces the amount of computation required by ≈(n - 1)/(e - 1).mk = k!·∑ 1/n!
Elementary Mathematical Analysis
Return to Contents
AbCd Classics - free on-line books