Documentation moved.
This entry is documented with its primary interface. Open the documentation →
Function
src/math/series.ts:56sum
sum(expr: ExpressionInput, index: ExpressionInput, lower: ExpressionInput, upper: ExpressionInput): ExpressionComputes a finite summation: sum(expr, k, a, b) = Σ_{k=a}^{b} expr.
- If bounds are integers and the number of terms ≤ Settings.MAX_PRODUCT_AND_SUMMATION_ITERATION,
evaluates by accumulating each term.
- If lower > upper, returns 0 (empty range).
- If expr does not depend on the index variable, simplifies to expr · (b − a + 1).
- Otherwise returns a symbolic sum(expr, k, a, b) node.
Parameters
| Name | Type | Description |
|---|---|---|
expr | ExpressionInput | The expression to be summed. |
index | ExpressionInput | The index variable (must be a plain symbol). |
lower | ExpressionInput | The lower bound (integer required for evaluation). |
upper | ExpressionInput | The upper bound (integer required for evaluation). |
Returns
Expression — The summation result or a symbolic sum node.
Examples
// Σ_{k=1}^{5} k = 15
sum('k', 'k', 1, 5).text() // "15"