[Tex/LaTex] equation exceeds the page border

equations

I have the following equation which goes behind the page border:

\begin{equation}
P(word|name_i)= \frac{1}{\sqrt{2\pi\sigma_i^{2}}} \times exp^{\frac{-(tf(name_i,word)*idf(name_i,word)-\mu_i)^{2}}{2\sigma_i^{2}}}
\end{equation}

is there anyway to prevent this to happen?

EDIT

here is the MWE. please note that for the document class, you should download the template from here.

\documentclass{sig-alternate}
\begin{document}

\begin{equation}
P(word|name_i)= \frac{1}{\sqrt{2\pi\sigma_i^{2}}} \times exp^{\frac{-(tf(name_i,word)*idf(name_i,word)-\mu_i)^{2}}{2\sigma_i^{2}}}
\end{equation

\end{document}

Best Answer

I'd use multline environment from amsmath for this.

\documentclass{sig-alternate}
\usepackage{amsmath}
\begin{document}

\begin{multline}
\label{eq:likelihood}
P(Keyword\mid Seg_i)= \frac{1}{\sqrt{2\pi\sigma_i^{2}}}\\
 \times\exp^{\frac{-(tf(Seg_i,Keyword)*idf(Seg_i,Keyword)-\mu_i)^{2}}{2\sigma_i^{2}}}
\end{multline}

\end{document}

Output

enter image description here

I don't know what tf and idf are, but if they are meant to be operators, it is better to define

\DeclareMathOperator{\idf}{idf}
\DeclareMathOperator{\tf}{tf}

Also, probably, many words have to be typeset as text.

MWE

\documentclass{sig-alternate}
\usepackage{amsmath}

\DeclareMathOperator{\idf}{idf}
\DeclareMathOperator{\tf}{tf}

\begin{document}

\begin{multline}
\label{eq:likelihood}
P(\text{Keyword}\mid\text{Seg}_i)= \frac{1}{\sqrt{2\pi\sigma_i^{2}}}\\
 \times\exp^{\frac{-(\tf(\text{Seg}_i,\text{Keyword})*\idf(\text{Seg}_i,\text{Keyword})-\mu_i)^{2}}{2\sigma_i^{2}}}
\end{multline}

\end{document} 

Output

enter image description here

If you want to fit it in one line, use \resizebox from graphicx

MWE

\documentclass{sig-alternate}
\usepackage{amsmath,graphicx}

\DeclareMathOperator{\idf}{idf}
\DeclareMathOperator{\tf}{tf}

\begin{document}

\begin{equation}
\label{eq:likelihood}
\resizebox{\columnwidth}{!}{$\displaystyle
P(\text{Keyword}\mid\text{Seg}_i)= \frac{1}{\sqrt{2\pi\sigma_i^{2}}}
 \times\exp^{\frac{-(\tf(\text{Seg}_i,\text{Keyword})*\idf(\text{Seg}_i,\text{Keyword})-\mu_i)^{2}}{2\sigma_i^{2}}}
$}
\end{equation}

\end{document} 

Output

enter image description here

BTW: You should use e^{...} or \exp(....) instead of \exp^(....), as Mico suggests in his comment.