inverse of a matrix with Fraction entries
Mark Wooding
mdw at distorted.org.uk
Wed Nov 24 15:10:10 EST 2010
Daniel Fetchinson <fetchinson at googlemail.com> writes:
> So after all I might just code the inversion via Gauss elimination
> myself in a way that can deal with fractions, shouldn't be that hard.
I wouldn't do it that way. Let M be your matrix. Work out the LCM l of
the denominators, and multiply the matrix by that to make it an integer
matrix N = l M. Then work out the determinant d of that integer matrix.
Next, the big step: use Gaussian elimination to find a matrix A (the
`adjugate matrix') such that A N = d I. This should be doable entirely
using integer arithmetic, and I think without needing any divisions.
Finally, we have l A M = d I, so (l/d A) M = I and l/d A is the inverse
you seek.
Does that make sense?
-- [mdw]
More information about the Python-list
mailing list