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.Sat, 18 Apr 2020 10:36:33 +0200how to check if a polynom is a squarehttps://ask.sagemath.org/question/50825/how-to-check-if-a-polynom-is-a-square/ I'ld like to put a condition in a programm that looks like:
"if Q is a square, then ..."
Q being a polynom (in GF(p)).
How can I do that ?Fri, 17 Apr 2020 23:32:38 +0200https://ask.sagemath.org/question/50825/how-to-check-if-a-polynom-is-a-square/Answer by vdelecroix for <p>I'ld like to put a condition in a programm that looks like:</p>
<p>"if Q is a square, then ..." </p>
<p>Q being a polynom (in GF(p)).</p>
<p>How can I do that ?</p>
https://ask.sagemath.org/question/50825/how-to-check-if-a-polynom-is-a-square/?answer=50830#post-id-50830First of all, there is a function to check if a polynomial is a square
sage: x = polygen(GF(7))
sage: p = 2*x^2 + 6*x + 1
sage: p.is_square()
True
Then you need to learn about conditional statements in Python (`if`/`elif`/`else`): https://docs.python.org/3/tutorial/controlflow.html
Sat, 18 Apr 2020 10:36:33 +0200https://ask.sagemath.org/question/50825/how-to-check-if-a-polynom-is-a-square/?answer=50830#post-id-50830