Opened 6 years ago
Closed 3 years ago
#14896 closed enhancement (fixed)
Implement symbolic confluent hypergeometric functions
Reported by:  eviatarbach  Owned by:  burcin 

Priority:  major  Milestone:  sage7.3 
Component:  symbolics  Keywords:  hypergeometric, kummer 
Cc:  kcrisman, benjaminfjones  Merged in:  
Authors:  Eviatar Bach, Ralf Stephan  Reviewers:  Jan Keitel, Ralf Stephan, Nils Bruin, Paul Masson 
Report Upstream:  N/A  Work issues:  
Branch:  23a5c65 (Commits)  Commit:  23a5c6531df9d9f0b9b553d0754c731ef2b17266 
Dependencies:  #2516, #16697  Stopgaps: 
Description
This patch implements the Kummer confluent hypergeometric functions hypergeometric_M
and hypergeometric_U
(superseding the previous numericalonly version), complete with numeric evaluation, simplification, and transformation to generalized hypergeometric functions.
Attachments (2)
Change History (51)
Changed 6 years ago by
comment:1 Changed 6 years ago by
Changed 6 years ago by
comment:2 Changed 6 years ago by
 Status changed from new to needs_review
Last patch, to be applied independently, adds LaTeX names which I forgot in the original.
comment:3 Changed 6 years ago by
 Cc kcrisman benjaminfjones added
comment:4 Changed 6 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:5 Changed 6 years ago by
 Keywords hypergeometric added
comment:6 Changed 5 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:7 Changed 5 years ago by
 Status changed from needs_review to needs_work
comment:8 Changed 5 years ago by
This one does not have a valid git branch attached to it... So, I have set it to "needs work". I am willing to review this ticket once there is a valid git branch.
comment:9 Changed 5 years ago by
is this a dupe of #2516?
comment:10 Changed 5 years ago by
No. Confluent hypergeometric functions are a specific type of hypergeometric function, which are solutions to Kummer's differential equation.
Thanks for offering to review, Kannappan! I'm new to the Git workflow, but I'll try to create the branch as soon as possible.
comment:11 Changed 5 years ago by
 Branch set to u/jkeitel/ticket/14896
 Commit set to 3b32a6cf6f625ac5d0ca263f6acbc3b5ad7b0899
I've created a git branch and fixed a few failing doctests. There are still many functions that do not have docstrings.
Last 10 new commits:
4b4ed75  Merge branch 'develop' into t/2516/ticket/2516

0dbbacd  2516: fix last doctests

934d057  2516: remove hack

0f5a4ff  2516: fix doctest

eeb273e  Merge branch 'develop' into t/2516/ticket/2516

62f7faa  Merge branch 'master' into t/2516/ticket/2516

9c6749d  doctest coverage

051edff  Merge branch 'develop' into t/2516/ticket/2516

9d6eea1  # Branch hyper

3b32a6c  Remove trailing whitespace and fix a few doctests by adding algorithm argument.

comment:12 Changed 5 years ago by
 Branch changed from u/jkeitel/ticket/14896 to u/rws/ticket/14896
comment:13 Changed 5 years ago by
 Commit changed from 3b32a6cf6f625ac5d0ca263f6acbc3b5ad7b0899 to b87c57b409b7d9df972ec88b7f0500e3ce51c89e
Documentation as is looks good. I fixed a newly appearing doctest fail.
Last 10 new commits:
e5a5343  6882: do word search/replace for symtable keys

4c1b0eb  6882: correction to previous commit

518de3e  6882: add symable rules for e,i,I; fix maxima_var; add doctests

7a6696b  Merge branch 'u/rws/bugs_in_conversion_of_variable_names_from_maxima_to_sage' of trac.sagemath.org:sage into t/8734/ticket/87341

a8df107  Merge branch 't/8734/ticket/87341' into t/16007/ticket/16007

