# pgfplots: three dimensional plot with one variable as exponent?

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}
\end{axis}
\end{tikzpicture}
\end{document}


Edit: Just to show what it should look like:

-
Possibly related to: Is plotting exponential graphs a known source of bugs in TikZ? –  Peter Grill Mar 5 '12 at 18:49

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]
\end{axis}
\end{tikzpicture}
\end{document}

-
Thank you. I am aware of the dividing by zero problem and already tried to set xmin,ymin in the axis options accordingly as I only need positive values. However, this just gave me more error messages. I guess, I'll just plot it another way. –  meep.meep Mar 6 '12 at 9:58
Note that xmin,ymin will still cause the problem: they only restrict the axis range, not the range in which samples will be taken. Consider using samples=min:max and samples y=min:max to reduce the sampled range. –  Christian Feuersänger Mar 6 '12 at 18:33

You could rewrite the function as exp((x)*ln((1+y))):

Your original function can be written as

\addplot3[surf] {1-(1-(exp((-x)*ln(1+y))))/(x*y)};


and yields:

\documentclass{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}