如何用 TikZ 重现这个 epsilon delta 定义图?

如何用 TikZ 重现这个 epsilon delta 定义图?

如何用 TikZ 重现下图?

Epsilon delta 定义

这是我的 MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{amssymb,txfonts,pxfonts}
\begin{document}
\begin{tikzpicture}[domain=0:2] 
\draw[->] (-1,0) --(4,0) node[below right] {$x$}; 
\draw[->] (0,-1) --(0,4) node[left] {$y$}; 
\draw[color=red] plot (\x,\x) node[right] {$f(x)=x$ }; 
\end{tikzpicture}
\end{document}

通过反复试验,我找到了函数 $f(x)=sin(x-1.3)+1.72$,它更接近图中的函数。但我无法重现上图。

答案1

使用您的功能$f(x)=sin(x-1.3)+1.72$,以下内容可以作为起点:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfmathdeclarefunction{myfunct}{1}{\pgfmathparse{sin(deg(#1)-1.3)+1.72}}
\begin{document}
    \begin{tikzpicture}[
            >=stealth, %% arrow tips
        ]
        \begin{axis}[
                blue,
                axis x line=middle,
                axis y line=center,
                every axis x label/.style={at={(current axis.right of origin)},anchor=north},
                every axis y label/.style={at={(current axis.above origin)},anchor=east},
                xmin=-0.5,xmax=1.5,
                ymin=-0.5,ymax=3,
                xtick=\empty,
                ytick=\empty,
                xlabel={$x$},
                ylabel={$y$},
            ]

            %% draw the plot:
            \addplot [red,samples=100] {myfunct(x)};

            %% define some coordinates that we need later:
            \def\xa{0.25}
            \pgfmathsetmacro{\ya}{myfunct(\xa)}
            \path (axis cs:\xa, \ya) coordinate (0);

            \def\xb{0.5}
            \pgfmathsetmacro{\yb}{myfunct(\xb)}
            \path (axis cs:\xb, \yb) coordinate (1);

            \def\xc{0.75}
            \pgfmathsetmacro{\yc}{myfunct(\xc)}
            \path (axis cs:\xc, \yc) coordinate (2);

            \path (axis cs:0, 0) coordinate (origin);
        \end{axis}

        %% draw the black lines:
        \tikzset{marker/.style={shorten <=-3pt,shorten >=-3pt}} %% expand the lines
        \draw [marker] (origin-|0) -- (0);
        \draw [marker] (origin|-0) -- (0);
        \draw [marker] (origin-|1) -- (1);
        \draw [marker] (origin|-1) -- (1);
        \draw [marker] (origin-|2) -- (2);
        \draw [marker] (origin|-2) -- (2);

        %% δ, ε:
        \path (origin) ++(10pt,10pt) coordinate (offset);

        \draw [<->,red!50!blue] (offset-|0) -- node [above] {$\delta$} (offset-|1);
        \draw [<->,red!50!blue] (offset-|1) -- node [above] {$\delta$} (offset-|2);
        \node at (origin-|1) [below,yshift=-3pt,red!50!blue] {$c$};

        \draw [<->,black!50!blue] (offset|-0) -- node [right] {$\varepsilon$} (offset|-1);
        \draw [<->,black!50!blue] (offset|-1) -- node [right] {$\varepsilon$} (offset|-2);
        \node at (origin|-1) [left,xshift=-3pt,black!50!blue] {$L$};
    \end{tikzpicture}
\end{document}

结果

  • 它看起来不像源代码中的函数,但我采纳了你的建议。你可以根据需要进行修改。
  • 这不是故意的精确复制;例如,箭头不应该结束轴线(看起来很奇怪)。

相关内容