9e66d16  Merge commit 'a8df107e76527d83a87456520395ab85dbc44050' of trac.sagemath.org:sage into t/2516/public/hypergeometric

5ac8224  2516: fix doctests affected by 16007 merge

b2f8dc5  2516: this 16007related doctest fail seems to be uncovered only by 2516, so fix it here

c2b74cb  Merge branch 't/2516/b2f8dc5a1c82312271f2e2361b142358a66d0965' into t/14896/ticket/14896

b87c57b  14896: fix doctest failing due to changes by 16007

comment:14 followup: ↓ 15 Changed 5 years ago by
Seems I found a Maxima interface problem with hypergeometric
:
sage: hypergeometric_M(1,b,x).simplify_hypergeometric() (b  1)*x^(b + 1)*e^x*gamma_greek(b  1, x) sage: hypergeometric([1],[b],x).simplify_hypergeometric() (b  1)*x^(b + 1)*e^x*gamma_greek(b  1, x)
Of course that should be gamma
.
comment:15 in reply to: ↑ 14 ; followup: ↓ 16 Changed 5 years ago by
Replying to rws:
(b  1)*x^(b + 1)*e^x*gamma_greek(b  1, x)Of course that should be
gamma
.
I'm not so sure: according to the maxima documentation:
 gamma  gamma function (complete)
 gamma_greek  lower incomplete gamma function
 gamma_incomplete  upper incomplete gamma function
in sage, gamma(a,z) is documented to be the upper gamma function, which gets translated appropriately. We might not have a lower gamma function yet.
comment:16 in reply to: ↑ 15 ; followup: ↓ 17 Changed 5 years ago by
(b  1)*x^(b + 1)*e^x*gamma_greek(b  1, x)Of course that should be
gamma
.I'm not so sure: according to the maxima documentation:
 gamma  gamma function (complete)
 gamma_greek  lower incomplete gamma function
 gamma_incomplete  upper incomplete gamma function
Good catch.
in sage, gamma(a,z) is documented to be the upper gamma function, which gets translated appropriately. We might not have a lower gamma function yet.
Maybe we can make it by gamma  upper incomplete?
comment:17 in reply to: ↑ 16 Changed 5 years ago by
Replying to kcrisman:
Maybe we can make it by gamma  upper incomplete?
Maybe define it in special.py
both as maxima and Sageevaluated (gammagamma_inc) function. Objections?
comment:18 Changed 5 years ago by
If maxima can produce gamma_greek
spontaneously, then we should be able to make sense of it. The most straightforward way is by having a transliteration, gamma_incomplete_lower
or gamma_lower
perhaps. Adding new symbolic functions isn't that laborious, is it? Simplification methods can be grown later.
FYI: Mathematica seems to have Gamma[a,z] for upper and Gamma[a,0,z] for lower; Maple seems to have upper Gamma. So it does seem packages have been gravitating to the upper one more than the lower one. However, if that means our confluent hypergeometric functions always end up being translated into a more convoluted expression than a straight gamma_lower would give, we're not doing ourselves favours
(e.g., for numerical work: do you really want to evaluate gamma_lower(a,z) as gamma(z)gamma_upper(a,z) ?)
Without strong indications in either direction, I'd be hesitant to make a choice and rather follow the lead of our main underlying engine: implement gamma_lower.
comment:19 Changed 5 years ago by
 Status changed from needs_work to needs_review
comment:20 Changed 5 years ago by
 Dependencies changed from #2516 to #2516, #16697
comment:21 Changed 5 years ago by
 Commit changed from b87c57b409b7d9df972ec88b7f0500e3ce51c89e to e699b41b195441c5b6da96a54be699a16b8fab9c
Branch pushed to git repo; I updated commit sha1. New commits:
1e5f524  14896: improve doctest coverage

c4f2c71  16697: tidy up gamma1, gamma_inc, gamma documentation

93c2f94  16697: deprecate "incomplete_gamma"

5c1dd67  16697: implement gamma_inc_lower

