simple-squiggle/node_modules/mathjs/docs/reference/functions/sum.md

948 B

Function sum

Compute the sum of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the sum of all elements will be calculated.

Syntax

math.sum(a, b, c, ...)
math.sum(A)

Parameters

Parameter Type Description
args ... * A single matrix or or multiple scalar values

Returns

Type Description
  • | The sum of all values

Throws

Type Description

Examples

math.sum(2, 1, 4, 3)               // returns 10
math.sum([2, 1, 4, 3])             // returns 10
math.sum([[2, 5], [4, 3], [1, 7]]) // returns 22

See also

mean, median, min, max, prod, std, variance, cumsum