在 Latex pgfplots 中绘制日志中的指数

Plotting Exponentials Inside Logs in Latex pgfplots

我正在尝试向我的文档中添加一些图表。我以前已经成功地做到了;但由于某种原因,这次它不起作用。我尝试删除除一个情节之外的所有内容,但我仍然遇到相同的错误。让我只用一张图来展示文档。

\documentclass[11pt]{amsart}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[domain=0:3,samples=100,yticklabels=\empty]
\addplot+[no markers] {20-500*\ln(0.998*exp(-x)+0.002+0*exp(x))-500*\ln(0.998*exp(x)+0.002+0*exp(-x))};
\end{axis}
\end{tikzpicture}
\end{document}

我收到错误 "Undefined control sequence.\foreach ...reach\let \pgffor@assign@before@code=[lots more]"

当我仅用简单的 exp(x) 替换该函数时,绘图有效。那么这个更复杂的函数有什么问题呢?

谢谢

对于在公式中使用的对数函数是ln而不是\ln

\documentclass[11pt]{amsart}

\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[domain=0:3,samples=100,yticklabels=\empty]
\addplot+[no markers] {20-500*ln(0.998*exp(-x)+0.002+0*exp(x))-500*ln(0.998*exp(x)+0.002+0*exp(-x))};
\end{axis}
\end{tikzpicture}
\end{document}