Using the .coeff to get the coefficient of an expression using sympy parser
133 views
Skip to first unread message
Abdul-Azeez Isiaq
unread,
Mar 24, 2014, 8:07:25 AM3/24/14
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 sy...@googlegroups.com
I am quite new to python and am using the sympy library to work on some mathematical code using the parser input. The problem is that it parses the coefficient of x as the constant when there is no constant in the expression. Below is a simple example of what am trying to explain.
At least am very sure eqn.coeff('x',0) which is a constant is eqn to 0 in this equation but the compiler says it is 2.
Aaron Meurer
unread,
Mar 24, 2014, 9:40:41 PM3/24/14
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 sy...@googlegroups.com
Yeah, that looks like a wrong result to me. It's because it's using
as_independent(x), but it should only do that if it's an Add. I think
it should be an easy fix if you want to give it a shot.