# Barycenter of complex numbers: barycenter

### 5.10.8 Barycenter of complex numbers: barycenter

The barycenter, or center of mass, of a set of points A1, A2,…,An with masses α1,α2,…,αn is

α1A1+⋯ + αnAn
α1+⋯ + αn

This formula makes sense even if the αj are not positive real numbers, and is still called the barycenter of the weighted points.

The barycenter command computes the barycenter of a set of weighted points.

- barycenter takes an unspecified number of arguments:
  each argument is a list lj=[Aj,αj] containing a point Aj (or the affix of a point) and a weight αj for the point. The sum of the weights needs to be non-zero.
  These lists can also be given as two columns of a matrix.
- barycenter(l1,l2,…,ln) returns the barycenter of the points Aj weighted by the real coefficients αj. If ∑αj = 0, barycenter returns an error.

Warning.
The barycenter command returns a point, not a complex number. To have a complex number in the output, the input must be affix(barycenter(l1,l2)) (see Section 13.13.1).

#### Example.

Input:

affix(barycenter([1+i,2],[1-i,1]))

or:

affix(barycenter([[1+i,2],[1-i,1]]))

Output:

3+i
3