In the following MWE, the tikz picture is outside of the paper. When I replace 10 by a bigger number, the pictures goes even further to the right. Any idea ?
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfmathdeclarefunction{myfunction}{1}{
\let\x\pgfmathresult
\pgfmathsetmacro\ret{0}
\foreach \i in {1,...,10}{
\pgfmathsetmacro\ret{\ret + \x^\i}
\xdef\ret{\ret}
}
\pgfmathparse{\ret}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle, domain=-1:1]
\addplot[domain=-1:1, blue, samples=10] {myfunction(x)};
\end{axis}
\end{tikzpicture}
\end{document}