Groups
Groups
Sign in
Groups
Groups
sympy
Conversations
About
Send feedback
Help
How to factor out a constant?
23 views
Skip to first unread message
Paul Royik
unread,
Dec 14, 2021, 8:53:28 AM
12/14/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
In any expression, how to factor a constant (that doesn't depend on certain symbols)?
For example (-2xy+2).factor_function(x,y) should give 2, (1-xy).
as_coeff_mul doesn't work.
Oscar Benjamin
unread,
Dec 14, 2021, 9:22:39 AM
12/14/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
Maybe factor_terms is what you want:
In [50]: factor_terms(-2*x*y + 2)
Out[50]: 2⋅(-x⋅y + 1)
--
Oscar
Reply all
Reply to author
Forward
0 new messages