我想画两条像第二张图那样的红虚线。
\documentclass{minimal}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\draw[->] (-0.2,0) -- (4.5,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,2.5) node[above] {$f(x)$};
\draw[dash pattern=on 0pt off 2\pgflinewidth,line cap=round,line width=0.5mm,color=blue,domain=0:4,samples=100] plot (\x,{1+ sin(10*\x r)*e^(-\x)}) ;
\end{tikzpicture}
\end{document}
答案1
您想要的行是您的初始函数的“周围的行”(我不知道名称)。
该sin(x)
函数总是在 -1 和 1 之间......所以,数学表明:
1+ sin(10*\x r)*e^(-\x)
总是在之间
1+ (+1)*e^(-\x)
和
1+ (-1)*e^(-\x)
\documentclass{minimal}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\draw[->] (-0.2,0) -- (4.5,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,2.5) node[above] {$f(x)$};
\draw[dash pattern=on 0pt off 2\pgflinewidth,line cap=round,line width=0.5mm,color=blue,domain=0:4,samples=100] plot (\x,{1+ sin(10*\x r)*e^(-\x)}) ;
\draw[dash pattern=on 0pt off 2\pgflinewidth,line cap=round,line width=0.5mm,color=red,dashed,thin,domain=0:4,samples=100] plot (\x,{1+e^(-\x)}) ;
\draw[dash pattern=on 0pt off 2\pgflinewidth,line cap=round,line width=0.5mm,color=red,dashed,thin,domain=0:4,samples=100] plot (\x,{1-e^(-\x)}) ;
\end{tikzpicture}
\end{document}