NSum
A numeric series -- a finite range summed directly, or a in b = Infinity accelerated to a tight, checked tolerance.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
NSum!NSum(f, {n, a, b})the finite sum of f(n) for n from a to b (both integers).NSum(f, {n, a, Infinity})the numeric value of the infinite series, accelerated and error-checked against a strict ~1e-12 relative tolerance (tightened internally to 1e-14 -- see details); declines rather than guess when the check doesn't clear it.Typed signatures
| Type | Package | Applies |
|---|---|---|
(expression, tuple<symbol, integer, infinity | integer>) -> number | analytic | always |
Details
- Two acceleration methods, chosen by how the terms behave (a term that doesn't shrink at all declines immediately, before either gets a chance): a term whose sign strictly alternates goes through Wynn's epsilon algorithm (a generalization of Aitken's Delta-squared process) on the partial sums -- exact to full double precision for the alternating harmonic series. Otherwise, a term asymptotic to a smooth power law C*n^-p (p estimated locally from two term ratios) goes through Euler-Maclaurin, truncated at its smallest correction term, cross-checked at three truncation depths (200/500/1000 direct terms) -- exact to full double precision for zeta(2) and zeta(3), and accurate to ~14 digits for the much more slowly convergent zeta(1.1).
- The internal cross-check tolerance is 1e-14, two orders of magnitude tighter than the ~1e-12 this head promises: checked against mpmath and the true zeta values, the cross-check's OWN error estimate can be optimistic by 1-3 orders of magnitude on a series whose local power-law estimate is contaminated by a secondary term (e.g. n / (n^3 + 1)) or whose exponent sits very close to 1 (zeta(1.01)) -- the tighter internal bar is what keeps those correctly declining instead of reporting a false ~12 digits.
- A term that's non-finite anywhere in the first 60 probed values (a domain edge, a pole) declines, as does any term sequence whose Solve-independent divergence check fails (the tail isn't actually shrinking).
- Always numeric -- never returns an exact closed form; that is Sum's job, when a series has one.
Examples
Basic #
Scope #
Sum 1/n^1.1 = zeta(1.1) -- far slower than zeta(2), but Euler-Maclaurin still clears the bar
live ↗InOut
Possible issues #
About
| Examples | 7 |
|---|---|
| Checked against | Wolfram Language 5 agree2 differ |
| Crosswalk | Wolfram Language |