Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sympy.factor() doesn't have an effect on matrix? #19331

Open
mgeier opened this issue May 15, 2020 · 4 comments
Open

sympy.factor() doesn't have an effect on matrix? #19331

mgeier opened this issue May 15, 2020 · 4 comments

Comments

@mgeier
Copy link
Contributor

mgeier commented May 15, 2020

When I call sympy.expand() on a matrix, all matrix elements get expanded, as expected.

However, when I call sympy.factor(), nothing happens?

>>> import sympy as sp
>>> a, b = sp.symbols('a b')
>>> one = sp.Matrix([(a - b)**2])
>>> one
Matrix([[(a - b)**2]])
>>> two = sp.expand(one)
>>> two
Matrix([[a**2 - 2*a*b + b**2]])
>>> sp.factor(two)
Matrix([[a**2 - 2*a*b + b**2]])

Expected result:

>>> sp.factor(two)
Matrix([[(a - b)**2]])

Am I doing something wrong?

I'm using the master branch of SymPy.

@jksuom
Copy link
Member

jksuom commented May 15, 2020

The method M.applyfunc(factor) could probably be used.

@oscarbenjamin
Copy link
Contributor

See #18181

@mgeier
Copy link
Contributor Author

mgeier commented May 16, 2020

Thanks for the quick answers!

It's good to know that this is a known issue. I will try to use applyfunc() in the meantime.

@sidhu1012
Copy link
Contributor

sidhu1012 commented Nov 20, 2020

@oscarbenjamin I would like to add .factor() to matrix if needed because after reading #18181 I'm not sure if it's needed or not . Shall I?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants