![在 tikz 中定义一个函数](https://linux22.com/image/309082/%E5%9C%A8%20tikz%20%E4%B8%AD%E5%AE%9A%E4%B9%89%E4%B8%80%E4%B8%AA%E5%87%BD%E6%95%B0.png)
在这个MWE中,Q函数有两个定义:
% arara: lualatex: {synctex: yes, shell: yes}
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\def\qfuncta(#1){0.5*erfc(#1/sqrt(2))}
\def\qfunctb(#1)(#2){0.5*erfc(#1/sqrt(2))}
\begin{document}
\begin{tikzpicture}
\begin{semilogyaxis}[
log plot exponent style/.style={/pgf/number format/precision=1},
samples=1000,
width=10cm, height=8cm,enlargelimits=false,
grid, yminorgrids,
xmin=0, xmax=15, xlabel={$x$ (dB)}, xtick={0,2,...,14}, xticklabels={$0$,$2$,$4$,$6$,$8$,$10$,$12$,$14$},
ymax=1, ymin=0.000000001, ylabel={$Q\left({\sqrt{x}}\right)$}]
\addplot [line width=1pt, color=blue, domain=0:15] gnuplot{\qfuncta(sqrt(10^(0.1*x)))} ;
\end{semilogyaxis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{semilogyaxis}[
log plot exponent style/.style={/pgf/number format/precision=1},
samples=1000,
width=10cm, height=8cm,enlargelimits=false,
grid, yminorgrids,
xmin=0, xmax=15, xlabel={$x$ (dB)}, xtick={0,2,...,14}, xticklabels={$0$,$2$,$4$,$6$,$8$,$10$,$12$,$14$},
ymax=1, ymin=0.000000001, ylabel={$Q\left({\sqrt{x}}\right)$}]
\addplot [line width=1pt, color=blue, domain=0:15] gnuplot{\qfunctb(sqrt(10^(0.1*x)))()} ;
\end{semilogyaxis}
\end{tikzpicture}
\end{document}
第二个是正确的,但我不明白为什么。有什么帮助吗?