A complex number $z = \text{re} + \text{im} \cdot i$ over a type α.
$$\mathbb{C}(\alpha) = \{ a + bi \mid a, b \in \alpha \}$$
Provides addition, multiplication, conjugation, and magnitude squared.
- re : α
The real part: $\text{Re}(z)$.
- im : α
The imaginary part: $\text{Im}(z)$.
Instances For
@[implicit_reducible]
Equations
@[implicit_reducible]
Equations
- Data.instOrdComplex = { compare := Data.instOrdComplex.ord }
@[implicit_reducible]
Equations
- Data.instReprComplex = { reprPrec := Data.instReprComplex.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[implicit_reducible]
Equations
@[inline]
Construct a purely real complex number: $a + 0i$.
Equations
- Data.Complex.ofReal a = { re := a, im := 0 }
Instances For
@[inline]
The imaginary unit: $i = 0 + 1i$.
Equations
- Data.Complex.i = { re := 0, im := 1 }
Instances For
@[implicit_reducible]
Multiplication of complex numbers: $$(a + bi)(c + di) = (ac - bd) + (ad + bc)i$$
Magnitude squared (norm squared): $$|z|^2 = \text{Re}(z)^2 + \text{Im}(z)^2 = z \cdot \overline{z}$$
Returns a real value. Avoids square roots for exact arithmetic.