Class Reals
- All Implemented Interfaces:
AbelianGroup<Real>, AbelianMonoid<Real>, Group<Real>, Magma<Real>, Monoid<Real>, Field<Real>, Ring<Real>, Semiring<Real>, InfiniteSet<Real>, Set<Real>
This class represents the structure of real numbers,
not individual elements. It implements Field because â„ forms
a field under addition and multiplication.
Real numbers are an infinite, uncountable set.
Usage
Reals structure = Reals.getInstance();
Real pi = Real.of(3.14159);
Real two = Real.of(2.0);
// Use structure for operations
Real twoPi = structure.multiply(pi, two);
Real halfPi = structure.divide(pi, two);
- Since:
- 1.0
- Author:
- Gemini AI (Google DeepMind)
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the sum of two elements (additive notation).intReturns the characteristic of this field.booleanTests whether this set contains the specified element.Returns a human-readable description of this set.static RealsReturns the singleton instance.Returns the multiplicative inverse of a non-zero element.booleanReturnstrueif this set is countable (i.e., its elements can be put in one-to-one correspondence with the natural numbers).booleanisEmpty()Returnstrueif this set contains no elements.booleanFields always have commutative multiplication.Returns the product of two elements.Returns the additive inverse (negation) of an element.one()Returns the multiplicative identity (one element).Performs the binary operation on two elements.toString()zero()Returns the additive identity (zero element).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbelianGroup
isCommutative, subtractMethods inherited from interface AbelianMonoid
identity, isCommutativeMethods inherited from interface Monoid
isAssociative
-
Field Details
-
INSTANCE
Singleton instance
-
-
Method Details
-
getInstance
-
operate
Description copied from interface:MagmaPerforms the binary operation on two elements.This is the fundamental operation of a magma. The result must be an element of this magma (closure property).
Properties: None required (not necessarily associative or commutative)
-
add
Description copied from interface:AbelianMonoidReturns the sum of two elements (additive notation).Delegates to
Magma.operate(Object, Object).- Specified by:
addin interfaceAbelianMonoid<Real>- Parameters:
a- the first addendb- the second addend- Returns:
- a + b
-
characteristic
public int characteristic()Description copied from interface:FieldReturns 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)
- Specified by:
characteristicin interfaceField<Real>- Returns:
- the characteristic (0 for infinite fields, p for finite fields)
-
zero
Description copied from interface:AbelianMonoidReturns the additive identity (zero element).Delegates to
AbelianMonoid.identity().- Specified by:
zeroin interfaceAbelianMonoid<Real>- Returns:
- the zero element
-
negate
Description copied from interface:AbelianGroupReturns the additive inverse (negation) of an element.Satisfies: a + (-a) = (-a) + a = 0
- Specified by:
negatein interfaceAbelianGroup<Real>- Parameters:
element- the element to negate- Returns:
- -element
- See Also:
-
multiply
Description copied from interface:SemiringReturns the product of two elements.Multiplication must be associative and distribute over addition.
-
one
-
isMultiplicationCommutative
public boolean isMultiplicationCommutative()Description copied from interface:FieldFields always have commutative multiplication.- Specified by:
isMultiplicationCommutativein interfaceField<Real>- Specified by:
isMultiplicationCommutativein interfaceSemiring<Real>- Returns:
- always
true
-
inverse
Description copied from interface:FieldReturns 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
-
isCountable
public boolean isCountable()Description copied from interface:InfiniteSetReturnstrueif this set is countable (i.e., its elements can be put in one-to-one correspondence with the natural numbers).Examples:
- Countable: ℕ (Natural numbers), ℤ (Integers), ℚ (Rational numbers)
- Uncountable: â„ (Real numbers), â„‚ (Complex numbers)
- Specified by:
isCountablein interfaceInfiniteSet<Real>- Returns:
trueif this set is countable
-
contains
Description copied from interface:SetTests whether this set contains the specified element.This is the fundamental operation of a set - membership testing.
-
isEmpty
-
description
Description copied from interface:SetReturns a human-readable description of this set.Examples:
- "â„ (Real Numbers)"
- "ℤ/12ℤ (Integers modulo 12)"
- "{1, 2, 3, 4, 5}"
- Specified by:
descriptionin interfaceSet<Real>- Returns:
- a description of this set
-
toString
-