Alex Herbert created NUMBERS-209:
------------------------------------

             Summary: Infinite loop for Trigamma function on large negative 
values
                 Key: NUMBERS-209
                 URL: https://issues.apache.org/jira/browse/NUMBERS-209
             Project: Commons Numbers
          Issue Type: Bug
          Components: gamma
    Affects Versions: 1.3
            Reporter: Alex Herbert


The Trigamma function increments the input argument by 1 until it exceeds the 
threshold of 49. This is not suitable for large negative values (below -2^53) 
as the increment does not increment the argument.

Note that double values above 2^53 in magnitude are integers. For negative 
arguments any integer is a pole of the trigamma function and has the value 
+infinity.

However smaller magnitude arguments may take prohibitively long to compute by 
incrementing. In this case it is possible to use the reflection formula:
{noformat}
trigamma(x) + trigamma(1 - x) = pi^2 / sin^2(pi * x)

if x < 0:
    trigamma(x) = pi^2 / sin^2(pi * x) - trigamma(1 - x){noformat}
Issue identified using a security scan.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to