importPour l'utiliser : import Data.Complex
Data.Complex — complex numbers, parametric over the component type
Synopsis
data Complex a = MkComplex a a
A complex number r :+ im over a component type a. Parametric so that Complex Double gives the usual floating-point complex numbers and Complex Rational gives EXACT (Gaussian-rational) ones — the latter satisfy the ring/field laws exactly (no floating error). Complex a inherits the numeric tower from a: it is a DivisionRing when a is one, and a Field when a is a Field.
complex : a -> a -> Complex a
realPart : Complex a -> a
imagPart : Complex a -> a
imagUnit : FromNat a => Additive a => Multiplicative a => Complex a
The imaginary unit 0 :+ 1 (needs a 0 and a 1 from the component type: zero is Additive, one is Multiplicative — the signature declared only the first until 2026-09-14, and a silently became Int because a signature's variable was not yet rigid, KB-24).
conjugate : AdditiveGroup a => Complex a -> Complex a
The complex conjugate r :+ (-im).
magnitudeSquared : Semiring a => Complex a -> a
The squared modulus r² + im² (a component-typed value; avoids sqrt, so it works for any ring component, including exact Rational).
magnitude : Complex Double -> Double
The modulus √(r² + im²), for floating components only (sqrt is Double).