AngouriMath

Navigation

PolynomialSummation


← Back to list of classes

Description

Summary

A summation whose summand is a polynomial in the index, written as a polynomial in the
bounds: sum(k, k, 1, n) is n^2/2 + n/2.

Remarks

The operator writes itself out term by term where the bounds are concrete and few, and
otherwise stayed as written — so a symbolic bound had no answer at all, and neither did a
concrete range past a hundred terms. Both are the same gap: a sum of a polynomial has a
closed form, and computing it is cheaper than the expansion it replaces.
No Bernoulli numbers. The sum of a degree-d polynomial in the index is a
polynomial of degree d + 1 in the bound, which is the whole of what is needed: a
polynomial of that degree is determined by d + 2 of its values, and those values
are sums of d + 2 terms each, computed directly. Interpolating them recovers the
coefficients exactly, in rational arithmetic, with no table to carry and no identity to
get subtly wrong. Faulhaber's formula would give the same answer by a shorter route that
needs Bernoulli numbers, which the library does not have.
The condition is not decoration.sum(k, k, 1, n) is notn^2/2 + n/2 for every n: at n = -2 the range is empty and this
library answers an empty range with 0, while the polynomial gives 1. The
identity holds exactly when to >= from - 1, so that is what is attached, with the
empty-range value as the other branch. Where the bounds are concrete the condition is
decidable and the piecewise collapses to a number.
SymPy answers the same input with the bare polynomial and is not making a mistake: it
reads a reversed range as the negated sum over the flipped one, under which the identity
is unconditional. This library defines an empty range as the operator's identity instead,
and the condition is what that choice costs.

Members

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online