[Tex/LaTex] pgfplots: three dimensional plot with one variable as exponent

3dpgfplots

In want to draw this function with pgfplots: f(x,y) = 1-(1-(1+y)^(-x))/x*y. When compiling, I get some error message about z buffer reoderings. I already played around a bit and ist seems to me the problem is that one variable (x) is in the exponent. So I broke it down to the simple function (1+y)^(x) and the problem still arises. Is there a way to plot this function type with pgfplots or is it just not possible?

\documentclass{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot3[surf] {(1+y)^(x)};
%\addplot3[surf] {1-(1-(1+y)^(-x))/(x*y)};
\end{axis}
\end{tikzpicture}
\end{document}

Edit: Just to show what it should look like:
enter image description here

Best Answer

This is because of a divide by zero in your original function at x=0,y=0, which yields a nan that throws PGFplots off track. You can remove nans by adding the key restrict z to domain*=-inf:inf:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[restrict z to domain=-inf:inf]
\addplot3[surf] {1-(1-(1+y)^(-x))/(x*y)};
\end{axis}
\end{tikzpicture}
\end{document}