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:



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

\pgfmathparse{\frho(0.15)}$\rho(0.15) = \pgfmathresult$\\
                scale only axis,
                x dir=reverse,
    \addplot[domain=0.001:1,samples=50,smooth] {\frho(x)};

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    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

Browse other questions tagged or ask your own question.