irem (or remain) returns the integer remainder r from
the Euclidean division of two integers a and b given as arguments
(a=b*q+r with 0≤ r< b).
For Gaussian integers, we choose q so that b*q is as near to a as possible and it can be proved that r may be chosen so that |r|2 ≤ |b|2/2.
irem works with long integers or with Gaussian integers.
Here a−b*q=−4+i and |−4+i|2=17<|5+7*i|2/2=74/2=37
smod or mods is a prefixed
function and has two integers a and b as arguments.
smod or mods returns the symmetric remainder s of the Euclidean division of the arguments a and b (a=b*q+s with −b/2<s ≤ b/2).
mod (or %) is an infixed function
and has two integers a and b
mod (or %) returns r% b of Z/bZ where r is the remainder of the Euclidean division of the arguments a and b.
Note that the answer 3 % 5 is not an integer (3) but an element of Z/5Z (see 5.32 to have the possible operations in Z/5Z).