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

Inaccurate quadrant 3 hyperu(1, x, y), does not attain required precision or raise error #658

Open
JubilantJerry opened this issue Mar 7, 2023 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@JubilantJerry
Copy link

mpmath version: 1.2.1
OS: Windows 10

When I run the following:

print("Low precision: ", mpmath.hyperu(1, -473.1, 156))
with mpmath.extraprec(1000):
    print("High precision: ", mpmath.hyperu(1, -473.1, 156))

I get:

Low precision:  -1.12058697578989e+44
High precision:  0.001586425835211121087681179361528927983242277888339631178609757381602116352014620984480403121211547027499627345216063020035934706802772039354304125819952326262751451176676820907796632804032104350623713922869560129245748835027779792137220628978091592575872212530734647063184344560862957299239418155652367375142065798074

I believe the correct result is the one that's close to 0.001586. The expected behavior is for the function to either return the value accurate to within 2 ** (-ctx.prec) relative error, or to raise an exception about a failure to converge. The 1e+44 value looks like a catastrophic cancellation error.

I must say though, I'm not so sure if this is easy to fix. Hypergeometric functions are evil.

At least for hyperu(1, x, y) for large x, y of similar magnitude, it empirically seems like the value is close to x / ((x - y) * (1 - x)). But I don't know what asymptotic expansion this comes from, or how fast that converges.

@fredrik-johansson
Copy link
Collaborator

Underlying issue:

>>> hyp1f1(1, -473.1, 156.0)
mpf('0.75212448847359259')
>>> mp.dps = 100
>>> hyp1f1(1, -473.1, 156.0)
mpf('53127028522198644725991850247300014579264749325.94652477156923010775254686158221630123354152926509969849')

@skirpichev skirpichev added the bug an unexpected problem or unintended behavior label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants