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.Fri, 01 Mar 2024 07:06:31 +0100Polynomial factorizationhttps://ask.sagemath.org/question/76264/polynomial-factorization/ I have a polynomial in x,y,z such that each term can factor out a certain power of x to get a polynomial with nonzero constant term. I want to simplify this polynomial, so I want to find the largest n such that each term can be divided by x^n and then divide the whole polynomial by x^n. How shall I do it?Tue, 27 Feb 2024 17:32:48 +0100https://ask.sagemath.org/question/76264/polynomial-factorization/Comment by rburing for <p>I have a polynomial in x,y,z such that each term can factor out a certain power of x to get a polynomial with nonzero constant term. I want to simplify this polynomial, so I want to find the largest n such that each term can be divided by x^n and then divide the whole polynomial by x^n. How shall I do it?</p>
https://ask.sagemath.org/question/76264/polynomial-factorization/?comment=76267#post-id-76267In your story it's not clear to me which polynomial should have a nonzero constant term. Please give an example of the input and the output you want.Tue, 27 Feb 2024 18:55:25 +0100https://ask.sagemath.org/question/76264/polynomial-factorization/?comment=76267#post-id-76267Answer by Emmanuel Charpentier for <p>I have a polynomial in x,y,z such that each term can factor out a certain power of x to get a polynomial with nonzero constant term. I want to simplify this polynomial, so I want to find the largest n such that each term can be divided by x^n and then divide the whole polynomial by x^n. How shall I do it?</p>
https://ask.sagemath.org/question/76264/polynomial-factorization/?answer=76294#post-id-76294Possible alternative in SR :
sage: var("x, y, z")
(x, y, z)
sage: f = x^2*(x + y + z + 1) + x^3*(y^2 + z^2 + 1); f
(y^2 + z^2 + 1)*x^3 + (x + y + z + 1)*x^2
sage: f.canonicalize_radical().factor()
(x*y^2 + x*z^2 + 2*x + y + z + 1)*x^2
Also :
sage: f.collect_common_factors()
((y^2 + z^2 + 1)*x + x + y + z + 1)*x^2
HTH,Fri, 01 Mar 2024 07:06:31 +0100https://ask.sagemath.org/question/76264/polynomial-factorization/?answer=76294#post-id-76294Answer by rburing for <p>I have a polynomial in x,y,z such that each term can factor out a certain power of x to get a polynomial with nonzero constant term. I want to simplify this polynomial, so I want to find the largest n such that each term can be divided by x^n and then divide the whole polynomial by x^n. How shall I do it?</p>
https://ask.sagemath.org/question/76264/polynomial-factorization/?answer=76266#post-id-76266If I understood you correctly:
sage: R.<x,y,z> = PolynomialRing(QQ)
sage: f = x^2*(x + y + z + 1) + x^3*(y^2 + z^2 + 1); f
x^3*y^2 + x^3*z^2 + 2*x^3 + x^2*y + x^2*z + x^2
sage: g = x^min(e[0] for e in f.exponents()); g
x^2
sage: h = f // g; h
x*y^2 + x*z^2 + 2*x + y + z + 1
sage: f == g*h
TrueTue, 27 Feb 2024 18:50:27 +0100https://ask.sagemath.org/question/76264/polynomial-factorization/?answer=76266#post-id-76266