Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is because you're not passing the function appropriately to find_root. Here's how you would do it:

sage: find_root(lambda t: xt(t) - 1, 2, 3)
ValueError: negative number cannot be raised to a fractional power

Unfortunately, the current root-finding only works with real numbers (see #14991).

With mpmath's root-finding you get the following answer, although the syntax is extremely clumsy at the moment:

from sage.libs.mpmath.utils import call
import mpmath
def mpmath_xt(t, prec):
    t = ComplexField(prec)(t.real, t.imag)
    ft = xt(t).n(prec)
    return mpmath.mpc(ft.real(), ft.imag()) - 1

Then,

sage: call(mpmath.findroot, lambda t: mpmath_xt(t, 100), [2, 3], parent=ComplexField(100))
2.4629947809517837884000550617 + 2.0631855558523985234600213842e-88*I

Change 100 in the above to whatever precision you want.

Hope this helps!

This is because you're not passing the function appropriately to find_root. Here's how you would do it:

sage: find_root(lambda t: xt(t) - 1, 2, 3)
ValueError: negative number cannot be raised to a fractional power

Unfortunately, the current root-finding only works with real numbers (see #14991).), and find_root is encountering complex numbers.

With mpmath's root-finding you get the following answer, although the syntax is extremely clumsy at the moment:

from sage.libs.mpmath.utils import call
import mpmath
def mpmath_xt(t, prec):
    t = ComplexField(prec)(t.real, t.imag)
    ft = xt(t).n(prec)
    return mpmath.mpc(ft.real(), ft.imag()) - 1

Then,

sage: call(mpmath.findroot, lambda t: mpmath_xt(t, 100), [2, 3], parent=ComplexField(100))
2.4629947809517837884000550617 + 2.0631855558523985234600213842e-88*I

Change 100 in the above to whatever precision you want.

Hope this helps!