modular arithmetic - Can modulus be negative? - Mathematics Stack Exchange
c - Modulo operation with negative numbers - Stack Overflow
Trying to understand modulus with negative numbers. Can't seem to grasp negative numbers. Can someone help?
The Modulus of a Complex Number is a) Always Positiveb) Always Negativec) Maybe Positive or Negatived) $0$
Videos
That is perfectly okay because they are in the same equivalency class. So, it isn't really that they have a different sign, it is just a different representative for that equivalency class (in the rationals, it is similar to ; same number, just different representatives for that equivalency class).
To answer the question in your title, the modulus (in your example, it is five) must always be at least for anything (interesting) to make sense. However, it is perfectly fine to write both
and
as
.
As a general statement, we write to mean that
. Since
and
, both statements are correct. However, the division algorithm implies that given integers
and
with
, then there exist unique integers
and
such that
and
. Since
, most mathematicians usually write
where
as this is the natural choice for a member of the congruence class.
C99 requires that when a/b is representable:
(a/b) * b + a%b shall equal a
This makes sense, logically. Right?
Let's see what this leads to:
Example A. 5/(-3) is -1
=> (-1) * (-3) + 5%(-3) = 5
This can only happen if 5%(-3) is 2.
Example B. (-5)/3 is -1
=> (-1) * 3 + (-5)%3 = -5
This can only happen if (-5)%3 is -2
The % operator in C is not the modulo operator but the remainder operator.
Modulo and remainder operators differ with respect to negative values.
With a remainder operator, the sign of the result is the same as the sign of the dividend (numerator) while with a modulo operator the sign of the result is the same as the divisor (denominator).
C defines the % operation for a % b as:
a == (a / b * b) + a % b
with / the integer division with truncation towards 0. That's the truncation that is done towards 0 (and not towards negative inifinity) that defines the % as a remainder operator rather than a modulo operator.
In the below examples, the modulus with the positive integers makes sense. I've almost been programmed my whole life with division and remainders. However, the negative numbers don't make sense. I've looked at difference formulas, but I can't seem to make them work in my head or on paper. (Using the Window calculator for results)
-4 mod 3 = 2 but 4 mod 3 = 1 -5 mod 3 = 1 but 5 mod 3 = 2
If the bulk modulus were negative, the system would be in an unstable configuration. (Thermodynamically, this means that it is not a minimum of the free energy. However, the instability is really just purely mechanical; no references to $S$ and $T$ are requried.) Consider a system (for simplicity and definiteness, make it a fluid) with negative bulk modulus $B$ at a given pressure $P$ and volume $V$. What happens if we compress (by applying an external force) the system, so that $V\rightarrow V+\Delta V$, with $\Delta V<0$?
If $B$ is negative, then the pressure drops by a positive amount, $|\Delta P|$, where the actual $\Delta P<0$. In a realistic system, the pressure would increase as the system is compressed, so that it would eventually come back to equilibrium, when the increased pressure balances the applied external force. However, here the volume decreases and the pressure drops, which means that as the system shrinks, it becomes less and less able to resist the external force, meaning that it will continue to shrink even more! The reverse happens if we start out by allowing the system to expand a little and increase its pressure, which would cause it to expand even further. Either way, a miniscule change in volume leads to a runaway effect, with volume either increasing or decreasing until the equation of state changes enough to make $B$ positive again.
It is possible, in principle, to have a nonequilibrium system with a negative $B$, but the configuration is unstable. For example, direct application of the van der Waals equation of state, $$\left(P+\frac{an^{2}}{V^{2}}\right)(V-nb)=nRT,$$ predicts than when $T$ is small enough (less than the critical point temperature $T_{c}$) there a region where the bulk modulus is negative (as shown in this image from Wikipedia).

