Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
1

Several variables, consider polynomail as polynomial only of X, group coefficients

asked 8 years ago

petRUShka gravatar image

updated 8 years ago

Suppose I have variables d, e and x and I somehow using symbolic calculation get polynomial like this:

9d2e2x236d2ex3+18de2x2

I want sage to group coefficients at x and consider my polynomial as polynomial only of x, I want other variables to be no more than just parameters. In short I want to see something like this:

9de2(d+2)x236d2ex3

Is it possible to exploit such an approach in Sage?

P.S. I shortened my example. In real life example it is not so easy to see such a grouping by hands.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 8 years ago

calc314 gravatar image

You can try:

var('d e x')
f = 9*d^2*e^2*x^2-36*d^2*e*x^3+18*d*e^2*x^2
f.collect(x)

If your example is very complicated, you might wish to use

f.coefficients(x)

to obtain a list of the coefficients with respect to x.

Depending on what you are doing, it might also be useful to define the ring you are working in:

R.<x> = PolynomialRing(QQ)
Preview: (hide)
link
2

answered 8 years ago

tmonteil gravatar image

If i understand correctly, you are looking for a polynomial in the indeterminate x whose coefficients belong to the polynomial ring with indeterminates d and e. You can define this as follows (assuming the numeral coefficients are rational numbers):

sage: R.<d,e> = PolynomialRing(QQ)
sage: R
Multivariate Polynomial Ring in d, e over Rational Field

sage: S.<x> = PolynomialRing(R)
sage: S
Univariate Polynomial Ring in x over Multivariate Polynomial Ring in d, e over Rational Field

sage: P = 9*d^2*e^2*x^2-36*d^2*e*x^3+18*d*e^2*x^2
sage: P
-36*d^2*e*x^3 + (9*d^2*e^2 + 18*d*e^2)*x^2
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: 8 years ago

Seen: 715 times

Last updated: Jun 02 '16