Function reference · Calculus

sum

Adds up an expression over a range of an integer index.

With number bounds, it adds the terms. With a symbolic bound, it finds a closed form where it can, as for powers of the index; otherwise the call is returned unevaluated.

Notation

sum(expr, index, lower, upper)

Write it in an expression: nerdamer('sum(k,k,1,5)'), or in the Playground.

nerdamer.sum

nerdamer.sum(expr: ExpressionInput, index: ExpressionInput, lower: ExpressionInput, upper: ExpressionInput): Expression

A method on the default import. Arguments can be strings, as in Notation.

import { sum }

import { sum } from 'nerdamer/calculus';
sum(expr: ExpressionInput, index: ExpressionInput, lower: ExpressionInput, upper: ExpressionInput): Expression

Import only this function, from nerdamer/calculus.

Examples

1+2+3+4+5.

sum(k,k,1,5)
// → 15
Open in Playground

Index into a vector.

V:[x,x^2-1,2]; sum(3*V[k],k,0,size(V)[0]-1)
// → 3+3*x+3*x^2
Open in Playground

Symbolic coefficients.

sum((a*k+b)^2,k,1,5)
// → (b+a)^2+(b+2*a)^2+(b+3*a)^2+(b+4*a)^2+(b+5*a)^2
Open in Playground

A closed form for a symbolic bound.

sum(k^2,k,1,n)
// → (1/6)*n*(1+n)*(1+2*n)
Open in Playground

No closed form: unevaluated.

sum(sin(k),k,1,n)
// → sum(sin(k), k, 1, n)
Open in Playground

The index is local to the call, so a stored k doesn't change the terms.

k:5; sum(k,k,1,3)
// → 6
Open in Playground

Stored values still apply in the bounds.

n:3; sum(k,k,1,n)
// → 6
Open in Playground

← Back to Function reference