\documentclass{article}
\usepackage{pgfplots}
\pagestyle{empty}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    grid=major,
    domain=-2.5:2.5,
    legend style={%
        at={(0.5,0.5)},
        thick,
        draw=none,
        legend entries={$x^3-x$,$3x^2-1$},
        anchor=south
    },
  ]
  \addplot[red, thick, samples=101]{x^3-x};
  \addplot[blue, thick, dashed, samples=101]{3*x^2-1};
\end{axis}
\end{tikzpicture}
\end{document}
