1 | | When `gmpy2` is installed: |
| 1 | When numerically evaluating `complex_root_of(a, k)`, the index `k` is passes as real number: |
| 2 | {{{ |
| 3 | sage: complex_root_of(x^8-1, 7).n(2) |
| 4 | --------------------------------------------------------------------------- |
| 5 | IndexError Traceback (most recent call last) |
| 6 | <ipython-input-4-4eba84b7c14c> in <module>() |
| 7 | ----> 1 complex_root_of(x**Integer(8)-Integer(1), Integer(7)).n(Integer(2)) |
| 8 | |
| 9 | /home/patchbot/sage-patchbot/src/sage/structure/element.pyx in sage.structure.element.Element.n (build/cythonized/sage/structure/element.c:8131)() |
| 10 | 863 0.666666666666667 |
| 11 | 864 """ |
| 12 | --> 865 return self.numerical_approx(prec, digits, algorithm) |
| 13 | 866 |
| 14 | 867 N = deprecated_function_alias(13055, n) |
| 15 | |
| 16 | /home/patchbot/sage-patchbot/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:36209)() |
| 17 | 5818 kwds = {'parent': R, 'algorithm': algorithm} |
| 18 | 5819 try: |
| 19 | -> 5820 x = x._convert(kwds) |
| 20 | 5821 except TypeError: # numerical approximation for real number failed |
| 21 | 5822 pass # try again with complex |
| 22 | |
| 23 | /home/patchbot/sage-patchbot/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._convert (build/cythonized/sage/symbolic/expression.cpp:10663)() |
| 24 | 1257 sig_on() |
| 25 | 1258 try: |
| 26 | -> 1259 res = self._gobj.evalf(0, kwds) |
| 27 | 1260 finally: |
| 28 | 1261 sig_off() |
| 29 | |
| 30 | /home/patchbot/sage-patchbot/local/lib/python2.7/site-packages/sage/functions/other.pyc in _evalf_(self, poly, index, parent, algorithm) |
| 31 | 2920 print("index: {}".format(index)) |
| 32 | 2921 print("type(index): {}".format(type(index))) |
| 33 | -> 2922 sobj = CRootOf(Poly(poly._sympy_()), int(index)) |
| 34 | 2923 return sobj.n(ceil(prec*3/10))._sage_() |
| 35 | 2924 |
| 36 | |
| 37 | /home/patchbot/sage-patchbot/local/lib/python2.7/site-packages/sympy/polys/rootoftools.pyc in __new__(cls, f, x, index, radicals, expand) |
| 38 | 130 if index < -degree or index >= degree: |
| 39 | 131 raise IndexError("root index out of [%d, %d] range, got %d" % |
| 40 | --> 132 (-degree, degree - 1, index)) |
| 41 | 133 elif index < 0: |
| 42 | 134 index += degree |
| 43 | |
| 44 | IndexError: root index out of [-8, 7] range, got 8 |
| 45 | }}} |
| 46 | |
| 47 | When `gmpy2` is installed, the index is even passed as complex number: |