While expecting a real example, let's look at a possible application : explicit inverse of a matrix. Let

```
sage: M=matrix(var("m", n=9), nrows=3) ; M
[m0 m1 m2]
[m3 m4 m5]
[m6 m7 m8]
```

Its inverse is hardly legible :

```
sage: IM=(M^-1).apply_map(factor) ; IM
[ (m5*m7 - m4*m8)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8) -(m2*m7 - m1*m8)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8) (m2*m4 - m1*m5)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8)]
[-(m5*m6 - m3*m8)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8) (m2*m6 - m0*m8)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8) -(m2*m3 - m0*m5)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8)]
[ (m4*m6 - m3*m7)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8) -(m1*m6 - m0*m7)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8) (m1*m3 - m0*m4)/(m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8)]
```

The common denominator of the nine elements of this inverse is theit *greatest common denominator*, which can be computed by `gcd`

:

```
sage: D=gcd(map(denominator, flatten(IM.list()))).factor() ; D
m2*m4*m6 - m1*m5*m6 - m2*m3*m7 + m0*m5*m7 + m1*m3*m8 - m0*m4*m8
```

and the inverse $IM$ can be written as the product of the inverse of this common denominator $D$ and the product of the original matrix by this denominator $\left(M\cdot D\right)$, which is :

```
sage: SIM = (IM*D).apply_map(factor) ; SIM
[ m5*m7 - m4*m8 -m2*m7 + m1*m8 m2*m4 - m1*m5]
[-m5*m6 + m3*m8 m2*m6 - m0*m8 -m2*m3 + m0*m5]
[ m4*m6 - m3*m7 -m1*m6 + m0*m7 m1*m3 - m0*m4]
```

The stucture of the inverse is much more understandable : one can almost "see" the Sarrus algorithm at work...

Check :

```
sage: SIM/D==IM
True
```

HTH,

Please provide a code example and the expected result.

Like Max, I'm expecting clarification on ypur problem (

i. e.sample code...).For more enlightment, have a look at Robert Beezer's book, whic covers a lot of a first course in linear algebra, and a lot of Sage code related to this topic. And, as always, this free book is a

sine qua nonof learning to use Sage efficiently.Finally, a hint :

`gcd?`