3

I'm wondering how I should deal with units when I do a modulo operation. What is considered legal and what is not.

When I have two numbers that have units such as 13cm and 3cm, I can multiply them:

$$13cm \times 3cm = 39cm^2 $$

Similarly, I can do divisions:

$${39cm^2 \over 3cm} = 13cm$$

Now, I'm wondering what can I do with modulo. It seems to me that only distance less numbers can be used on the right side of the operation and the result keeps the same unit as the left side.

$$39cm \bmod 5 = 4cm$$

Is that correct? Where could I find information about dealing with units and all operators (relations, additions, multiplication, divisions, modulo, power, etc.)

2 Answers2

7

When I write $$39\mod{5}=4$$ what I am saying is that there is some integer $k$ such that $$39=5k+4$$

Hence the only way I can make sense of units associated to the mod function is if all of $39, 5, 4$ have the same units (while $k$ is dimensionless). Hence I would write $$39cm \mod{5 cm}=4cm$$

vadim123
  • 82,796
  • Great, that will help me in resolving the same problem for other operations too! – Alexis Wilke Jul 08 '15 at 01:06
  • This is a great, succinct answer. One way that helped me think about it was imagining the impact of using a completely different unit (rather than dimensionless) in modulo operations. Imagine trying to compute 39cm mod 5sec. It's nonsensical. 39cm mod 5 (dimensionless) follows the same logic. – Brendan Nov 30 '19 at 20:11
  • 1
    In the term $5k$, couldn't we instead leave the $5$ dimensionless while making $k$ take on a unit? That is, $39cm \mod 5 = 4cm$. A possible interpretation might be "After dividing 39cm of string into 5 equal pieces, there is 4cm remaining" (though a discrete unit like "jelly beans" is probably better in this example). – davidg Feb 09 '21 at 00:01
1

Typically, two values with the same dimension (length, time, current squared over kilogram, etc) can be added or subtracted, and two values of any dimension can be multiplied or divided. Other operations generally don't behave so nicely, but there is a workaround.

Let $x$ be the length of whatever in centimetres. Then if the object has length L, $x = L/1\ cm$. $x$ is a dimensionless value, which means you can work with it in modulus equations (and other functions that don't like units, like $e^x$ and $\cos(x)$). It also has the neat property that it doesn't actually matter what units $L$ is expressed in - if $L = 1\ inch$, then $x = 1\ inch/1\ cm = 2.54\ cm/1\ cm = 2.54$.

ConMan
  • 24,300
  • Shouldn't $x$ in $cos(x)$ be an angle though? – Alexis Wilke Jul 08 '15 at 02:25
  • 1
    Not necessarily. Cosine is defined on the whole complex plane, so although its original definition is in terms of angles it's actually closely related to the exponential function and harmonic motion. – ConMan Jul 08 '15 at 04:22