gives the total of the elements in list.


totals all elements down to level n.


totals elements at level n.


totals elements at levels n1 through n2.

Details and Options


open allclose all

Basic Examples  (1)

Total the values in a list:

Scope  (6)

Use exact arithmetic to total the values:

Use machine arithmetic:

Use 47-digit precision arithmetic:

Total the columns of a matrix:

Total the rows:

Total all the elements:

Total by adding parts in the first dimension:

Total in the last dimension only:

Total in the last two dimensions:

Total all but the last dimension:

Total all the elements:

Total the last dimension in a ragged array:

Total all the elements:

You cannot total in the first dimension because the lists have incompatible lengths:

Total the columns in a sparse matrix:

Total the rows:

Total several sparse vectors:

Total all the elements in all the vectors:

Options  (2)

Method  (1)

Use Method->"CompensatedSummation" to reduce accumulated errors in a sum:

Without compensated summation, small errors may accumulate with each term:

AllowedHeads  (1)

Total[expr,AllowedHeads->Inherited] works with any head:

Find the total derivative order:

Applications  (3)

Form a polynomial from monomials:

Show that the trace of a matrix is equal to the total of its eigenvalues:

Search for "perfect" numbers equal to the sum of their divisors:

Properties & Relations  (2)

Total[list] is equivalent to Apply[Plus,list]:

Total[list,k] is equivalent to Total[Flatten[list,k-1]]:

Introduced in 2003
Updated in 2007