inverting matrixes over rings

8 views
Skip to first unread message

Prof. Dr. Johannes Grabmeier privat

unread,
Apr 13, 2021, 5:35:58 AM4/13/21
to fricas...@googlegroups.com
the FriCAS code for inverting matrices over R is not correct. If wished
I can provide the necessary changes to matfuns.spad

Problem: recip returns "failed", inverse coerces to Fraction Integer:

(1) -> R := IntegerMod 26

   (1)  IntegerMod(26)
                                                                                         
Type: Type

(2) -> U : Matrix R := [[1,2],[0,1]]

        +1  2+
   (2)  |    |
        +0  1+
                                                                       
Type: Matrix(IntegerMod(26))
(3) -> recip U

   (3)  "failed"
                                                                          
Type: Union("failed",...)
(4) -> inverse U

        +1  - 2+
   (4)  |      |
        +0   1 +
                                                          Type:
Union(Matrix(Fraction(Integer)),...)


The desired result should be the following:

(72) -> inverse U

         +1  24+
   (72)  |     |
         +0  1 +
                                                             Type:
Union(Matrix(IntegerMod(26)),...)


--
Mit freundlichen Grüßen

Johannes Grabmeier

Prof. Dr. Johannes Grabmeier
Köckstraße 1, D-94469 Deggendorf
Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756
Tel. +49-(0)-991-3615-141 (d), Fax: +49-(0)-32224-192688

Kurt Pagani

unread,
Apr 13, 2021, 10:27:53 AM4/13/21
to fricas...@googlegroups.com
On 13.04.2021 11:35, Prof. Dr. Johannes Grabmeier privat wrote:
> the FriCAS code for inverting matrices over R is not correct. If wished
> I can provide the necessary changes to matfuns.spad

From my side, please do ;)

(2) -> IU := inverse(U)@Matrix(R)

An expression involving @ Matrix(IntegerMod(26)) actually evaluated
to one of type Union(Matrix(Fraction(Integer)),"failed") .
Perhaps you should use :: Matrix(IntegerMod(26)) .

(2) -> IU := inverse(U)::Matrix(R)

+1 24+
(2) | |
+0 1 +
Type: Matrix(IntegerMod(26))


)sh Matrix(R) => provides no inverse, indeed.

Waldek Hebisch

unread,
Apr 14, 2021, 6:42:59 PM4/14/21
to fricas...@googlegroups.com
On Tue, Apr 13, 2021 at 11:35:55AM +0200, Prof. Dr. Johannes Grabmeier privat wrote:
> the FriCAS code for inverting matrices over R is not correct. If wished
> I can provide the necessary changes to matfuns.spad

I am not sure what you consider as "not correct". Namely, currently
'inverse' assumes that matrix is over a field. AFAICS this is
deliberate, because otherwise a lot of integer matrices would
be noninvertible (because inverse needs rational numbers). So
your result with 'inverse' is a conseqence of decision to not
provide 'inverse' over rings and interpreter rules for coercion.

Concerning 'recip', this is clearly a bug: SquareMatrix claims
to be a Ring, which implies that there is a 'recip'.
'recip' in SquareMatrix is inherited from MagmaWithUnit,
which is a trivial one: it fails on anything different than 1.
But Ring also claims 'unitsKnown', which means that 'recip' is
allowed to fail only on non-invertible elements. ATM is is
not clear for me how to fix this: for commutative rings we
can easily provide slow but simple implementation of 'recip'
using determinants. For more general rings this looks more
complicated. And to say the truth, I wonder if other non-commutative
rings have correct 'recip'.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages