0

I have a little trouble understanding how to write a mathematically notation for r = x%n. How should I write this in math notation if I want to get the remainder value, after dividing by $n$? $r$ is also not just an integer in this case, just the rest of $x$ (double) divided by $n$ (integer), "$r = \operatorname{mod}(5.4, 3) = 2.4$" in this case. I think $x \equiv r \mod n$ means something different.

Edit: After thinking a while, I am still confused by the notation. Why is the notation $x \equiv r \mod n$ used at all? If $\operatorname{mod}$ is a mathematical operator like $\sin$ or $\cos$, why is the notation $r = \operatorname{mod}(x,n)$ not used always?

  • That's generally correct, $x\equiv r\mod n$ is usually assumed to be using integers, however it should be noted that the definitions do not limit the operation to only integers. – abiessu Jul 05 '20 at 16:26
  • Consider the proof at https://primes.utm.edu/notes/proofs/LucasLehmer.html for an example. – abiessu Jul 05 '20 at 16:27
  • @abiessu While in this context I think so too, there is no difficulty in making sense of $x\equiv y\mod2\pi$ for $x,y\in\mathbb R$. – mrtaurho Jul 05 '20 at 16:27
  • 1
    Consider $r=x-n\lfloor\frac xn\rfloor$ – J. W. Tanner Jul 05 '20 at 16:28
  • $$x\equiv r\mod n$$ almost always means $\ n\mid x-r\ $ , where $n$ is an integer greater than $\ 1\ $ and $\ x,r\ $ integers. This does not mean that $\ r\ $ is the minimum value in the residue class. – Peter Jul 05 '20 at 16:32
  • More explicitly, you can just write $r\in x+n\mathbf Z$ (although this does not imply that $0\leq r<n$). You can just write $r=x\mod n$. This is not standard when $r,x,n$ are not integers, but if you explain the convention when you use it, I don't think anyone is going to complain. – tomasz Jul 05 '20 at 16:36
  • I am just confused by the notation of $x \equiv r \mod n$, since I want to write it like a general equation, like $r = ...$. Also if the notation is generally applied to intergers, is it ok to use it for real valued variables? – Lemonbonbon Jul 05 '20 at 16:37
  • 1
    @Lemonbonbon: It is, as soon as you explain what you mean by that. – tomasz Jul 05 '20 at 16:42
  • 1
    In particular, I think that this answer is quite nice. It pains me to say this, as I don't want to give Mike credit for doing anything right (before you jump on me, his office was down the hall from me, and I find it amusing to give him a bit of good natured ribbing from time to time), but his answer is spot-on. – Xander Henderson Jul 05 '20 at 22:00

1 Answers1

3

You can just write $``x \bmod n"$.

According to Wikipedia

Given two positive numbers, a and n, a modulo n (abbreviated as a mod n) is the remainder of the Euclidean division of a by n, where a is the dividend and n is the divisor.

Note that it was not required that $a$ or $n$ be integers.