# custom function in pgf doesn't behave consistently [duplicate]

Possible Duplicate:
Is plotting exponential graphs a known source of bugs in TikZ?

I want to use a custom function in pgf plots and in text, like in this example:

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\def\frho(#1){pow(#1,(1/\fKappa))}%

% \pgfmathdeclarefunction{rho}{1}{%
%   \pgfmathparse{pow(#1,(1/\fKappa))}%
% }

\begin{document}
\pgfmathsetmacro{\fKappa}{1.4}
\pgfmathparse{\frho(0.15)}$\rho(0.15) = \pgfmathresult$\\
\begin{tikzpicture}
\begin{axis}[name=upper,
xmin=0,xmax=1,width=10cm,
ymin=0,ymax=1,height=10cm,
scale only axis,
x dir=reverse,
xlabel={$p$},
ylabel={$\rho$}
]
\end{axis}
\end{tikzpicture}
\end{document}


The outcoming plot is correct, but the text result is not: the pdf says rho(0.15) = 3.84593. This happens with the \def variant as well as with the \pgfmathdeclarefunction variant. I don't think this might be caused by the limitations of pow, because one result is correct.

How can I fix this?

## marked as duplicate by Jake, Joseph Wright♦Feb 2 '12 at 12:57

• There's a bug in the exp function of pgfmath, which is used internally by the pow function. It's been fixed in the CVS version of pgf. If you don't want to update to the CVS version, you can just copy the relevant bit of code into your document: tex.stackexchange.com/a/31791/2552. The function works in pgfplots because it uses the fpu engine, which reimplements the exp function correctly. – Jake Feb 2 '12 at 12:08