inverse of a matrix with Fraction entries

Daniel Fetchinson fetchinson at googlemail.com
Wed Nov 24 17:08:32 EST 2010


>> 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?

Absolutely! But there is nothing wrong with working out the inverse
directly using fractions.Fraction arithmetic, I'd think.

Cheers,
Daniel



-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown



More information about the Python-list mailing list