Ask Your Question

coefficient() with composite variable

asked 2013-04-15 10:45:57 +0200

daviddoria gravatar image

Say I have something like this:

test=b*a + c*a + 3*a + b + c

I can find that the coefficient of 'a' is (b+c+3) using:


However, I am interested in find the coefficient of $ab$ (which in this case would just be $1$). I tried


but it just returns zero. Is something like this possible?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-15 11:48:49 +0200

slelievre gravatar image

You can work in a polynomial ring.

sage: R.<a,b,c> = PolynomialRing(QQ)
sage: p = b * a + c * a + 3 * a + b + c
sage: p.coefficient(a*b)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-04-15 10:45:57 +0200

Seen: 195 times

Last updated: Apr 15 '13