On a case-by-case basis, it is possible to typeset text within math mode using \textrm{...}
or \mathrm{...}
, the latter being used predominantly for typesetting units or symbols and not pure text (since it gobbles spaces that are not escaped). \mbox{...}
is another alternative to \textrm{...}
, since it resets its contents to text mode by default. Here are some examples:

\documentclass{article}
\begin{document}
Here is a formula: $x=\exp(\log \mathrm{x})$
Here is another: $\sin^2 t+\cos^2 t = \textrm{famous identity}$
\end{document}
The above font changes do not work that well in general, since switching to a different font when using sub- and superscripts, say, does not always scale as expected. There are ways around it though. For example, using \text{...}
from the amstext
package (automatically loaded by amsmath
- see the AMS package dependencies), which switches to the appropriate font size via \mathchoice
:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
% amsmath loads the amstext package by default
\begin{document}
Here is a formula: $x=y^{abc}$
Here it is again: $x=y^{\mbox{abc}}$
Compare that to: $x=y^{\text{abc}}$
\end{document}