# PGF Math Error: Could not parse input

Trying to plot a BER vs SNR function using erf function. However I get an error saying " Package PGF Math Error: Could not parse input '' as a floating point number, sorry. The unreadable part was near ''. (in '0.5-0.5*erf(sqrt(10**(x/10)))') "

\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{
label style={anchor=near ticklabel},
xlabel style={yshift=0.8em},
ylabel style={yshift=-2em},
tick label style={font=\bfseries\small },
label style={font=\bfseries\small},
legend style={font=\bfseries\small},
}
\begin{document}
\begin{tikzpicture}[
declare function={erf(\x)=%
(1+(e^(-(\x*\x))*(-265.057+abs(\x)*(-135.065+abs(\x)%
*(-59.646+(-6.84727-0.777889*abs(\x))*abs(\x)))))%
/(3.05259+abs(\x))^5)*(\x>0?1:-1);},
declare function={erf2(\x,\y)=erf(\x)+erf(\y);}
]
\begin{axis}[xdomain:0:30,
width=\textwidth,
enlargelimits=false,
grid=major,
]
\end{axis}
\end{tikzpicture}
\end{document}


There were a few things to change in your code:

• use 10^ not 10**
• use exp(...) not e^(...)
• use domain=... not xdomain=...

Here's a complete MWE - remember to start small, and build on it slowly :) When you get an error, study the messages, comment out pieces of code, and keep tweaking until you fix it.

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
label style={anchor=near ticklabel},
xlabel style={yshift=0.8em},
ylabel style={yshift=-2em},
tick label style={font=\bfseries\small },
label style={font=\bfseries\small},
legend style={font=\bfseries\small},
}
\begin{document}
\begin{tikzpicture}[
/pgf/declare function={erf(\x)=%
(1+(exp(-(\x*\x))*(-265.057+abs(\x)*(-135.065+abs(\x)%
*(-59.646+(-6.84727-0.777889*abs(\x))*abs(\x)))))%
/(3.05259+abs(\x))^5)*(\x>0?1:-1);},
]
\begin{axis}[domain=0:30,
width=\textwidth,
enlargelimits=false,
grid=major,
]

• The description of pgf/declare function in the TikZ/PGF manual (page 949 in version 3.0.0) seems to contradict parts of your answer: The list of arguments is given in parentheses, and variables are used as \x, \y, etc. – mvkorpel Jun 5 '14 at 19:16
• Could you try to compare results with a: your MWE (unmodified) and b: your MWE (with \x in function body and argument list)? At least for me, the first alternative plots an increasing function, while the second alternative plots a decreasing function tending towards zero. I'm pretty sure the second alternative is correct. – mvkorpel Jun 5 '14 at 22:06