Symbolic matrix inversion broken?
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?
What is your SageMath version? https://sagecell.sagemath.org/ gives the right answer.
Sagecell is running 10.1. This also works for me in sage 10.2.beta9.
Good point.
sage0_version
says "'SageMath version 10.0, Release Date: 2023-05-20'". I'll update and report back.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.
Because this has been fixed recently. You can close your question.