ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 Oct 2014 17:01:15 +0200Polynomial decompositionhttps://ask.sagemath.org/question/24438/polynomial-decomposition/We say that a polynomial $f$ is decomposable if there are (not linear) polynomials $g,h$ such that $f = g \circ h.$
Is there a function in Sage doing this?
As far as I can see the function is present in Mathematica under the name Decompose http://reference.wolfram.com/language/ref/Decompose.html.
Wed, 08 Oct 2014 15:33:16 +0200https://ask.sagemath.org/question/24438/polynomial-decomposition/Answer by tmonteil for <p>We say that a polynomial $f$ is decomposable if there are (not linear) polynomials $g,h$ such that $f = g \circ h.$ </p>
<p>Is there a function in Sage doing this? </p>
<p>As far as I can see the function is present in Mathematica under the name Decompose <a href="http://reference.wolfram.com/language/ref/Decompose.html">http://reference.wolfram.com/language...</a>.</p>
https://ask.sagemath.org/question/24438/polynomial-decomposition/?answer=24440#post-id-24440Unfortunately i can not see any method about this for polynomials, but you can use ``sympy`` shich is shipped with Sage, though not imported by default (nor completely interfaced):
sage: R.<x> = PolynomialRing(QQ)
sage: f = 27*x^4 - 27/5*x^3 + 1737/100*x^2 - 171/100*x + 37/10
sage: from sympy import decompose
sage: decompose(f)
[27*x**2 + 171*x/10 + 37/10, x**2 - x/10]
sage: a,b = _
sage: a
27*x**2 + 171*x/10 + 37/10
sage: type(a)
<class 'sympy.core.add.Add'>
sage: a = R(SR(a))
sage: b = R(SR(b))
sage: a
27*x^2 + 171/10*x + 37/10
sage: a.parent()
Univariate Polynomial Ring in x over Rational Field
sage: a(b) == f
True
Wed, 08 Oct 2014 17:01:15 +0200https://ask.sagemath.org/question/24438/polynomial-decomposition/?answer=24440#post-id-24440