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

U(a,b,z) returns results different from Mathematica/MATLAB when z is negative #63

Open
Haonan-Zhou opened this issue May 3, 2023 · 1 comment

Comments

@Haonan-Zhou
Copy link

Haonan-Zhou commented May 3, 2023

Hi,

Thanks a lot for the wonderful package!

This issue might be related to #61 , but I tried to compare the result of the Tricomi confluent hypergeometric function HypergeometricFunctions.U(a,b,z) across softwares when the final argument z is a negative number. Here are some results:

Experiment 1: Evaluate U(0.5, 0.5, -2.5):

  • Mathematica: HypergeometricU[0.5, 0.5, -2.5] yields 0.145492 - 0.810467i.
  • MATLAB: kummerU(0.5, 0.5, -2.5) yields 0.1455 - 0.8105i.
  • Julia: HypergeometricFunctions.U(0.5, 0.5, Complex(-2.5)) yields 0.0 - 1.1612906236707266im.

Note that HypergeometricFunctions.U(0.5, 0.5, -2.5) throws a DomainError with -2.5: Exponentiation yielding a complex result requires a complex argument. Probably one needs to make sure z^(1-b) is defined for negative real z.

Experiment 2: Evaluate U(-0.5 -0.5, -2.5):

  • Mathematica: HypergeometricU[-0.5, -0.5, -2.5] yields 0.0727459 + 1.17591i.
  • MATLAB: kummerU(-0.5, -0.5, -2.5) yields 0.0727 + 1.1759i.
  • Julia: HypergeometricFunctions.U(-0.5, -0.5, Complex(-2.5)) yields 0.0 + 0.0im.

The issue does not seem to appear (the results matches across platforms) if z is a positive real or z is a complex number with a negative real part:

Experiment 3: Evaluate U(-0.5 -0.5, -2.5-1.5im):

  • Mathematica: HypergeometricU[-0.5, -0.5, -2.5-1.5i] yields 0.595921 - 1.34976i.
  • MATLAB: result is 0.5959 - 1.3498i.
  • Julia: result is 0.5959210215481137 - 1.3497630048128746im.

Environment: Julia 1.8.5, package ver. 0.3.15. MATLAB R2022a. Mathematica 12.3.1.0 on a macOS 13.3.

@MikaelSlevinsky
Copy link
Collaborator

Thanks for filing the issue! Evaluating U near the branch cut (-∞,0] requires a different approach, such as Kummer's transformation #61.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants