2

How to reproduce the following diagram with TikZ?

Epsilon delta definition

Here is my 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}

By trial and error I found the function $f(x)=sin(x-1.3)+1.72$, which is closer to the function in the image. But I am unable to reproduce the above diagram.

  • 3
    You can try pgfplots instead of drawing the axes manually. There you can also draw the function directly. – Scz Oct 8 '17 at 14:46
  • but seems, that your main problem is math expression (formula) for your function, i.e. it is off-topic here ... – Zarko Oct 8 '17 at 16:23
2

Using your function $f(x)=sin(x-1.3)+1.72$, the following can serve as a starting point:

\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}

Result

  • It does not look like the function from the source, but I took your proposal. You can modify it as you wish.
  • It is not an exact reproduction on purpose; e.g. the arrow tips should not end before the axis lines (it looks weird).
  • 1
    Also note that depending on the meaning behind the various letters and your typographical conventions, they should be upright like in the source or in italic like in this answer. Many people fail to keep this consistent. – lblb Oct 8 '17 at 18:19
  • That figure looks suspicious: is it really the case that if you go the same distance $\epsilon$ above and below the line $y = f(c)$, then drop verticals from those heights to the $x$-axis, the $x$-intercepts would be equidistant from $c$? (Typically for such a function, you would get two different $x$-intercept gaps and then have to take the min of the two as the value of $\delta$.) – murray Oct 8 '17 at 22:19
  • That's right, both distances marked with ε don't have to have the same length. However, for differentiable functions they should approach the same value ε for δ → 0. I have to admit that I didn't care for that when trying to recreate the figure given in the question. – Scz Oct 9 '17 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.