Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
separate constants and functions in _parse_other
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed May 24, 2021
1 parent d6c5cd9 commit ba08317
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/sage/interfaces/fricas.py
Expand Up @@ -1325,14 +1325,22 @@ def _parse_other(s, start=0, make_fun=False):
except KeyError:
e = function(e)
else:
from sage.symbolic.constants import e as sage_e, pi, I
from sage.rings.infinity import infinity
constants = {'%i': I,
'%e': sage_e,
'%pi': pi,
'infinity': infinity,
'plusInfinity': infinity,
'minusInfinity': -infinity}
try:
e = ZZ(e)
except TypeError:
try:
e = float(e)
except ValueError:
try:
e = symbol_table["fricas"][e]
e = constants[e]
except KeyError:
e = var(e.replace("%", "_"))
return e, a - 1
Expand Down Expand Up @@ -1569,22 +1577,24 @@ def _sage_expression(fricas_InputForm):
0
sage: fricas(A).D(x).sage() - diff(A, x) # optional - fricas
0
Check that :trac:`31849` is fixed::
sage: var("D")
D
sage: integrate(D/x, x, algorithm="fricas") # optional - fricas
D*log(x)
"""
from sage.libs.pynac.pynac import register_symbol
from sage.symbolic.constants import e, pi, I
from sage.calculus.functional import diff
from sage.functions.log import dilog, lambert_w
from sage.functions.trig import sin, cos, tan, cot, sec, csc
from sage.functions.hyperbolic import tanh, sinh, cosh, coth, sech, csch
from sage.functions.other import abs
from sage.misc.functional import symbolic_sum, symbolic_prod
from sage.rings.infinity import infinity
register_symbol(I, {'fricas': '%i'})
register_symbol(e, {'fricas': '%e'})
register_symbol(pi, {'fricas': 'pi'}) # fricas uses both pi and %pi
register_symbol(lambda: infinity, {'fricas': 'infinity'})
register_symbol(lambda: infinity, {'fricas': 'plusInfinity'})
register_symbol(lambda: -infinity, {'fricas': 'minusInfinity'})
from sage.symbolic.constants import I, pi
register_symbol(pi, {'fricas': 'pi'}) # pi is also a function in fricas
register_symbol(cos, {'fricas': 'cos'})
register_symbol(sin, {'fricas': 'sin'})
register_symbol(tan, {'fricas': 'tan'})
Expand Down

0 comments on commit ba08317

Please sign in to comment.