# == -- equality

• Usage:
x == y

## Description

Returns true or false, depending on whether the objects x and y are (mathematically) equal. The objects x and y are typically numbers, elements of rings, matrices, modules, ideals, chain complexes, and so on.

A test for mathematical equality will typically involve doing a computation to see whether two representations of the same mathematical object are being compared. For example, an ideal in a ring is represented by giving its generators, and checking whether two sets of generators produce the same ideal involves a computation with Gröbner bases. The ideals must be defined in the same ring.

### Ideals

 i1 : R = QQ[a,b,c]; i2 : ideal(a^2-b,a^3) == ideal(b^2, a*b, a^2-b) o2 = true

Often mathematical objects can be tested to see if they are 0 or 1.

 i3 : L = ideal(a^2-a-1,a^3+a+3) 2 3 o3 = ideal (a - a - 1, a + a + 3) o3 : Ideal of R i4 : L == 1 o4 = true i5 : L == 0 o5 = false

### Matrices

Two matrices are equal if their entries are equal, the source and target are the same (including degrees), and the degree of the matrices are the same. In this example, m and n have different source free modules.

 i6 : m = matrix{{a,b},{c,a}} o6 = | a b | | c a | 2 2 o6 : Matrix R <--- R i7 : n = map(R^2,R^2,m) o7 = | a b | | c a | 2 2 o7 : Matrix R <--- R i8 : m == n o8 = false i9 : source m == source n o9 = false

If you only want to know if they have the same entries, test the difference against zero.

 i10 : m-n == 0 o10 = true

### Modules

Two modules are equal if they are isomorphic as subquotients of the same ambient free module.

 i11 : image matrix {{2,a},{1,5}} == R^2 o11 = false i12 : image matrix {{2,a},{0,5}} == R^2 o12 = true

### Intervals

If either side of the equality is an RRi, the equality is an equality of sets.

 i13 : interval(1,3) == interval(1,3) o13 = true i14 : interval(1/2) == 1/2 o14 = true i15 : interval(1/3) == 1/3 o15 = false

It may happen that for certain types of objects, there is no method installed (yet) for testing mathematical equality, in which case an error message will be printed. A good alternative may be to test for strict equality with the operator ===.

Since various sorts of mathematical objects are implemented as types, i.e., as instances of Type, there is no generic method for checking equality of types, so that new mathematical comparison code can be provided in the future without breaking code that works.

## Caveat

Warning: whether this comparison operator returns true is not necessarily related to whether the comparison operator ? returns symbol ==.

## Ways to use symbol == :

• "BettiTally == BettiTally"
• "Boolean == Boolean"
• "CC == CC"
• "CC == QQ"
• "CC == RR"
• "CC == ZZ"
• "ChainComplex == ChainComplex"
• "ChainComplex == ZZ"
• "ChainComplexMap == ChainComplexMap"
• "ChainComplexMap == RingElement"
• "ChainComplexMap == ZZ"
• "Equation == Equation"
• "Equation == Expression"
• "Equation == Holder"
• "Expression == Equation"
• "Holder == Equation"
• "Ideal == Ideal"
• "Ideal == Module"
• "Ideal == MonomialIdeal"
• "Ideal == Ring"
• "Ideal == ZZ"
• "InfiniteNumber == InfiniteNumber"
• "InfiniteNumber == Number"
• "Matrix == Matrix"
• "Matrix == Number"
• "Matrix == RingElement"
• "Matrix == ZZ"
• "Module == Ideal"
• "Module == Module"
• "Module == ZZ"
• "MonoidElement == MonoidElement"
• "MonomialIdeal == Ideal"
• "MonomialIdeal == MonomialIdeal"
• "MonomialIdeal == Ring"
• "MonomialIdeal == ZZ"
• "MutableMatrix == MutableMatrix"
• "MutableMatrix == ZZ"
• "Net == Net"
• "Net == String"
• "Nothing == Nothing"
• "Number == InfiniteNumber"
• "Number == Matrix"
• "Number == RingElement"
• "ProjectiveHilbertPolynomial == ProjectiveHilbertPolynomial"
• "QQ == CC"
• "QQ == QQ"
• "QQ == RR"
• "QQ == RRi"
• "QQ == ZZ"
• "Ring == Ideal"
• "Ring == MonomialIdeal"
• "Ring == ZZ"
• "RingElement == ChainComplexMap"
• "RingElement == Matrix"
• "RingElement == Number"
• "RingElement == RingElement"
• "RingElement == ZZ"
• "RingMap == ZZ"
• "RR == CC"
• "RR == QQ"
• "RR == RR"
• "RR == RRi"
• "RR == ZZ"
• "RRi == QQ"
• "RRi == RR"
• "RRi == RRi"
• "RRi == ZZ"
• "Sequence == Sequence"
• "String == Net"
• "String == String"
• "Symbol == Symbol"
• "Vector == Vector"
• "VisibleList == VisibleList"
• "ZZ == CC"
• "ZZ == ChainComplex"
• "ZZ == ChainComplexMap"
• "ZZ == Ideal"
• "ZZ == Module"
• "ZZ == MonomialIdeal"
• "ZZ == MutableMatrix"
• "ZZ == QQ"
• "ZZ == Ring"
• "ZZ == RingElement"
• "ZZ == RingMap"
• "ZZ == RR"
• "ZZ == RRi"
• "ZZ == ZZ"
• "Constant == Constant" -- see Constant
• "Constant == InexactNumber" -- see Constant
• "InexactNumber == Constant" -- see Constant
• "Expression == Expression" -- see Expression -- the class of all expressions
• "Expression == Holder" -- see Expression -- the class of all expressions
• "Expression == Thing" -- see Expression -- the class of all expressions
• "Holder == Expression" -- see Expression -- the class of all expressions
• "Holder == Holder" -- see Expression -- the class of all expressions
• "Thing == Expression" -- see Expression -- the class of all expressions
• InexactNumber == RingElement (missing documentation)
• InfiniteNumber == RR (missing documentation)
• RingElement == InexactNumber (missing documentation)
• RR == InfiniteNumber (missing documentation)
• Tally == ZZ (missing documentation)
• VirtualTally == ZZ (missing documentation)
• ZZ == Tally (missing documentation)
• ZZ == VirtualTally (missing documentation)

## For the programmer

The object == is .

This operator may be used as a binary operator in an expression like x==y. The user may install binary methods for handling such expressions with code such as

         X == Y := (x,y) -> ...

where X is the class of x and Y is the class of y.