Opened 4 years ago

Closed 16 months ago

#14896 closed enhancement (fixed)

Implement symbolic confluent hypergeometric functions

Reported by: eviatarbach Owned by: burcin
Priority: major Milestone: sage-7.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 numerical-only version), complete with numeric evaluation, simplification, and transformation to generalized hypergeometric functions.

Attachments (2)

trac_14896.patch (13.8 KB) - added by eviatarbach 4 years ago.
trac_14896_2.patch (13.9 KB) - added by eviatarbach 4 years ago.

Download all attachments as: .zip

Change History (51)

Changed 4 years ago by eviatarbach

comment:1 Changed 4 years ago by eviatarbach

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.

Changed 4 years ago by eviatarbach

comment:2 Changed 4 years ago by eviatarbach

  • 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 4 years ago by kcrisman

  • Cc kcrisman benjaminfjones added

comment:4 Changed 4 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 4 years ago by chapoton

  • Keywords hypergeometric added

comment:6 Changed 3 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:7 Changed 3 years ago by knsam

  • Status changed from needs_review to needs_work

comment:8 Changed 3 years ago by knsam

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 3 years ago by nbruin

is this a dupe of #2516?

comment:10 Changed 3 years ago by eviatarbach

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 3 years ago by jkeitel

  • 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:

4b4ed75Merge branch 'develop' into t/2516/ticket/2516
0dbbacd2516: fix last doctests
934d0572516: remove hack
0f5a4ff2516: fix doctest
eeb273eMerge branch 'develop' into t/2516/ticket/2516
62f7faaMerge branch 'master' into t/2516/ticket/2516
9c6749ddoctest coverage
051edffMerge branch 'develop' into t/2516/ticket/2516
9d6eea1# Branch hyper
3b32a6cRemove trailing whitespace and fix a few doctests by adding algorithm argument.

comment:12 Changed 3 years ago by rws

  • Branch changed from u/jkeitel/ticket/14896 to u/rws/ticket/14896

comment:13 Changed 3 years ago by rws

  • Commit changed from 3b32a6cf6f625ac5d0ca263f6acbc3b5ad7b0899 to b87c57b409b7d9df972ec88b7f0500e3ce51c89e

Documentation as is looks good. I fixed a newly appearing doctest fail.


Last 10 new commits:

e5a53436882: do word search/replace for symtable keys
4c1b0eb6882: correction to previous commit
518de3e6882: add symable rules for e,i,I; fix maxima_var; add doctests
7a6696bMerge branch 'u/rws/bugs_in_conversion_of_variable_names_from_maxima_to_sage' of trac.sagemath.org:sage into t/8734/ticket/8734-1
a8df107Merge branch 't/8734/ticket/8734-1' into t/16007/ticket/16007
9e66d16Merge commit 'a8df107e76527d83a87456520395ab85dbc44050' of trac.sagemath.org:sage into t/2516/public/hypergeometric
5ac82242516: fix doctests affected by 16007 merge
b2f8dc52516: this 16007-related doctest fail seems to be uncovered only by 2516, so fix it here
c2b74cbMerge branch 't/2516/b2f8dc5a1c82312271f2e2361b142358a66d0965' into t/14896/ticket/14896
b87c57b14896: fix doctest failing due to changes by 16007

comment:14 follow-up: Changed 3 years ago by rws

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 ; follow-up: Changed 3 years ago by nbruin

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 ; follow-up: Changed 3 years ago by kcrisman

