ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 13 Jun 2019 12:55:37 -0500roots of third degree polynomialhttp://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/ roots of polynomial x^3+7x+25 over field F(37)Sun, 09 Jun 2019 09:56:26 -0500http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/Comment by Emmanuel Charpentier for <p>roots of polynomial x^3+7x+25 over field F(37)</p>
http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?comment=46898#post-id-46898Homework ?Mon, 10 Jun 2019 13:05:01 -0500http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?comment=46898#post-id-46898Comment by John Palmieri for <p>roots of polynomial x^3+7x+25 over field F(37)</p>
http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?comment=46886#post-id-46886What have you tried?Sun, 09 Jun 2019 13:02:56 -0500http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?comment=46886#post-id-46886Answer by dan_fulea for <p>roots of polynomial x^3+7x+25 over field F(37)</p>
http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?answer=46910#post-id-46910It may be well a homework, but maybe one should give the solution, since part of it is knowing the right method to be used in the right context. The following initializes the polynomial ring $\Bbb F_{37}[X]$ in the transcendental variable $X$, an other one as the $x$ set by default, and maybe not the $x$ in the OP. Then having the polynomial over the right field we simply ask for its roots. A second solution would be to use a "polynomial expression" using the variable `x`, which exists by default (or create any other), then use the method `roots` also specifying as optional parameter the ring for the roots.
sage: var('x');
sage: R.<X> = PolynomialRing(GF(37))
sage: (x^3 + 7*x + 25).roots(ring=GF(37))
[(5, 1)]
sage: (x^3 + 7*x + 25).roots(ring=GF(37), multiplicities=False)
[5]
sage: (X^3 + 7*X + 25).roots()
[(5, 1)]
sage: (X^3 + 7*X + 25).roots(multiplicities=False)
[5]
Thu, 13 Jun 2019 08:46:30 -0500http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?answer=46910#post-id-46910Comment by John Palmieri for <p>It may be well a homework, but maybe one should give the solution, since part of it is knowing the right method to be used in the right context. The following initializes the polynomial ring $\Bbb F_{37}[X]$ in the transcendental variable $X$, an other one as the $x$ set by default, and maybe not the $x$ in the OP. Then having the polynomial over the right field we simply ask for its roots. A second solution would be to use a "polynomial expression" using the variable <code>x</code>, which exists by default (or create any other), then use the method <code>roots</code> also specifying as optional parameter the ring for the roots.</p>
<pre><code>sage: var('x');
sage: R.<X> = PolynomialRing(GF(37))
sage: (x^3 + 7*x + 25).roots(ring=GF(37))
[(5, 1)]
sage: (x^3 + 7*x + 25).roots(ring=GF(37), multiplicities=False)
[5]
sage: (X^3 + 7*X + 25).roots()
[(5, 1)]
sage: (X^3 + 7*X + 25).roots(multiplicities=False)
[5]
</code></pre>
http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?comment=46913#post-id-46913With a field of size 37, you can also use brute force: `f = X^3 + 7*X + 25` and then `[y for y in GF(37) if f(y) == 0]`.Thu, 13 Jun 2019 12:55:37 -0500http://ask.sagemath.org/question/46884/roots-of-third-degree-polynomial/?comment=46913#post-id-46913