_Reduction
sum(e, k, lo, hi) / product(e, k, lo, hi) -- a finite reduction over an integer range.
The counterpart of _Tabulate, which yields the terms rather than their total, and the reason a summation could not be converted from the editor before: tabulate is not an answer to a Σ, so the AsciiMath reader had nothing to translate one into and refused it by name. Same shape as tabulate -- k is a binder (excluded from children, carried through rebuild, so substitute cannot rewrite it) while lo/hi are ordinary children, the _DefIntegral convention -- and the same MaxTabulateTerms cap, shared through indexRange.
The terms are folded with reduce, never a seeded fold. Seeding with a literal _Number(0) would be an inexact-tier constant, so an exact sum would be demoted through float contagion before anything could use it -- the numeric-tier rule, and the single most repeated bug of issues 4.L and 4.N. The identity is therefore used for the empty range only, where there is nothing to combine with and nothing to demote.
An empty range is the identity rather than a refusal, unlike tabulate's empty grid: the empty sum is 0 and the empty product 1 by universal convention, which is exactly what makes sum(f, k, 1, n) read correctly at n = 0 instead of declining a base case.
Symbolic terms EXPAND. sum(k*x, k, 1, 3) becomes x + 2x + 3x rather than staying folded, so normalize/simplify can collect it -- and since this is a _Functional, F_0034's pass reduces it under the simplify command with no further wiring.
Value parameters
- e
-
the term, in which
vis bound - hi
-
the last index, inclusive
- kind
-
which reduction this is
- lo
-
the first index, inclusive
- v
-
the index variable (a binder)
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass Any