Documentation

Hale.Base.Data.Complex

structure Data.Complex (α : Type u) :

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]
    instance Data.instBEqComplex {α✝ : Type u_1} [BEq α✝] :
    BEq (Complex α✝)
    Equations
    def Data.instBEqComplex.beq {α✝ : Type u_1} [BEq α✝] :
    Complex α✝Complex α✝Bool
    Equations
    Instances For
      def Data.instOrdComplex.ord {α✝ : Type u_1} [Ord α✝] :
      Complex α✝Complex α✝Ordering
      Equations
      Instances For
        @[implicit_reducible]
        instance Data.instOrdComplex {α✝ : Type u_1} [Ord α✝] :
        Ord (Complex α✝)
        Equations
        @[implicit_reducible]
        instance Data.instReprComplex {α✝ : Type u_1} [Repr α✝] :
        Repr (Complex α✝)
        Equations
        def Data.instReprComplex.repr {α✝ : Type u_1} [Repr α✝] :
        Complex α✝NatStd.Format
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[implicit_reducible]
          instance Data.instHashableComplex {α✝ : Type u_1} [Hashable α✝] :
          Equations
          def Data.instHashableComplex.hash {α✝ : Type u_1} [Hashable α✝] :
          Complex α✝UInt64
          Equations
          Instances For
            @[implicit_reducible]
            Equations
            @[implicit_reducible]
            instance Data.Complex.instToString {α : Type u_1} [ToString α] :
            Equations
            @[inline]
            def Data.Complex.ofReal {α : Type u_1} [OfNat α 0] (a : α) :

            Construct a purely real complex number: $a + 0i$.

            Equations
            Instances For
              @[inline]
              def Data.Complex.i {α : Type u_1} [OfNat α 0] [OfNat α 1] :

              The imaginary unit: $i = 0 + 1i$.

              Equations
              Instances For
                @[implicit_reducible]
                instance Data.Complex.instAdd {α : Type u_1} [Add α] :

                Addition of complex numbers: $$(a + bi) + (c + di) = (a + c) + (b + d)i$$

                Equations
                @[implicit_reducible]
                instance Data.Complex.instNeg {α : Type u_1} [Neg α] :

                Negation: $-(a + bi) = -a + (-b)i$.

                Equations
                @[implicit_reducible]
                instance Data.Complex.instSub {α : Type u_1} [Sub α] :

                Subtraction: $(a + bi) - (c + di) = (a - c) + (b - d)i$.

                Equations
                @[implicit_reducible]
                instance Data.Complex.instMulOfAddOfSub {α : Type u_1} [Add α] [Sub α] [Mul α] :

                Multiplication of complex numbers: $$(a + bi)(c + di) = (ac - bd) + (ad + bc)i$$

                Equations
                def Data.Complex.conjugate {α : Type u_1} [Neg α] (z : Complex α) :

                Complex conjugate: $\overline{a + bi} = a - bi$.

                Satisfies $z \cdot \overline{z} = |z|^2$.

                Equations
                Instances For
                  def Data.Complex.magnitudeSquared {α : Type u_1} [Add α] [Mul α] (z : Complex α) :
                  α

                  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.

                  Equations
                  Instances For
                    theorem Data.Complex.conjugate_conjugate {α : Type u_1} [Neg α] (hnn : ∀ (x : α), - -x = x) (z : Complex α) :

                    Conjugation is an involution: $\overline{\overline{z}} = z$. $$\overline{\overline{a + bi}} = \overline{a - bi} = a + bi$$

                    Requires that negation is involutive: $-(-x) = x$.

                    theorem Data.Complex.add_comm' {α : Type u_1} [Add α] (hc : ∀ (a b : α), a + b = b + a) (z w : Complex α) :
                    z + w = w + z

                    Addition is commutative: $(z_1 + z_2) = (z_2 + z_1)$.

                    Requires that the underlying type has commutative addition.