From: Stefan Weinzierl Date: Sun, 12 Jan 2014 21:58:12 +0000 (+0000) Subject: Avoid calling log(1-x) for x=1 in Li_projection. X-Git-Tag: release_1-6-3~29 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=a4ad8cb5a89db1405fbdcaae12aef3c07904efd8 Avoid calling log(1-x) for x=1 in Li_projection. --- diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 5f5949b6..7487b314 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -346,7 +346,11 @@ cln::cl_N Li_projection(int n, const cln::cl_N& x, const cln::float_format_t& pr } else { // choose the faster algorithm if (cln::abs(cln::realpart(x)) > 0.75) { - return -Li2_do_sum(1-x) - cln::log(x) * cln::log(1-x) + cln::zeta(2); + if ( x == 1 ) { + return cln::zeta(2); + } else { + return -Li2_do_sum(1-x) - cln::log(x) * cln::log(1-x) + cln::zeta(2); + } } else { return -Li2_do_sum_Xn(1-x) - cln::log(x) * cln::log(1-x) + cln::zeta(2); } @@ -368,7 +372,8 @@ cln::cl_N Li_projection(int n, const cln::cl_N& x, const cln::float_format_t& pr return Lin_do_sum_Xn(n, x); } } else { - cln::cl_N result = -cln::expt(cln::log(x), n-1) * cln::log(1-x) / cln::factorial(n-1); + cln::cl_N result = 0; + if ( x != 1 ) result = -cln::expt(cln::log(x), n-1) * cln::log(1-x) / cln::factorial(n-1); for (int j=0; j