If a fluid is quickly supercooled into the region with negative $B$, the anomalous behavior can be directly observed, but only briefly. What happens after a very short period of time is that the instabilities take over. Some regions of the fluid (where the local pressure happened to be lower) rapidly expand and other regions (where the pressure was randomly a little higher) rapidly contract. These become regions of gas and liquid, respectively! The instability is resolved by a phase separation; a system with negative $B$ has greater free energy than the same system split into separate liquid and gas components.
As requested, a simpler version of the excellent answer by Buzz: If you pulled on this hypothetical material, it would shrink. We just don’t see that behavior in passive materials.
Alternatively, if you squeezed it in a vise, it would expand, which would pressurize it even more, which would cause further expansion. This is called an explosion and again is not seen in passive materials.
And a nonsimple, math-intensive supplement: The ultimate reason for positive bulk moduli in passive materials arises from the Second Law; materials at equilibrium tend to minimize, not maximize, their stored strain energy.
In the complex numbers, no. $|z|$ is defined to be $\sqrt{z*\overline z}$ which is non negative as $z\overline z = \Re(z)^2 + \Im(z)^2$ is always non-negative real.
I suspect you are asking as we extended the reals to the complex (depending upon your philsophy) by allowing square roots of negatives which as a consequence allowed for logarithms of negative numbers, you are asking if we can create another number system that will allow $|z| < 0$.
It's hard for me to imagine how or why we would do so. There are no numbers that "want to exist but can't" because if they existed there modulus would have to be negative. And as modulus was defined to be non-neg real, it's hard to imagine in what sense we'd define another meaning for it that satisfy any condition associated with it. Primarily the condition that the modulus represents the quantitative measure of the absolute non-negative size of something.
=====
Okay, more.
In the reals $|x|$ is defined as $|x| = x$ if $x \ge 0$ and $|x| = -x$ if $x < 0$.
In extending to the complex numbers we could have kept that definition as close as possible by saying $|a+ib| = a+ib$ if $a \ge 0$ and $|a+ib| = -a-ib$ if $a < 0$. Admittedly we wouldn't ever have $|z| < 0$ but we would have $|z| \not \ge 0$. We could define, god knows why we'd want to but we could, $|a+ib| = a+b$ and the we could have $|z| < 0$.
So we don't we? Why instead to we replace the simple $|x| = \pm x$ with the scary looking $|a+bi| = \sqrt{(a+bi)(a-bi)} = \sqrt{a^2 + b^2}$?
Well, BECAUSE $|a+bi|= \sqrt{a^2 + b^2}$ IS greater than or equal to $0$. That $|z| \ge 0$ is a requirement of the definition of anything that we wish to call a "modulus".
Y2H in his/her answer lists some of the requirements for what something we call a "modulus" must obey. Why must we obey it to call it a modulus? Because if we didn't there wouldn't be any meaning to the word "modulus".
(Why is an elephant large, gray and wrinkly? Because if it were small, white and smooth it would be an aspirin.)
The very first requirement is ... that the "modulus" is real, and non-negative.
The modulus is essentially the "size" of a number. And size is positive value (or zero if and only if the number is zero). That's just.... axiomatic.
There are other conditions. By definition:
In an algebra, If $a,b \in F$, a field, $|a|$ is called the modulus, we must have:
i)$|a| \in \mathbb R; |a| \ge 0$.
ii) $|a| = 0$ if and only if $a$ is the multiplicative identity of $F$.
iii) $|ab| = |a||b|$
iv) $|a+b| \le |a| + |b|$
In vector spaces, $|x|$ is a norm and we must have (by definition) where $V,W$ are vectors in a vector space and $a$ is an element of a field:
i) $|V| \ge 0; |V| \in \mathbb R$
ii) $|V| = 0 \iff V = 0$
iii) $|aV| = |a||V|$ where $|a|$ is a modulus of $a$.
iv) $|V + W| \le |V| + |W|$.
The modulus, by definition, is a positive number as it represents a concept similar to the "magnitude" in Physics. So the fact that the value of a modulus is always positive does not depend on the complex number you are considering at all but is in fact an attribute of the modulus itself.
In $\mathbb C$, given a complex number $x = a + ib$ (with $a$, $b ∈ \mathbb R$) the modulus is defined as
$$\sqrt{x² + y²} $$
Since $y$ itself real, the number under the square root is always positive, hence the modulus is always real and positive.
From a more general and abstract point of view, the modulus is a special case of the norm in $\mathbb C$. By definition, for any vector space, the norm satisfies the below conditions:
- Must be real and positive
- Separation
- Absolute homogeneity
- Subadditivity
One use of it is to define the distance between numbers. For example, in Calculus, you may want to say "the distance between $x$ and $y$ is less than $1$". The way to write that mathematically is $|x-y|<1$. And you want to write it mathematically so you can work with it mathematically.
The notation $\vert x\vert$ for absolute value of $x$ was introduced by Weierstrass in 1841:
K. Weierstrass, Mathematische Werke, Vol. I (Berlin, 1894), p. 67.
Quoted from [1]
...There has been a real need in analysis for a convenient symbolism for "absolute value" of a given number, or "absolute number," and the two vertical bars introduced in 1841 by Weierstrass, as in $\vert z\vert$, have met with wide adoption;...
Extra information: Absolute is from the Latin absoluere, "to free from"; hence suggesting, to free from its sign.
[1] Florian Cajori, A History of Mathematical Notations (Two volumes bound as one), Dover Publications, 1993.
My take on a usage example of absolute value: $$ \min(x,y)=\frac{1}{2}(|x+y|-|x-y|) $$ $$ \max(x,y)=\frac{1}{2}(|x+y|+|x-y|) $$
As I understand it, the modulus of a positive number x with a number n is - the remainder of x divided by n.
But how is the modulus of a negative number calculated?
Example - -3 mod 12 = 1, -1 % 19 = 18.
I spent more than an hour going through the answers to this question on Math.StackExchange, but nothing made sense to me.