In the Wikipedia article describing the Modulo operation, Raymond T. Boute introduces the Euclidean Definition, where the remainder is always positive and therefore consistent with Euclidean Division.
a (the Dividend) modulo n (the Divisor) where q is the quotient and r is the remainder.
$ q \in \mathbb{Z} $
$ a = n \times q + r\,$
$0 \leq r < |n|$
Two corollaries being:
$ n > 0 \Rightarrow q = \left\lfloor \frac{a}{n} \right\rfloor$
$ n < 0 \Rightarrow q = \left\lceil \frac{a}{n} \right\rceil $
equivalently:
$ q = sgn(n) \left\lfloor \frac{a}{\left|n\right|} \right\rfloor. $
When I verified these statements using Python, I got incorrect results using a -Dividend and a +Divisor. Specifically, I had a = -1.0, n = 7.0 and I was expecting a quotient of 0.0 and a positive remainder of 1.0.
In the Wikipedia article on Euclidean Division it states that the remainder is the only term that needs to be positive.
However, if we have a -Dividend, a zero quotient, and a required positive remainder, then:
-a == n x zero + r
becomes incorrect because:
-a == +r
Therefore, in Euclidean Division, we cannot have a -Dividend?
Where am I reasoning incorrectly?
Many thanks, David.
UPDATE_______________________________________________
Your clarifications have helped me a lot, and have moved me to laughter, when realising my own insanity.
I've always believed Mathematics to be a visual art. Probably because of the visual proof of Pythagorus's Theorem et al. When I expect that something should be visualisable, I get confused if I cannot visualise it.
When reading about Euclidean Division, the visual example made perfect sense, only when a >= 0, b > 0, q >= 0, r >= 0
@ @ @ @ @ @ @ @ @ @ @ @ @
13 swirls (a) divided by 4 (b) gives a (q) of 3 and a (r) of 1
a == bq + r => 13 == 4 * 3 + 1, or 13 swirls == 4 quotients of 3 + a remainder of 1
Which is visually and linguistically intuitive.
But when you have:
-7 swirls (a) divided by 3 (b) giving a (q) of -3 and a (r) of 2, because -7 == 3 * -3 + 2; I become visually lost.
How can -3 go into -7, 3 times and leave remainder 2?
The reason for this confusion is because during the Khan Academy addition videos, I visualised Integers > 0 being Violet Circles, Integers == 0 being Green Circles, and Integers < 0 being Red Circles.
In my head 2 - 2 == 2 + -2 == 2 Violet Circles merging with 2 Red Circles == the creation of 1 Green Circle.
Kind of like Particles Annihilating each other to create other Particles.
The comments system loses all formatting, so my related comments are here:
@Caveman, thank you for constructing those beautiful natural number asterisk sets.
Let's be totally clear on this:
13/4 is 3 sets of 4 union 1 set of 1,
or less ambiguously,
A set of 13 natural numbers asterisks divided into 4 equal natural amounts
is 3 sets of 4 union 1 set of 1.
or if we want to think fractionally,
A set of 13 real number asterisks divided into 4 equal fractional amounts
(of desired and sensible accuracy) is 3 sets 4 + 1/4.
In reality, you cannot divide 12 oranges by -4 oranges because -4 oranges is a figment of your Cartesian imagination.
The notion of a negative amount has been patched by mathematicians to make it a credible public concept. Complex Numbers are an extension of this insanity.
There's no such thing a a negative orange or a negative amount of pizza. You can only divide them into smaller amounts up until you reach the limits of known reality; the Planck length.
The notion of a negative amount is an intellectual conspiracy eloquently constructed to obfuscate reality.
Sure, you can subtract a positive amount from a positive amount, but you cannot do this if the result is negative. 2 oranges minus 3 oranges is not defined in Natures reality.
Negative amounts have been constructed by intellectual Magicians.
I still love you (there's no such thing as negative love; only positive hatred)
From the History Of Negative Numbers:
Although the first set of rules for dealing with negative numbers was stated in the 7th century by the Indian mathematician Brahmaputra, it is surprising that in 1758 the British mathematician Francis Maseres was claiming that negative numbers
"... darken the very whole doctrines of the equations and make dark of the things which are in their nature excessively obvious and simple" .
x % y
returns a result with the sign ofy
." (Seemath.fmod
). $\endgroup$ – kahen Mar 22 '13 at 21:24