Interface Field<E>

All Superinterfaces:
AbelianGroup<E>, AbelianMonoid<E>, Group<E>, Magma<E>, Monoid<E>, Ring<E>, Semiring<E>, Set<E>
All Known Implementing Classes:
Complex, Complexes, DoubleField, NativeRealBig, Octonion, Octonions, Quaternion, Quaternions, Rational, Rationals, Real, RealBig, RealDouble, RealFloat, Reals

public interface Field<E> extends Ring<E>
A field is a commutative ring where every non-zero element has a multiplicative inverse.

Fields are algebraic structures where addition, subtraction, multiplication, and division (except by zero) are all well-defined. They are fundamental in mathematics, appearing in linear algebra, number theory, and many applications.

Mathematical Definition

A field (F, +, ×) is a ring satisfying:

  1. Commutativity of multiplication: a × b = b × a
  2. Existence of unity: ∃ 1 ∈ F such that 1 × a = a for all a
  3. Multiplicative inverses: ∀ a ∈ F \ {0}, ∃ a⁻¹ such that a × a⁻¹ = 1
This means (F \ {0}, ×) forms an abelian group.

Examples

  • ℚ - Rational numbers
  • ℝ - Real numbers
  • â„‚ - Complex numbers
  • 𝔽ₚ - Integers modulo prime p
  • ℚ(√2) - Rationals extended with √2
  • ℝ(x) - Rational functions over reals

Not Fields

  • ℤ - Integers (no multiplicative inverses: 2⁻¹ ∉ ℤ)
  • Mâ‚‚(ℝ) - 2×2 matrices (not commutative)
  • ℤ/6ℤ - Integers mod 6 (zero divisors: 2 × 3 = 0 mod 6)

Usage

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • inverse

      E inverse(E element)
      Returns the multiplicative inverse of a non-zero element.

      For element a ≠ 0, returns a⁻¹ such that: a × a⁻¹ = a⁻¹ × a = 1

      Examples:

      • In ℚ: inverse(2/3) = 3/2
      • In ℝ: inverse(5.0) = 0.2
      • In â„‚: inverse(3+4i) = (3-4i)/25

      Specified by:
      inverse in interface Group<E>
      Parameters:
      element - the element to invert (must be non-zero)
      Returns:
      the multiplicative inverse
      Throws:
      NullPointerException - if element is null
      ArithmeticException - if element is zero
      See Also:
    • divide

      default E divide(E dividend, E divisor)
      Returns the quotient of two elements (division).

      Defined as: a ÷ b = a × b⁻¹

      Parameters:
      dividend - the dividend (numerator)
      divisor - the divisor (denominator, must be non-zero)
      Returns:
      dividend ÷ divisor
      Throws:
      NullPointerException - if either argument is null
      ArithmeticException - if divisor is zero
      See Also:
    • hasUnity

      default boolean hasUnity()
      Fields always have unity (multiplicative identity).
      Specified by:
      hasUnity in interface Ring<E>
      Returns:
      always true
      See Also:
    • isMultiplicationCommutative

      default boolean isMultiplicationCommutative()
      Fields always have commutative multiplication.
      Specified by:
      isMultiplicationCommutative in interface Semiring<E>
      Returns:
      always true
    • characteristic

      int characteristic()
      Returns the characteristic of this field.

      The characteristic is the smallest positive integer n such that:
      1 + 1 + ... + 1 (n times) = 0
      If no such n exists, the characteristic is 0.

      Examples:

      • char(ℚ) = char(ℝ) = char(â„‚) = 0
      • char(𝔽ₚ) = p (for prime p)

      Returns:
      the characteristic (0 for infinite fields, p for finite fields)