The following uses xfp for the actual calculation, and \pgfmathsetmacro with the options /pgf/fpu=true and /pgf/fpu/output format=sci applied locally to ensure the input number format is understandable for xfp (as pgfmath uses a custom internal number representation when the FPU is used, which isn't understood by xfp).
The \romannumeral is used to ensure that \fpeval is fully done when the group is closed and therefore \argA, \argB, and \argC don't have the correct meaning anymore. The result is then again parsed by \pgfmathparse to make sure that \pgfmathresult holds the correct format for pgf outside of the function.
\documentclass{article} \usepackage{pgfplots} \usepackage[]{xfp} \begin{document} \pgfmathdeclarefunction{lognormal}{3}{% \begingroup \pgfkeys{/pgf/fpu=true, /pgf/fpu/output format=sci}% \pgfmathsetmacro\argA{#1}% \pgfmathsetmacro\argB{#2}% \pgfmathsetmacro\argC{#3}% \expandafter \endgroup \expandafter\pgfmathparse\expandafter {% \romannumeral`\^^@% \fpeval{exp(-((ln(\argA)-\argB)^2)/(2*\argC^2))/(\argA*\argC*sqrt(2*pi))}% }% } \begin{tikzpicture} \begin{axis}[ domain=0.01:10, samples=100 ] \addplot {lognormal(x,ln(5),0.02)}; \end{axis} \end{tikzpicture} \end{document}
Is it fast? No. Does it work? Yes:
