This is an old version, view current version.

4.3 Complex arithmetic operators

The arithmetic operators have the same precedence for complex and real arguments. The complex form of an operator will be selected if at least one of its argument is of type complex. If there are two arguments and only one is of type complex, then the other will be promoted to type complex before performing the operation.

4.3.1 Unary operators

complex operator+(complex z)
Return the complex argument z, \[ +z = z. \]
Available since 2.28

complex operator-(complex z)
Return the negation of the complex argument z, which for \(z = x + yi\) is \[ -z = -x - yi. \]
Available since 2.28

4.3.2 Binary operators

complex operator+(complex x, complex y)
Return the sum of x and y, \[ (x + y) = \text{operator+}(x, y) = x + y. \]
Available since 2.28

complex operator-(complex x, complex y)
Return the difference between x and y, \[ (x - y) = \text{operator-}(x, y) = x - y. \]
Available since 2.28

complex operator*(complex x, complex y)
Return the product of x and y, \[ (x \, * \, y) = \text{operator*}(x, y) = x \times y. \]
Available since 2.28

complex operator/(complex x, complex y)
Return the quotient of x and y, \[ (x / y) = \text{operator/}(x,y) = \frac{x}{y} \]
Available since 2.28

complex operator^(complex x, complex y)
Return x raised to the power of y, \[ (x^\mathrm{\wedge}y)= \text{operator}^\mathrm{\wedge}(x,y) = \textrm{exp}(y \, \log(x)). \]
Available since 2.28