e699b41  Merge branch 't/16697/implement_symbolic_lower_incomplete_gamma_function' into t/14896/ticket/14896

comment:22 Changed 5 years ago by
 Merged in set to #16697
comment:23 Changed 5 years ago by
 Commit changed from e699b41b195441c5b6da96a54be699a16b8fab9c to ef78ae1641ee83dc8ca864013b3a62784b9c78f6
Branch pushed to git repo; I updated commit sha1. New commits:
ef78ae1  14896: use mpmath as default evalf algorithm

comment:24 Changed 5 years ago by
 Commit changed from ef78ae1641ee83dc8ca864013b3a62784b9c78f6 to 4c473be4ea871b4d32034245bbde30499b2b61a6
Branch pushed to git repo; I updated commit sha1. New commits:
4c473be  Merge branch 'develop' into t/14896/ticket/14896

comment:25 Changed 5 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:26 Changed 5 years ago by
 Commit changed from 4c473be4ea871b4d32034245bbde30499b2b61a6 to eef585a99d1a2f7b4bb416ad76124236209de521
Branch pushed to git repo; I updated commit sha1. New commits:
eef585a  Merge branch 'develop' into t/14896/ticket/14896

comment:27 Changed 5 years ago by
 Commit changed from eef585a99d1a2f7b4bb416ad76124236209de521 to 76d3545efb39cf2c83a90842d59570df20722e03
Branch pushed to git repo; I updated commit sha1. New commits:
76d3545  14896: remove merge markers, resolve

comment:28 Changed 5 years ago by
 Keywords kummer added
 Merged in #16697 deleted
comment:29 Changed 5 years ago by
 Commit changed from 76d3545efb39cf2c83a90842d59570df20722e03 to b8197b13db132d18901a5d889ded44061f36f7bc
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
705c34e  16697: fix a related bug

a73c5e3  16697: fix previous patch and a doctest

7558a7c  16697: revert fix in favor of merge of 16785

1fc19e7  Merge branch 't/16785/ticket/16785' into t/16697/implement_symbolic_lower_incomplete_gamma_function

9033be8  Merge branch 'develop' into t/16697/implement_symbolic_lower_incomplete_gamma_function

05195e7  Merge branch 'develop' into t/16697/implement_symbolic_lower_incomplete_gamma_function

a383a5b  Merge branch 'u/jdemeyer/ticket/17130' of trac.sagemath.org:sage into t/16697/implement_symbolic_lower_incomplete_gamma_function

6f59f3a  16697: adaptations due to trac 17130

a91bebb  Merge branch 'u/rws/implement_symbolic_lower_incomplete_gamma_function' of trac.sagemath.org:sage into t/14896/ticket/14896

b8197b1  14896: adaptations due to recent BuiltinFunction changes

comment:30 Changed 5 years ago by
 Reviewers set to Jan Keitel, Ralf Stephan, Nils Bruin
 Status changed from needs_review to needs_work
This branch is sadly red.
comment:31 Changed 5 years ago by
 Commit changed from b8197b13db132d18901a5d889ded44061f36f7bc to abad8a3c7e43e15cb9a8a8f3a270be216da1819a
comment:32 Changed 5 years ago by
 Status changed from needs_work to needs_review
comment:33 Changed 5 years ago by
 Status changed from needs_review to needs_work
branch is red, needs rebase
comment:34 Changed 5 years ago by
 Commit changed from abad8a3c7e43e15cb9a8a8f3a270be216da1819a to a628fcbd0ec00f33d69f93304153a81463ec08d3
Branch pushed to git repo; I updated commit sha1. New commits:
a628fcb  Merge branch 'develop' into t/14896/ticket/14896

comment:35 Changed 5 years ago by
Also needs merge in of updated #16697 and a squash.
comment:36 Changed 5 years ago by
 Milestone changed from sage6.4 to sagepending
Pending because #16697 is pending.
comment:37 Changed 3 years ago by
 Branch changed from u/rws/ticket/14896 to u/rws/14896
