### 7.4.8 Barycenter of complex numbers

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 arbitrary 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.

##### Remark.

Note that the barycenter command returns a point, not an affix. To output the point affix, you must input affix(barycenter(l1,l2)) (see Section 26.12.1).

#### Example

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

or:

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

3+i
3