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, 07 Dec 2017 03:40:29 -0600Change Precision of complex_roots()http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/I am trying to find the complex roots of the polynomial
poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
But when I do poly.complex_roots(), the system gives:
PariError: overflow in expo()
Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example).
How do I change the complex_roots() function to get lower-precision roots?Wed, 06 Dec 2017 23:10:52 -0600http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/Comment by tmonteil for <p>I am trying to find the complex roots of the polynomial</p>
<pre><code>poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
</code></pre>
<p>But when I do poly.complex_roots(), the system gives:</p>
<pre><code> PariError: overflow in expo()
</code></pre>
<p>Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example). </p>
<p>How do I change the complex_roots() function to get lower-precision roots?</p>
http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/?comment=39989#post-id-39989How did you define `x` ? By default, you will get:
sage: poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'complex_roots'Thu, 07 Dec 2017 03:35:32 -0600http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/?comment=39989#post-id-39989Answer by tmonteil for <p>I am trying to find the complex roots of the polynomial</p>
<pre><code>poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
</code></pre>
<p>But when I do poly.complex_roots(), the system gives:</p>
<pre><code> PariError: overflow in expo()
</code></pre>
<p>Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example). </p>
<p>How do I change the complex_roots() function to get lower-precision roots?</p>
http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/?answer=39990#post-id-39990OK, you hit a bug, thanks for reporting !
sage: R.<x> = QQ[]
sage: poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
sage: poly.complex_roots()
PariError: overflow in expo()
See:
sage: poly.roots(ring=CDF)
[(0.0, 1),
(0.9970597732189228 - 0.0016886658100989547*I, 1),
(0.9970597732189228 + 0.0016886658100989547*I, 1),
(0.9999846391506835 - 0.003403956023304669*I, 1),
(0.9999846391506835 + 0.003403956023304669*I, 1),
(1.0029555876303982 - 0.0017152722520868947*I, 1),
(1.0029555876303982 + 0.0017152722520868947*I, 1)]
sage: poly.roots(ring=QQbar)
[(0, 1), (1, 6)]
sage: poly.roots(ring=ZZ)
[(0, 1), (1, 6)]
Those can be used as workarounds.
However:
sage: poly.roots(ring=CC)
PariError: overflow in expo()
sage: poly.roots(ring=RealField(123))
PariError: overflow in expo()
This seems to be en interface problem with `cypari2`, the bug is now tracked at [trac ticket 24332](https://trac.sagemath.org/ticket/24332)Thu, 07 Dec 2017 03:40:29 -0600http://ask.sagemath.org/question/39987/change-precision-of-complex_roots/?answer=39990#post-id-39990