I'm doing a sanity check of the following equation: $$\sum_{j=2}^\infty \frac{(-x)^j}{j!}\zeta(j) \approx x(\log x + 2 \gamma -1)$$
Naive comparison of the two shows a bad match but I suspect one of the graphs is incorrect.
- Why isn't there a warning?
- How do I compute this sum correctly?
katsurda[x_] := NSum[(-x)^j/j! Zeta[j], {j, 2, Infinity}];
katsurdaApprox[x_] := x (Log[x] + 2 EulerGamma - 1) - Zeta[0];
plot1 = DiscretePlot[katsurda[x], {x, 0, 40, 2}];
plot2 = Plot[katsurdaApprox[x], {x, 0, 40}];
Show[plot1, plot2]
- meta How do I avoid being mislead by incorrect numeric results? Would using
NIntegrate
instead ofNSum
give better guarantees? My usual approach of a avoiding machine precision, checkingPrecision
of the answer and minding warnings fails in the example below
katsurda[x_] :=
NSum[(-x)^j/j! Zeta[j], {j, 2, Infinity}, WorkingPrecision -> 32,
NSumTerms -> 2.5 x];
katsurdaApprox[x_] := x (Log[x] + 2 EulerGamma - 1) - Zeta[0];
Print["Precision: ", Precision@katsurda[100]] (* 13.9729 *)
Print["Discrepancy: ", katsurda[100] - katsurdaApprox[100]] (* 94.65088290385, but should be <1 *)
Background: the expression comes from "Power series with the Riemann zeta-function in the coefficients" by Katsurada M (paper)
NSum
. I have a good idea how many of the methods ofNIntegrate
andNDSolve
work. One test is to raiseWorkingPrecision
andPrecisionGoal
, and perhapsAccuracyGoal
, and see if the result is stable. That hasn't always been reliable forNSum
for me. ThePrecision
of an answer in Mma usually indicates only the effect of round-off. It is not good indicator of convergence/nonconvergence. For the sum at hand, since it is alternating and eventually decreasing in magnitude,Method -> "AlternatingSigns"
, should be reliable. $\endgroup$NSumTerms
. I tried to use NIntegrate by splitting series into positive/negative parts and treating each as Riemann sum, but this approximation turned out to be bad for large x wolframcloud.com/obj/yaroslavvb/newton/forum-katsurda-split.nb $\endgroup$NIntegrate
couldn't handle the it. $\endgroup$NSumTerms->Automatic
:) $\endgroup$