Issues 3512 and 2015 point out that finding the solution to relatively 
small systems of equations can take a long time. A solution to this problem 
is to use a matrix-solving method that doesn't require simplification to 
determine where symbolic zeros appear and capitalizes on the caching nature 
of SymPy. It turns out the a simple solution based on finding the 
determinant through the expansion of matrix minors works very well for this 
purpose. I am not sure where to make the modifications.

We have the whole Matrix suite that is good for handling calculations of 
the determinant and inverse of *numerical* matrices; the routines are much 
slower once a few symbols are introduced. The issues raised above refer to 
extremely long times taken to solve such systems. The best idea is to not 
try to solve symbolic systems, especially those involving many equations, 
since the results are often huge and seem to me to be of little practical 
value. In issue 2015 the non-zero elements are located as follows:

[    XX]
[X    X]
[XX   X]
[XXX   ]
[ XXX  ]
[  XX  ]

All but one of those Xs is a number; the rest are expressions involving 
symbols. Inverting this matrix with the Matrix.det() takes about 9 seconds 
whereas an inversion method based on finding the inverse through minor 
expansion and the computation of determinants using the product of the 
permuted element of the matrix takes 0.7 seconds.

It doesn't matter where the matrix comes from: the user might be interested 
in inverting or finding the determinant of symbolic matrices or they might 
have entered a set of equations involving symbols other than those being 
solved for. In either case (for a small n) the system can be solved more 
quickly by using the traditional naive algorithms (minor expansion or 
permutations of elements). So where should these methods go, and when 
should they be used?

They could be part of Matrices and solve could be made to look at the 
system and decide whether it is worth calling one of these special solvers. 
But I don't know whether det and inv should automatically do such checking 
(since that slows down the handling of numerical matrices) or if it should 
be left to the user to know their matrix and call the best corresponding 
method. I hate to lock them into solve alone since they have good general 
utility for the appropriate matrix.

I have 4 routines that can be used:

D = the existing method (bareis)
P = find the determinant using fast generation of the permutations needed 
to select the necessary elements
S = given a matrix with numbers and symbols, find determinants of minors in 
the row/col with the most symbols, shifting to D when there are no symbols
Z = given a sparse matrix, find determinants of minors in the row/col with 
the most zeros shifting to D, P or S when there are no zeros

Any ideas on how best to incorporate P, S and Z? Using these routines will 
give orders-of-magnitude improvement to calculations involving matrix 
inversion.


-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to