Skip to content

Commit

Permalink
Introduce algebraic closure
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Aug 26, 2024
1 parent e042294 commit 616e055
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/sage/symbolic/expression_conversion_algebraic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def __init__(self, field):
tan
"""
self.field = field
try:
self.field_ac = field.algebraic_closure()
except:
self.field_ac = field

from sage.functions.all import reciprocal_trig_functions
self.reciprocal_trig_functions = reciprocal_trig_functions
Expand Down Expand Up @@ -105,15 +109,15 @@ def arithmetic(self, ex, operator):
if operator is pow:
from sage.rings.rational import Rational
base, expt = ex.operands()
base = self.field(base)
base = self.field_ac(base)
expt = Rational(expt)
return self.field(base**expt)
else:
if operator is add_vararg:
operator = add
elif operator is mul_vararg:
operator = mul
return reduce(operator, map(self, ex.operands()))
if operator is add_vararg:
operator = add
elif operator is mul_vararg:
operator = mul
converter = AlgebraicConverter(self.field_ac)
return self.field(reduce(operator, map(converter, ex.operands())))
except TypeError:
pass

Expand Down Expand Up @@ -251,7 +255,7 @@ def composition(self, ex, operator):
interval = cr._get_interval()._sage_()
return self.field.polynomial_root(poly, interval)
elif operand is not None:
res = func(operand._algebraic_(self.field))
res = func(operand._algebraic_(self.field_ac))
# We have to handle the case where we get the same symbolic
# expression back. For example, QQbar(zeta(7)). See
# issue #12665.
Expand Down

0 comments on commit 616e055

Please sign in to comment.