JuliaMath / JuliaMath/HypergeometricFunctions.jl

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

Open
#63 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
76
Forks
12
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.