Don't use strange things in your \labels. In this case, math content. Here's what happens using a relevant example (following along with Understanding how references and labels work):
\documentclass{article}
\begin{document}
\begin{figure}
\caption{$e^x \cos x$}
\label{fig:e^x \cos x}
\end{figure}
\end{document}
After the first compilation, one would think there's something like \newlabel{fig:e^x \cos x}{{<fig>}{<page>}} in the .aux. However, this is not the case:
\newlabel{fig:e^x \mathop {\mathgroup \symoperators cos}\nolimits x}{{1}{1}}
\cos is fully-expanded, causing all sorts of problems. As such, avoid math-related content in your labels as a general rule, since they may be shorthand for bigger hidden things.
In fact, \cos even expands in the \caption (which may be used in \listoffigures) and therefore might be problematic. In this case its not, but it may help using \protect\cos in moving arguments like \caption.
\cosin your\label, but instead justcos. Also, don't use spaces... – Werner Jan 15 '17 at 05:11.auxand retry to compile. – Werner Jan 15 '17 at 05:28