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.
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 |
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 |
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 |
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.
This operator may be used as a binary operator in an expression like x==y. The user may install binary methodsfor 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.