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

Tigonometric functions conversion from Mathematica back to Sage #38852

Open
2 tasks done
janekj2727 opened this issue Oct 25, 2024 · 1 comment · May be fixed by #38853
Open
2 tasks done

Tigonometric functions conversion from Mathematica back to Sage #38852

janekj2727 opened this issue Oct 25, 2024 · 1 comment · May be fixed by #38853

Comments

@janekj2727
Copy link

janekj2727 commented Oct 25, 2024

Steps To Reproduce

Among all trigonometric functions, only $\sin$ and $\cos$ (and surprisingly all inverse functions) are correctly converted to their Sage equivalents from Mathematica when using sage() method on a mathematica object. Particularly Tan[x], Cot[x], Csc[x] and Sec[x] are converted to Tan(x), Cot(x), Csc(x) and Sec(x), i.e. the first letter is still uppercase and such functions are not recognized by Sage.

Expected Behavior

All trigonometric functions from Mathematica should be converted back to their Sage equivalents.

Actual Behavior

Capitalization of Tan, Cot, Sec and Csc from Mathematica prevails after conversion to Sage. The conversion table returns:

sage: sage.symbolic.expression.symbol_table['mathematica']
{('I', 0): I,
 ('True', 0): True,
 ('False', 0): False,
 ('Pi', 0): pi,
 ('E', 0): e,
 ('(1+Sqrt[5])/2', 0): golden_ratio,
 ('Log[2]', 0): log2,
 ('EulerGamma', 0): euler_gamma,
 ('Catalan', 0): catalan,
 ('Khinchin', 0): khinchin,
 ('Glaisher', 0): glaisher,
 ('Sin', 1): sin,
 ('Cos', 1): cos,
 ('ArcSin', 1): arcsin,
 ('ArcCos', 1): arccos,
 ('ArcTan', 1): arctan,
 ('ArcCot', 1): arccot,
 ('ArcCsc', 1): arccsc,
 ('ArcSec', 1): arcsec,
 ('Abs', 1): abs,
 ('Sqrt', 2): <function sqrt at 0x779e067cb9c0>,
 ('Surd', 2): real_nth_root,
 ('Arg', 1): arg,
 ('Re', 1): real_part,
 ('Im', 1): imag_part,
 ('Conjugate', 1): conjugate,
 ('Factorial', 1): factorial,
 ('Binomial', 2): binomial,
 ('ArcSinh', 1): arcsinh,
 ('ArcCosh', 1): arccosh,
 ('ArcTanh', 1): arctanh,
 ('ArcCoth', 1): arccoth,
 ('ArcSech', 1): arcsech,
 ('ArcCsch', 1): arccsch,
 ('Log', 1): log,
 ('PolyLog', 2): polylog,
 ('ProductLog', 2): lambert_w,
 ('HarmonicNumber', 1): harmonic_number,
 ('Zeta', 1): zeta,
 ('StieltjesGamma', 1): stieltjes,
 ('HurwitzZeta', 2): hurwitz_zeta,
 ('Gamma', 1): gamma,
 ('LogGamma', 1): log_gamma,
 ('Gamma', 2): gamma,
 ('Gamma', 3): <function _mathematica_gamma3 at 0x779db60b1120>,
 ('PolyGamma', 1): psi,
 ('PolyGamma', 2): psi,
 ('Beta', 2): beta,
 ('BesselJ', 2): bessel_J,
 ('BesselY', 2): bessel_Y,
 ('BesselI', 2): bessel_I,
 ('BesselK', 2): bessel_K,
 ('StruveH', 2): struve_H,
 ('StruveL', 2): struve_L,
 ('HankelH1', 2): hankel1,
 ('HankelH2', 2): hankel2,
 ('SphericalBesselJ', 2): spherical_bessel_J,
 ('SphericalBesselY', 2): spherical_bessel_Y,
 ('SphericalHankelH1', 2): spherical_hankel1,
 ('SphericalHankelH2', 2): spherical_hankel2,
 ('SphericalHarmonicY', 4): spherical_harmonic,
 ('EllipticE', 2): elliptic_e,
 ('EllipticE', 1): elliptic_ec,
 ('EllipticF', 2): elliptic_f,
 ('EllipticK', 1): elliptic_kc,
 ('EllipticPi', 3): elliptic_pi,
 ('JacobiND', 2): jacobi_nd,
 ('JacobiNS', 2): jacobi_ns,
 ('JacobiNC', 2): jacobi_nc,
 ('JacobiDN', 2): jacobi_dn,
 ('JacobiDS', 2): jacobi_ds,
 ('JacobiDC', 2): jacobi_dc,
 ('JacobiSN', 2): jacobi_sn,
 ('JacobiSD', 2): jacobi_sd,
 ('JacobiSC', 2): jacobi_sc,
 ('JacobiCN', 2): jacobi_cn,
 ('JacobiCD', 2): jacobi_cd,
 ('JacobiCS', 2): jacobi_cs,
 ('InverseJacobiND', 2): inverse_jacobi_nd,
 ('InverseJacobiNS', 2): inverse_jacobi_ns,
 ('InverseJacobiNC', 2): inverse_jacobi_nc,
 ('InverseJacobiDN', 2): inverse_jacobi_dn,
 ('InverseJacobiDS', 2): inverse_jacobi_ds,
 ('InverseJacobiDC', 2): inverse_jacobi_dc,
 ('InverseJacobiSN', 2): inverse_jacobi_sn,
 ('InverseJacobiSD', 2): inverse_jacobi_sd,
 ('InverseJacobiSC', 2): inverse_jacobi_sc,
 ('InverseJacobiCN', 2): inverse_jacobi_cn,
 ('InverseJacobiCD', 2): inverse_jacobi_cd,
 ('InverseJacobiCS', 2): inverse_jacobi_cs,
 ('JacobiAmplitude', 2): jacobi_am,
 ('ChebyshevT', 2): chebyshev_T,
 ('ChebyshevU', 2): chebyshev_U,
 ('LegendreP', 2): legendre_P,
 ('LegendreQ', 2): legendre_Q,
 ('LegendreP', 3): gen_legendre_P,
 ('LegendreQ', 3): gen_legendre_Q,
 ('HermiteH', 2): hermite,
 ('JacobiP', 4): jacobi_P,
 ('GegenbauerC', 3): gegenbauer,
 ('LaguerreL', 2): laguerre,
 ('LaguerreL', 3): gen_laguerre,
 ('PrimePi', 1): prime_pi,
 ('DiracDelta', 1): dirac_delta,
 ('HeavisideTheta', 1): heaviside,
 ('UnitStep', 1): unit_step,
 ('Sign', 1): sgn,
 ('KroneckerDelta', 2): kronecker_delta,
 ('AiryAi', 1): airy_ai,
 ('AiryAiPrime', 1): airy_ai_prime,
 ('AiryBi', 1): airy_bi,
 ('AiryBiPrime', 1): airy_bi_prime,
 ('FresnelS', 1): fresnel_sin,
 ('FresnelC', 1): fresnel_cos,
 ('HypergeometricPFQ', 3): hypergeometric,
 ('Hypergeometric1F1', 3): hypergeometric_M,
 ('HypergeometricU', 3): hypergeometric_U}

where tan, cot, sec and csc are missing.

Additional Information

Connected with issue #34087

Environment

  • OS: Ubuntu 24.04
  • Sage Version: 10.4
  • Python version: 3.12.3

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@janekj2727 janekj2727 linked a pull request Oct 25, 2024 that will close this issue
5 tasks
@janekj2727
Copy link
Author

Temporary fix: call

addsymb = {('Sec', 1): sec, ('Csc', 1): csc, ('Tan', 1): tan, ('Cot', 1): cot}
sage.symbolic.expression.symbol_table['mathematica'].update(addsymb)

before the conversion from Mathematica.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants