[3.27] Fast Symbolic Determinants - Texas Instruments TI-89 Tip List

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

[3.27] Fast symbolic determinants

The TI-89/92+ may take quite a while to find some symbolic determinants with det(). For example, a
HW2 TI-92+ takes about 11 seconds to return the determinant of this matrix:
a
b
c
d sin ( e ) f
g
h
i
Timité Hassan has written an excellent replacement for det() called det2(), which returns the
determinant in about a second. You can get this routine at http://www.ti-cas.org. You will see similar
execution time improvements when the matrix elements are exact numeric expressions involving
square roots. Some floating-point determinants may be calculated more accurately.
I made some minor changes to Timité's code; I call this new function det2a(). I changed the local
variable names, which reduced the code size considerably. I also defined the function is_0() within the
function, so it is self-contained. I changed the returned error message strings. My modified routine is
shown below.
det2a(m)
Func
©(mat) symbolic determinant
©T. Hassan
©Modified 4nov01/dburkett@infinet.com
Local n,k,i,j,q,p,r,is_0
Define is_0(z)=Func
when(z=0,true,false,false)
EndFunc
If getType(m)≠"MAT"
Return
"det2a:Invalid argument"
dim(m)→n
If n[1]≠n[2]
Return "det2a:Not square matrix"
n[1]→n
If n=1 Then
Return m[1,1]
ElseIf n=2 Then
Return m[1,1]*m[2,2]-m[2,1]*m[1,2]
ElseIf n=3 Then
Return
m[1,1]*(m[2,2]*m[3,3]-m[2,3]*m[3,2])-m[1,2]*(m[2,1]*m[3,3]-m[2,3]*m[3,1])+m[1,3]*(m[2,1]*
m[3,2]-m[2,2]*m[3,1])
EndIf
1→q
For i,1,n-3
m[i,i]→p
If is_0(p) Then
For j,i+1,n
If not is_0(m[j,i]) Then
rowSwap(m,i,j)→m
Exit
EndIf
EndFor
If j>n
Return
0
EndIf
© Define local function
© Test input argument type
© Get matrix dimensions
© Test for square matrix
© Get number of matrix rows
© 1x1 matrix
© 2x2 matrix
© 3x3 matrix
© N x N matrix, N>3
3 - 34

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents