Matrix assumption

18 views
Skip to first unread message

Florent Périat

unread,
Oct 13, 2025, 2:54:25 PM (3 days ago) Oct 13
to sympy
Hi everyone,

I just read the documentation and noticed that there is, as I understood it, a mathematical mistake (and also at the execution).

If you look at this section, it seems to assert that the product (not the Hadamard product, but usual one) of two symmetric matrices is also symmetric, which is True if and only if both matrices commutes; but as their shape is (in the example) defined as 2x2, they do not necessarily.

from sympy import Q, ask, MatrixSymbol, Equality

X = MatrixSymbol('X', 2, 2)
Z = MatrixSymbol('Z', 2, 2)

print(ask(Q.symmetric(X * Z), Q.symmetric(X) & Q.symmetric(Z))) # True
print(ask(Equality(X * Z, Z * X), Q.symmetric(X) & Q.symmetric(Z))) # False

Here both output should give False.

Best regards,

F. Périat

Oscar Benjamin

unread,
3:40 PM (6 hours ago) 3:40 PM
to sy...@googlegroups.com
Hi Florent,

It would be better to open a GitHub issue with this as it is a bug.

The output should be None in both cases rather than True or False
because it is possible that X*Z is symmetric (for example if X and Z
are diagonal) but also possible that it is not.

Thanks,
Oscar
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sympy/d029d408-66cb-4531-a548-b7e455a0387dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages