Complex
Lean: Hale.Base.Complex | Haskell: Data.Complex
Overview
Complex numbers parameterized by coefficient type. Supports arithmetic operations and conjugation.
API Mapping
| Lean | Haskell | Kind |
|---|---|---|
Complex | Complex | Type |
re / im | realPart / imagPart | Accessor |
ofReal | (:+ 0) | Constructor |
i | 0 :+ 1 | Constant |
conjugate | conjugate | Function |
magnitudeSquared | magnitude ^2 | Function |
Instances
Inhabited (Complex a)(requiresInhabited a)ToString (Complex a)(requiresToString a)Add (Complex a)(requiresAdd a)Neg (Complex a)(requiresNeg a)Sub (Complex a)(requiresSub a)Mul (Complex a)(requiresAdd a,Sub a,Mul a)BEq (Complex a)(derived)Ord (Complex a)(derived)Repr (Complex a)(derived)Hashable (Complex a)(derived)
Proofs & Guarantees
conjugate_conjugate—conjugate (conjugate z) = z(involution)add_comm'—z1 + z2 = z2 + z1
Example
-- Compute magnitude squared of 3 + 4i
Complex.magnitudeSquared ⟨3, 4⟩
-- => 25 (since 3^2 + 4^2 = 25)