Opened 8 months ago
Closed 8 months ago
#27141 closed defect (fixed)
Fix for conversion of Gamma function in Mathematica interface
Reported by: | gh-mwageringel | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.7 |
Component: | interfaces | Keywords: | Mathematica |
Cc: | dimpase, etn40ff | Merged in: | |
Authors: | Markus Wageringel | Reviewers: | Dima Pasechnik, Salvatore Stella |
Report Upstream: | N/A | Work issues: | |
Branch: | 4d8f85a (Commits) | Commit: | 4d8f85aada8a67432827f8079250e6fabb3010f9 |
Dependencies: | Stopgaps: |
Description
Converting expressions involving Gamma functions from Mathematica to Sage currently fails:
sage: mathematica('Gamma[4/3]').sage() ... NotImplementedError: Unable to parse Mathematica output: Gamma(4/3) sage: mathematica('Gamma[4/3, 1]').sage() # This should be the upper incomplete Gamma function `gamma(4/3, 1)` in Sage. gamma_inc_lower(4/3, 1) sage: mathematica('Gamma[4/3, 0, 1]').sage() ... NotImplementedError: Unable to parse Mathematica output: Gamma(4/3, 0, 1)
Moreover, this should convert to Gamma[4/3, 0, 1]
in Mathematica:
sage: gamma_inc_lower(4/3, 1)._mathematica_() Gamma[4/3, 1]
The reason for this is that all three kinds of Gamma functions (the (complete) Gamma, the upper incomplete Gamma gamma_inc
and the lower incomplete gamma_inc_lower
) all convert to Gamma
in Mathematica, but the conversion does not properly take into account that the arguments to those functions are different. Conversely, Gamma
is currently registered to convert to gamma_inc_lower
, which is always wrong and fails as shown above.
More precisely, there are the following correspondences:
gamma(x)
andGamma[x]
,gamma(x, y)
andGamma[x, y]
,gamma_inc_lower(x, z)
andGamma[x, 0, z]
,gamma(x, y) - gamma(x, z)
andGamma[x, y, z]
.
The Mathematica documentation for this can be found here: https://reference.wolfram.com/language/ref/Gamma.html.
This was tested with Sage 8.6 and Mathematica 11.3.
Change History (8)
comment:1 Changed 8 months ago by
- Branch set to u/gh-mwageringel/mathematica_gamma
- Commit set to 4d8f85aada8a67432827f8079250e6fabb3010f9
- Status changed from new to needs_review
comment:2 Changed 8 months ago by
- Cc dimpase etn40ff added
Dima, Salvatore, could one of you test this? Otherwise I can test it when I get back to Australia next month.
comment:3 Changed 8 months ago by
It works as advertised and all the tests pass on my machine. My knowledge of the Gamma function is too limited to spot any mathematical issue.
Feel free to set this to positive review if you are confident on the math side.
comment:4 Changed 8 months ago by
It'd help to know what Mathematica version you tested it with, thanks.
comment:5 Changed 8 months ago by
Mathematica 11.3.0 Kernel for Linux x86 (64-bit)
comment:6 Changed 8 months ago by
- Reviewers set to Dima Pasechnik, Salvatore Stella
- Status changed from needs_review to positive_review
Looks good to me. Tested with Mathematica 11.2 on Linux
comment:7 Changed 8 months ago by
Thank you.
comment:8 Changed 8 months ago by
- Branch changed from u/gh-mwageringel/mathematica_gamma to 4d8f85aada8a67432827f8079250e6fabb3010f9
- Resolution set to fixed
- Status changed from positive_review to closed
New commits:
fix Mathematica conversions of Gamma function