Symbolic matrix inversion broken?

asked 2023-11-02 08:20:05 +0100

The result of the following is a bit unexpected.

sage: n=3;
sage: D = matrix.diagonal(SR,(var(f'd_{i+1}',domain='real') for i in range(n)))

sage: D
[d_1   0   0]
[  0 d_2   0]
[  0   0 d_3]

sage: D.inverse()
[1 0 0]
[0 1 0]
[0 0 1]

Clearly, that's generally not the inverse. The inverse()-method should either produce $1/d_i$ on the diagonal or throw an exception that perhaps it cannot divide by the $d_i$ because they might be zero. That I'd understand. But why the 1s?

edit retag flag offensive close merge delete

Comments

What is your SageMath version? https://sagecell.sagemath.org/ gives the right answer.

tolga gravatar imagetolga ( 2023-11-02 08:22:57 +0100 )edit

Sagecell is running 10.1. This also works for me in sage 10.2.beta9.

FrédéricC gravatar imageFrédéricC ( 2023-11-02 08:24:35 +0100 )edit

Good point. sage0_version says "'SageMath version 10.0, Release Date: 2023-05-20'". I'll update and report back.

Björn gravatar imageBjörn ( 2023-11-02 09:29:00 +0100 )edit

It works for me after updating SageMath from 10.0 to 10.1 via Homebrew. I still have no clue why this didn't work in 10.0 on my two machines (both Mac, one Apple-Silicon, one Intel, both SM10.0). I'll leave the question open for a bit in case someone can offer an explanation.

Björn gravatar imageBjörn ( 2023-11-02 10:19:14 +0100 )edit

Because this has been fixed recently. You can close your question.

FrédéricC gravatar imageFrédéricC ( 2023-11-02 13:27:12 +0100 )edit