comment:38 Changed 3 years ago by
 Commit changed from a628fcbd0ec00f33d69f93304153a81463ec08d3 to da3a146a9ef69ff80e36e30f7e67a7ea56cd1312
 Milestone changed from sagepending to sage7.3
 Status changed from needs_work to needs_review
comment:39 Changed 3 years ago by
Please review/merge #16697 first (its commit metadata is missing here).
comment:40 Changed 3 years ago by
Ralf, I'm trying to merge existing commits to a branch that already includes #16697 but I'm getting errors:
STDOUT: Automerging src/sage/symbolic/expression_conversions.py STDOUT: CONFLICT (content): Merge conflict in src/sage/symbolic/expression_conversions.py STDOUT: Automerging src/sage/symbolic/expression.pyx STDOUT: Automerging src/sage/functions/special.py STDOUT: Automerging src/sage/functions/other.py STDOUT: CONFLICT (content): Merge conflict in src/sage/functions/other.py STDOUT: Automerging src/sage/functions/hypergeometric.py STDOUT: Automerging src/sage/functions/all.py STDOUT: CONFLICT (content): Merge conflict in src/sage/functions/all.py STDOUT: Automatic merge failed; fix conflicts and then commit the result.
Am I doing something wrong or do these commits need updating after all this time? Would like to get this one reviewed.
comment:41 Changed 3 years ago by
 Commit changed from da3a146a9ef69ff80e36e30f7e67a7ea56cd1312 to 58f6a1276a46c70dc9f0e42b5ccb0ab15dbcae10
Branch pushed to git repo; I updated commit sha1. New commits:
58f6a12  Merge branch 'develop' into t/14896/14896

comment:42 Changed 3 years ago by
Still getting an error:
STDOUT: Automerging src/sage/symbolic/expression_conversions.py STDOUT: CONFLICT (content): Merge conflict in src/sage/symbolic/expression_conversions.py STDOUT: Automerging src/sage/functions/all.py STDOUT: Automatic merge failed; fix conflicts and then commit the result.
comment:43 Changed 3 years ago by
As you can see at the top of the ticket the branch cleanly merges with beta5. So you seem to want to merge it with a different version? And why merge at all? Just git trac checkout 14896
and compile.
comment:44 Changed 3 years ago by
I assumed I needed keep track of changes from#16697 manually, but clearly Trac does that automatically.
Running a doctest
on symbolic/expression_conversions.py gives an error:
ValueError: line 93 of the docstring for sage.symbolic.expression_conversions.InterfaceInit.derivative has inconsistent leading whitespace: '======='
This is the same file that had a merge conflict.
comment:45 Changed 3 years ago by
 Commit changed from 58f6a1276a46c70dc9f0e42b5ccb0ab15dbcae10 to 23a5c6531df9d9f0b9b553d0754c731ef2b17266
Branch pushed to git repo; I updated commit sha1. New commits:
23a5c65  Merge branch 'develop' into t/14896/14896

comment:46 Changed 3 years ago by
I updated to beta6 and had a merge conflict there too which should be resolved now. Let's try again, please.
comment:47 Changed 3 years ago by
 Reviewers changed from Jan Keitel, Ralf Stephan, Nils Bruin to Jan Keitel, Ralf Stephan, Nils Bruin, Paul Masson
 Status changed from needs_review to positive_review
Doctests all pass. Documentation builds. Random numeric testing accurate and both functions plot. Symbolic behavior as expected.
Looks good to me.
comment:48 Changed 3 years ago by
Thanks for the review.
comment:49 Changed 3 years ago by
 Branch changed from u/rws/14896 to 23a5c6531df9d9f0b9b553d0754c731ef2b17266
 Resolution set to fixed
 Status changed from positive_review to closed
Whittaker functions can be easily implemented similarly; the reason I didn't include them in this patch is because the Maxima conversion is a bit more complicated.