Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying hyperbolic point should require maxima #251

Open
videlec opened this issue Sep 13, 2023 · 1 comment
Open

Displaying hyperbolic point should require maxima #251

videlec opened this issue Sep 13, 2023 · 1 comment
Labels

Comments

@videlec
Copy link
Collaborator

videlec commented Sep 13, 2023

The underlying problem is that elt.square_root() when elt belongs to a number field, relies on the symbolic ring.

from flatsurf import HyperbolicPlane
x = polygen(QQ)
K = NumberField(x^3 - 2, 'cbrt3', embedding=AA(2)**(1/3))
cbrt3 = K.gen()
H2 = HyperbolicPlane(K)
g0 = H2.geodesic(0, 1)
g1 = H2.geodesic(1/2 - cbrt3/5, 2)
p = g0.intersection(g1)
print(p)

gives

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[29], line 1
----> 1 p.coordinates('half_plane')

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/flatsurf/geometry/hyperbolic.py:8767, in HyperbolicPoint.coordinates(self, model, ring)
   8765 square = 1 - x * x - y * y
   8766 try:
-> 8767     sqrt = square.sqrt()
   8768     if sqrt not in x.parent():
   8769         raise ValueError(f"square root of {square} not in {x.parent()}")

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/rings/number_field/number_field_element.pyx:2264, in sage.rings.number_field.number_field_element.NumberFieldElement.sqrt (build/cythonized/sage/rings/number_field/number_field_element.cpp:22045)()
   2262     from sage.misc.functional import sqrt
   2263     from sage.symbolic.ring import SR
-> 2264     root = sqrt(SR(self))
   2265     roots = [[root, 1], [-root, 1]]
   2266 except TypeError:

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/structure/parent.pyx:897, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9534)()
    895 if mor is not None:
    896     if no_extra_args:
--> 897         return mor._call_(x)
    898     else:
    899         return mor._call_with_args(x, args, kwds)

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx:287, in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6236)()
    285     raise TypeError("Cannot coerce {} to {}".format(x, C))
    286 cdef Map m
--> 287 cdef Element e = method(C)
    288 if e is None:
    289     raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x)))

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/rings/number_field/number_field_element.pyx:2965, in sage.rings.number_field.number_field_element.NumberFieldElement._symbolic_ (build/cythonized/sage/rings/number_field/number_field_element.cpp:27165)()
   2963 # Convert the embedding to an embedding into AA or QQbar
   2964 embedding = refine_embedding(embedding, infinity)
-> 2965 a = embedding(self).radical_expression()
   2966 if a.parent() == SR:
   2967     return a

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/rings/qqbar.py:4700, in AlgebraicNumber_base.radical_expression(self)
   4698 else:
   4699     interval_field = ComplexIntervalField(self._value.prec())
-> 4700 roots = poly.roots(SR, multiplicities=False)
   4701 if len(roots) != poly.degree():
   4702     return self

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/rings/polynomial/polynomial_element.pyx:8235, in sage.rings.polynomial.polynomial_element.Polynomial.roots (build/cythonized/sage/rings/polynomial/polynomial_element.c:66304)()
   8233 var = SR(vname)
   8234 expr = self(var)
-> 8235 rts = expr.solve(var,
   8236                  explicit_solutions=True,
   8237                  multiplicities=multiplicities)

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/symbolic/expression.pyx:12320, in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:91690)()
  12318 """
  12319 from sage.symbolic.relation import solve
> 12320 return solve(self, x, multiplicities=multiplicities,
  12321                       solution_dict=solution_dict,
  12322                       explicit_solutions=explicit_solutions,

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/symbolic/relation.py:1071, in solve(f, *args, **kwds)
   1066         raise TypeError("The first argument to solve() should be a "
   1067                         "symbolic expression or a list of symbolic "
   1068                         "expressions.")
   1070 if isinstance(f, Expression): # f is a single expression
-> 1071     return _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
   1073 if not isinstance(f, (list, tuple)):
   1074     raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/symbolic/relation.py:1330, in _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
   1327     return _giac_solver(f, x, solution_dict)
   1329 # from here on, maxima is used for solution
-> 1330 m = ex._maxima_()
   1331 P = m.parent()
   1332 if explicit_solutions:

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/symbolic/expression.pyx:1236, in sage.symbolic.expression.Expression._maxima_ (build/cythonized/sage/symbolic/expression.cpp:36201)()
   1234     # Maybe not such a great idea because the "default" interface is another one
   1235     from sage.calculus.calculus import maxima
-> 1236     return super()._interface_(maxima)
   1237 else:
   1238     return super()._interface_(session)

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/structure/sage_object.pyx:686, in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:5708)()
    684     except (KeyError, ValueError):
    685         pass
--> 686 nm = I.name()
    687 init_func = getattr(self, '_%s_init_' % nm, None)
    688 if init_func is not None:

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/misc/lazy_import.pyx:359, in sage.misc.lazy_import.LazyImport.__getattr__ (build/cythonized/sage/misc/lazy_import.c:4242)()
    357         True
    358     """
--> 359     return getattr(self.get_object(), attr)
    360 
    361 # We need to wrap all the slot methods, as they are not forwarded

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/misc/lazy_import.pyx:216, in sage.misc.lazy_import.LazyImport.get_object (build/cythonized/sage/misc/lazy_import.c:2674)()
    214     if likely(self._object is not None):
    215         return self._object
--> 216     return self._get_object()
    217 
    218 cpdef _get_object(self):

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/misc/lazy_import.pyx:252, in sage.misc.lazy_import.LazyImport._get_object (build/cythonized/sage/misc/lazy_import.c:2998)()
    250 
    251         try:
--> 252             self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name)
    253         except ImportError as e:
    254             if self._feature:

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/interfaces/maxima_lib.py:112
    110 ecl_eval("(setf *load-verbose* NIL)")
    111 if MAXIMA_FAS:
--> 112     ecl_eval("(require 'maxima \"{}\")".format(MAXIMA_FAS))
    113 else:
    114     ecl_eval("(require 'maxima)")

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/libs/ecl.pyx:1352, in sage.libs.ecl.ecl_eval (build/cythonized/sage/libs/ecl.c:10944)()
   1350 
   1351 #convenience routine to more easily evaluate strings
-> 1352 cpdef EclObject ecl_eval(str s):
   1353     r"""
   1354     Read and evaluate string in Lisp and return the result

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/libs/ecl.pyx:1375, in sage.libs.ecl.ecl_eval (build/cythonized/sage/libs/ecl.c:10877)()
   1373 """
   1374 cdef cl_object o
-> 1375 o=ecl_safe_eval(python_to_ecl(s, True))
   1376 return ecl_wrap(o)
   1377 

File ~/proj/eskin/flatsurf-0.5.2/lib/python3.9/site-packages/sage/libs/ecl.pyx:321, in sage.libs.ecl.ecl_safe_eval (build/cythonized/sage/libs/ecl.c:5659)()
    319         raise KeyboardInterrupt("ECL says: {}".format(message))
    320     else:
--> 321         raise RuntimeError("ECL says: {}".format(message))
    322 else:
    323     return ret

RuntimeError: ECL says: Filesystem error with pathname #P"/home/jule/proj/eskin/flatsurf-0.5.2/lib/ecl/maxima.fas".
Either
 1) the file does not exist, or
 2) we are not allowed to access the file, or
 3) the pathname points to a broken symbolic link.
@saraedum
Copy link
Member

Fixed in #254.

@saraedum saraedum added the bug label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants