Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

coefficient() with composite variable

asked 11 years ago

daviddoria gravatar image

Say I have something like this:

var('a','b','c')
test=b*a + c*a + 3*a + b + c

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

test.coefficient(a,1)

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

test.coefficient(a*b,1)

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

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)
1
Preview: (hide)
link

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

Stats

Asked: 11 years ago

Seen: 259 times

Last updated: Apr 15 '13