(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 3 years ago by rws

Replying to kcrisman:

Maybe we can make it by gamma - upper incomplete?

Maybe define it in special.py both as maxima and Sage-evaluated (gamma-gamma_inc) function. Objections?

comment:18 Changed 3 years ago by nbruin

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 3 years ago by rws

  • Status changed from needs_work to needs_review

I think this warrants a ticket of its own: #16697

And it should not stay in the way of this issue. The reason for needs-work was the missing git branch (comment:8). Please review.

comment:20 Changed 3 years ago by nbruin

  • Dependencies changed from #2516 to #2516, #16697

I don't think this can be merged independently (but it can be reviewed independently) because without #16697, it can create problematic expressions (gamma_greek has no meaning in sage). So I'm setting #16697 (which should be easy) as a dependency for this ticket.

comment:21 Changed 3 years ago by git

  • Commit changed from b87c57b409b7d9df972ec88b7f0500e3ce51c89e to e699b41b195441c5b6da96a54be699a16b8fab9c

Branch pushed to git repo; I updated commit sha1. New commits:

1e5f52414896: improve doctest coverage
c4f2c7116697: tidy up gamma1, gamma_inc, gamma documentation
93c2f9416697: deprecate "incomplete_gamma"
5c1dd6716697: implement gamma_inc_lower
e699b41Merge branch 't/16697/implement_symbolic_lower_incomplete_gamma_function' into t/14896/ticket/14896

comment:22 Changed 3 years ago by rws

  • Merged in set to #16697

comment:23 Changed 3 years ago by git

  • Commit changed from e699b41b195441c5b6da96a54be699a16b8fab9c to ef78ae1641ee83dc8ca864013b3a62784b9c78f6

Branch pushed to git repo; I updated commit sha1. New commits:

ef78ae114896: use mpmath as default evalf algorithm

comment:24 Changed 3 years ago by git

  • Commit changed from ef78ae1641ee83dc8ca864013b3a62784b9c78f6 to 4c473be4ea871b4d32034245bbde30499b2b61a6

Branch pushed to git repo; I updated commit sha1. New commits:

4c473beMerge branch 'develop' into t/14896/ticket/14896

comment:25 Changed 3 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:26 Changed 3 years ago by git

  • Commit changed from 4c473be4ea871b4d32034245bbde30499b2b61a6 to eef585a99d1a2f7b4bb416ad76124236209de521

Branch pushed to git repo; I updated commit sha1. New commits:

eef585aMerge branch 'develop' into t/14896/ticket/14896

comment:27 Changed 3 years ago by git

  • Commit changed from eef585a99d1a2f7b4bb416ad76124236209de521 to 76d3545efb39cf2c83a90842d59570df20722e03

Branch pushed to git repo; I updated commit sha1. New commits:

76d354514896: remove merge markers, resolve

comment:28 Changed 3 years ago by rws

  • Authors set to Eviatar Bach, Ralf Stephan
  • Keywords kummer added
  • Merged in #16697 deleted

comment:29 Changed 3 years ago by git

  • Commit changed from 76d3545efb39cf2c83a90842d59570df20722e03 to b8197b13db132d18901a5d889ded44061f36f7bc

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

705c34e16697: fix a related bug
a73c5e316697: fix previous patch and a doctest
7558a7c16697: revert fix in favor of merge of 16785
1fc19e7Merge branch 't/16785/ticket/16785' into t/16697/implement_symbolic_lower_incomplete_gamma_function
9033be8Merge branch 'develop' into t/16697/implement_symbolic_lower_incomplete_gamma_function
05195e7Merge branch 'develop' into t/16697/implement_symbolic_lower_incomplete_gamma_function
a383a5bMerge branch 'u/jdemeyer/ticket/17130' of trac.sagemath.org:sage into t/16697/implement_symbolic_lower_incomplete_gamma_function
6f59f3a16697: adaptations due to trac 17130
a91bebbMerge branch 'u/rws/implement_symbolic_lower_incomplete_gamma_function' of trac.sagemath.org:sage into t/14896/ticket/14896
b8197b114896: adaptations due to recent BuiltinFunction changes

comment:30 Changed 3 years ago by kcrisman

  • 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 3 years ago by git

  • Commit changed from b8197b13db132d18901a5d889ded44061f36f7bc to abad8a3c7e43e15cb9a8a8f3a270be216da1819a

Branch pushed to git repo; I updated commit sha1. New commits:

a61c949Merge branch 'develop' into t/14896/ticket/14896
abad8a3Merge branch 'develop' into t/14896/ticket/14896

comment:32 Changed 3 years ago by rws

  • Status changed from needs_work to needs_review

comment:33 Changed 3 years ago by chapoton

  • Status changed from needs_review to needs_work

branch is red, needs rebase

comment:34 Changed 3 years ago by git

  • Commit changed from abad8a3c7e43e15cb9a8a8f3a270be216da1819a to a628fcbd0ec00f33d69f93304153a81463ec08d3

Branch pushed to git repo; I updated commit sha1. New commits:

a628fcbMerge branch 'develop' into t/14896/ticket/14896

comment:35 Changed 3 years ago by rws

Also needs merge in of updated #16697 and a squash.

comment:36 Changed 3 years ago by rws

  • Milestone changed from sage-6.4 to sage-pending

Pending because #16697 is pending.

comment:37 Changed 17 months ago by rws

  • Branch changed from u/rws/ticket/14896 to u/rws/14896

comment:38 Changed 17 months ago by rws

  • Commit changed from a628fcbd0ec00f33d69f93304153a81463ec08d3 to da3a146a9ef69ff80e36e30f7e67a7ea56cd1312
  • Milestone changed from sage-pending to sage-7.3
  • Status changed from needs_work to needs_review

Updated with newest #16697, squashed into three tickets, removed pending. Please review.


New commits:

0e19f0bMerge branch 'develop' into u/jkeitel/ticket/14896
da3a14614896: fix documentation, doctests, coverage; use mpmath, other

comment:39 Changed 17 months ago by rws

Please review/merge #16697 first (its commit metadata is missing here).

comment:40 Changed 16 months ago by paulmasson

Ralf, I'm trying to merge existing commits to a branch that already includes #16697 but I'm getting errors:

    STDOUT: Auto-merging src/sage/symbolic/expression_conversions.py
    STDOUT: CONFLICT (content): Merge conflict in src/sage/symbolic/expression_conversions.py
    STDOUT: Auto-merging src/sage/symbolic/expression.pyx
    STDOUT: Auto-merging src/sage/functions/special.py
    STDOUT: Auto-merging src/sage/functions/other.py
    STDOUT: CONFLICT (content): Merge conflict in src/sage/functions/other.py
    STDOUT: Auto-merging src/sage/functions/hypergeometric.py
    STDOUT: Auto-merging 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 16 months ago by git

  • Commit changed from da3a146a9ef69ff80e36e30f7e67a7ea56cd1312 to 58f6a1276a46c70dc9f0e42b5ccb0ab15dbcae10

Branch pushed to git repo; I updated commit sha1. New commits:

58f6a12Merge branch 'develop' into t/14896/14896

comment:42 Changed 16 months ago by paulmasson

Still getting an error:

    STDOUT: Auto-merging src/sage/symbolic/expression_conversions.py
    STDOUT: CONFLICT (content): Merge conflict in src/sage/symbolic/expression_conversions.py
    STDOUT: Auto-merging src/sage/functions/all.py
    STDOUT: Automatic merge failed; fix conflicts and then commit the result.

comment:43 Changed 16 months ago by rws

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 16 months ago by paulmasson

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 16 months ago by git

  • Commit changed from 58f6a1276a46c70dc9f0e42b5ccb0ab15dbcae10 to 23a5c6531df9d9f0b9b553d0754c731ef2b17266

Branch pushed to git repo; I updated commit sha1. New commits:

23a5c65Merge branch 'develop' into t/14896/14896

comment:46 Changed 16 months ago by rws

I updated to beta6 and had a merge conflict there too which should be resolved now. Let's try again, please.

comment:47 Changed 16 months ago by paulmasson

  • 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 16 months ago by rws

Thanks for the review.

comment:49 Changed 16 months ago by vbraun

  • Branch changed from u/rws/14896 to 23a5c6531df9d9f0b9b553d0754c731ef2b17266
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.