Skip to content

Commit

Permalink
WIP #929 avoid StackOverflow
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Mar 18, 2024
1 parent 92942cc commit ac76a9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public static Complex polyLog(final Complex n, final Complex x) {
return x.divide(Complex.ONE.subtract(x).multiply(Complex.ONE.subtract(x)));
}

if (cabs(x) >= 1.0) {
if (cabs(x) > 1.0) {

if (F.isZero(n.getImaginary()) && F.isNumIntValue(n.getReal()) && n.getReal() > 0.0) {

Expand Down Expand Up @@ -447,7 +447,7 @@ public static Complex polyLog(final double n, final double x) {
return new Complex(x / (oneMinusX * oneMinusX));
}

if (Math.abs(x) >= 1.0) {
if (Math.abs(x) > 1.0) {
if (F.isNumIntValue(n) && n > 0.0) {
final int nInt = NumberUtil.toInt(n);
Complex twoPiI = new Complex(0, 2 * Math.PI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18650,10 +18650,11 @@ public void testPolyGamma() {
@Test
public void testPolyLog() {
// issue #929
// check("(PolyLog(2,E^(I*1/270*Pi^2)))/Pi // N", //
// " ");
// check("PolyLog(2,0.9993319736282411 + 0.03654595031305655*I)", //
// "");
// message Infinite or NaN number in z1 calculation.
check("(PolyLog(2,E^(I*1/270*Pi^2)))/Pi // N", //
"0.31831*PolyLog(2.0,0.999332+I*0.036546)");
check("PolyLog(2,0.9993319736282411 + 0.03654595031305655*I)", //
"PolyLog(2,0.9993319736282411+I*0.03654595031305655)");

check("PolyLog(2,z) + PolyLog(2,1-z)", //
"Pi^2/6-Log(1-z)*Log(z)");
Expand Down

0 comments on commit ac76a9a

Please sign in to comment.