Use of Eq

39 views
Skip to first unread message

amsympy

unread,
Oct 28, 2017, 1:20:34 PM10/28/17
to sympy
Hi

I write the following code to display a matrix named P equal to A.T*A.

---------------------------------------------
from sympy import *
a, b, c, d = symbols('a, b, c, d')
P = Symbol('P')

A = Matrix( [ [a, b], [c, d] ])
M = A.T*A
Eq(P, M)

----------------------------------------------

but sympy display

False instead the expected result.

Thanks


Aaron Meurer

unread,
Oct 28, 2017, 4:48:28 PM10/28/17
to sy...@googlegroups.com
You need for P to be a MatrixSymbol, like

P = MatrixSymbol('P', 2, 2)

A regular Symbol object is assumed to be a scalar, which is why SymPy
states it cannot be equal to a matrix.

Aaron Meurer
> --
> 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 post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/fb2087d0-b4fb-42f9-ba8f-433fe4876d0e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

amsympy

unread,
Oct 28, 2017, 7:43:46 PM10/28/17
to sympy
Fine
Thanks
Reply all
Reply to author
Forward
0 new messages