Ask Your Question
2

Resultant of Symbolic Expression.

asked 2021-06-02 22:13:11 +0100

Amrutha gravatar image

Is there a way to find resultant of two polynomials whose coefficients are not numbers. For example, $a_0x^3+a_1x^2y+a_2xy^2+a_3x^2z+a_4xz^2+a_5y^3+a_6y^2z+a_7yz^2+a_8z^3+a_9xyz$ and $a_0x^2+a_1xy+a_2xz+a_3yz+a_4y^2+a_5z^2$. I am getting the error "RuntimeError: resultant(): arguments must be polynomials". Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-02 23:30:40 +0100

tmonteil gravatar image

You can put the coefficients of your polynomials in a polynomial ring:

sage: R = PolynomialRing(QQ,'a',10)
sage: R
Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9 over Rational Field
sage: R.inject_variables()
Defining a0, a1, a2, a3, a4, a5, a6, a7, a8, a9

Then define the main polynomial ring, with coefficients in the first polynomial ring:

sage: S.<x,y,z> = R[]
sage: S
Multivariate Polynomial Ring in x, y, z over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9 over Rational Field

Then you can define the 2 polynomials and compute their resultant:

sage: P = a0*x^3+a1*x^2*y+a2*x*y^2+a3*x^2*z+a4*x*z^2+a5*y^3+a6*y^2*z+a7*y*z^2+a8*z^3+a9*x*y*z
sage: P
a0*x^3 + a1*x^2*y + a2*x*y^2 + a5*y^3 + a3*x^2*z + a9*x*y*z + a6*y^2*z + a4*x*z^2 + a7*y*z^2 + a8*z^3
sage: P.parent()
Multivariate Polynomial Ring in x, y, z over Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5, a6, a7, a8, a9 over Rational Field
sage: Q = a0*x^2+a1*x*y+a2*x*z+a3*y*z+a4*y^2+a5*z^2
sage: P.resultant(Q)
(a0^2*a2^2*a4 - 2*a0^2*a2*a4^2 + a0^2*a4^3 - a0^2*a1*a2*a5 + a0^2*a1*a4*a5 + a0^3*a5^2)*y^6 + (a0^2*a2^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2*a3*a5*a8 + a0^3*a8^2)*z^6
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

Stats

Asked: 2021-06-02 22:13:11 +0100

Seen: 1,712 times

Last updated: Jun 02 '21