Caution: the following discussion assumes that the package amsmath has been loaded.
In general \mathrm
should be used for "symbols" and \text
for, yes, text. :)
However, it's best to use operators for clusters of Roman letters that represent functions: the commands \lcm
and \gcd
are predefined; for "ord" there's not a predefined command, but it suffices to put in the preamble
\DeclareMathOperator{\ord}{ord}
(the command's name can be what one wants). The input before would become
\frac{\lcm(m,n)}{\gcd(m,n)}
\quad \text{divides} \quad
\frac{\lcm(m,n)}{|\langle x\rangle\cap\langle y\rangle|}
\quad \text{divides} \quad
\ord(ab)
\quad \text{divides} \quad
\lcm(m,n)
In this case \text{divides}
and \mathrm{divides}
might give the same result, but they are conceptually different (and can actually be printed in different ways, depending on the math fonts used). Spaces in the argument of \mathrm
are ignored, for example. Moreover, \text
honors the font of the surrounding environment: it will print in italics in the statement of a theorem.
Particular attention should be paid to units such as "m/s"; it's best not to do them "by hand", but employ a package like siunitx that takes care of all the subtleties, while being very flexible.