From c89110a60ec29ef94233fe48d51c84538aff93f9 Mon Sep 17 00:00:00 2001 From: Martin Rubey Date: Fri, 15 Jul 2022 17:05:59 +0530 Subject: [PATCH] add translation for ellipticF --- src/sage/functions/special.py | 45 ++++++++++++++++++++++++++++++++++- src/sage/interfaces/fricas.py | 3 ++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py index 349553d734c..02596e49620 100644 --- a/src/sage/functions/special.py +++ b/src/sage/functions/special.py @@ -506,6 +506,21 @@ def __init__(self): sage: fricas(elliptic_e(x, y)).D(x).sage()/elliptic_e(x, y).diff(x) # optional - fricas cos(x)/sqrt(-sin(x)^2 + 1) + Numerically:: + + sage: f = lambda x, y: elliptic_e(arcsin(x), y).subs(x=x, y=y) # optional - fricas + sage: g = lambda x, y: fricas.ellipticE(x, y).sage() # optional - fricas + sage: d = lambda x, y: f(x, y) - g(x, y) # optional - fricas + sage: [d(N(-pi/2+x), y) for x in range(1, 3) for y in range(-2,2)] # optional - fricas tol 1e-8 + [0.000000000000000, + 0.000000000000000, + 0.000000000000000, + 0.000000000000000, + 5.55111512312578e-17, + 0.000000000000000, + 0.000000000000000, + 0.000000000000000] + """ BuiltinFunction.__init__(self, 'elliptic_e', nargs=2, # Maple conversion left out since it uses @@ -841,11 +856,39 @@ def __init__(self): elliptic_f sage: elliptic_f(x, 2)._sympy_() elliptic_f(x, 2) + + Check that :trac:`34186` is fixed:: + + sage: _ = var("x y") + sage: fricas(elliptic_f(x, y)) # optional - fricas + ellipticF(sin(x),y) + + However, the conversion is only correct in the interval + `[-\pi/2, \pi/2]`:: + + sage: fricas(elliptic_f(x, y)).D(x).sage()/elliptic_f(x, y).diff(x) # optional - fricas + cos(x)/sqrt(-sin(x)^2 + 1) + + Numerically:: + + sage: f = lambda x, y: elliptic_f(arcsin(x), y).subs(x=x, y=y) # optional - fricas + sage: g = lambda x, y: fricas.ellipticF(x, y).sage() # optional - fricas + sage: d = lambda x, y: f(x, y) - g(x, y) # optional - fricas + sage: [d(N(-pi/2+x), y) for x in range(1, 3) for y in range(-2,2)] # optional - fricas tol 1e-8 + [0.000000000000000, + 0.000000000000000, + 0.000000000000000, + 0.000000000000000, + 5.55111512312578e-17, + 0.000000000000000, + 0.000000000000000, + 0.000000000000000] + """ BuiltinFunction.__init__(self, 'elliptic_f', nargs=2, conversions=dict(mathematica='EllipticF', maxima='elliptic_f', - # fricas='ellipticF', buggy + fricas='((x,y)+->ellipticF(sin(x), y))', sympy='elliptic_f')) def _eval_(self, z, m): diff --git a/src/sage/interfaces/fricas.py b/src/sage/interfaces/fricas.py index dee071c736b..99d481b5bd5 100644 --- a/src/sage/interfaces/fricas.py +++ b/src/sage/interfaces/fricas.py @@ -576,7 +576,7 @@ def _register_symbols(): from sage.functions.hyperbolic import tanh, sinh, cosh, coth, sech, csch from sage.functions.other import abs from sage.functions.gamma import gamma - from sage.functions.special import elliptic_e + from sage.functions.special import elliptic_e, elliptic_f from sage.misc.functional import symbolic_sum, symbolic_prod from sage.rings.infinity import infinity register_symbol(pi, {'fricas': 'pi'}, 0) # %pi::INFORM is %pi, but (pi) also exists @@ -598,6 +598,7 @@ def _register_symbols(): register_symbol(gamma, {'fricas': 'Gamma'}, 1) register_symbol(gamma, {'fricas': 'Gamma'}, 2) register_symbol(lambda x, y: elliptic_e(asin(x), y), {'fricas': 'ellipticE'}, 2) + register_symbol(lambda x, y: elliptic_f(asin(x), y), {'fricas': 'ellipticF'}, 2) register_symbol(lambda x, y: x + y, {'fricas': '+'}, 2) register_symbol(lambda x, y: x - y, {'fricas': '-'}, 2) register_symbol(lambda x, y: x * y, {'fricas': '*'}, 2)