Symbolic matrix inversion broken?

asked 1 year ago

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/di on the diagonal or throw an exception that perhaps it cannot divide by the di because they might be zero. That I'd understand. But why the 1s?

Preview: (hide)

Comments

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

tolga gravatar imagetolga ( 1 year ago )

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

FrédéricC gravatar imageFrédéricC ( 1 year ago )

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 ( 1 year ago )

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 ( 1 year ago )

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

FrédéricC gravatar imageFrédéricC ( 1 year ago )