UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.

49 lines (32 loc) 869 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 ```js 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 ## Examples ```js 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](mean.md), [median](median.md), [min](min.md), [max](max.md), [prod](prod.md), [std](std.md), [var](var.md) <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->