Ask Your Question

How to increase maxterms for hypergeometric?

asked 2019-04-24 09:19:34 -0500

anonymous user


updated 2019-05-06 09:51:17 -0500

Iguananaut gravatar image

I'm trying to compute a (bunch of) hypergeometric functions for which I get a NoConvergence error


hypergeometric([4.14 + 15*I, -3.14 + 15*I],[1. - 1.12e7*I], -500000)

The suggestion of the error message is to try increasing 'maxterms'. However, I don't seem to find a way to do this as e.g.hypergeometric([4.14 + 15*I, -3.14 + 15*I],[1. - 1.12e7*I], -500000,maxterms=10^6) does not work.

(I could be missing something very basic, I'm rather new to sage)

edit retag flag offensive close merge delete


(please note, when pasting code it's important to be careful of formatting, as some symbols such as * have special meaning in markdown; always format code examples either by indenting a whole line with 4 spaces or putting bits of code in backtick quotes)

Iguananaut gravatar imageIguananaut ( 2019-04-24 09:37:50 -0500 )edit

Indeed, that is not a very helpful message. It seems that the underlying low-level sage.libs.mpmath.ext_impl.MPF_hypsum function does accept a maxterms argument, but there is a disconnect that prevents this from being passed to it from the higher-level generic hypergeometric function. I would consider this a bug.

Iguananaut gravatar imageIguananaut ( 2019-04-24 09:44:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-04-24 09:59:05 -0500

Iguananaut gravatar image

By digging into the code and going a little lower-level I was able to do effectively the same thing while close-enough to the lower-level code that it accepted the maxterms argument (of course, you shouldn't have to do this at all and I would consider it a bug):

sage: from mpmath import hyper
sage: from sage.libs.mpmath import utils as mpmath_utils
sage:, [4.14 + 15*I, -3.14 + 15*I],[1. - 1.12e7*I], -500000, maxterms=10^6)
-608213.273405350 - 24201.2928264098*I

I make no guarantee as to the accuracy of the result or if it's even expected be convergent for the given $a$'s and $b$'s.

edit flag offensive delete link more


Thanks! This indeed works and I will heed your word of caution but mathematica seems to agree ...

virtual_neutrino gravatar imagevirtual_neutrino ( 2019-04-25 06:32:43 -0500 )edit

Great. I went ahead and opened a ticket for the maxtermsissue: Coincidentally, a different bug involving arguments to hypergeometric was just fixed, but I don't think it has anything to do with this one.

Iguananaut gravatar imageIguananaut ( 2019-05-06 09:51:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-04-24 09:19:34 -0500

Seen: 37 times

Last updated: Apr 24