\chapter{Constant functions} \section{Defined on $\mdr$} Let $f(x) = c$ with $c \in \mdr$ be a constant function. \begin{figure}[htp] \centering \begin{tikzpicture} \begin{axis}[ legend pos=north west, axis x line=middle, axis y line=middle, grid = major, width=0.8\linewidth, height=8cm, grid style={dashed, gray!30}, xmin=-5, % start the diagram at this x-coordinate xmax= 5, % end the diagram at this x-coordinate ymin= 0, % start the diagram at this y-coordinate ymax= 3, % end the diagram at this y-coordinate axis background/.style={fill=white}, xlabel=$x$, ylabel=$y$, tick align=outside, minor tick num=-3, enlargelimits=true, tension=0.08] \addplot[domain=-5:5, thick,samples=50, red] {1}; \addplot[domain=-5:5, thick,samples=50, green] {2}; \addplot[domain=-5:5, thick,samples=50, blue, densely dotted] {3}; \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)}; \addplot[blue, mark = *, nodes near coords=$P_{h,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(2, 3)}; \addplot[green, mark = x, nodes near coords=$P_{g,\text{min}}$,every node near coord/.style={anchor=120}] coordinates {(2, 2)}; \addplot[red, mark = *, nodes near coords=$P_{f,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(2, 1)}; \draw[thick, dashed] (axis cs:2,0) -- (axis cs:2,3); \addlegendentry{$f(x)=1$} \addlegendentry{$g(x)=2$} \addlegendentry{$h(x)=3$} \end{axis} \end{tikzpicture} \caption{Three constant functions and their points with minimal distance} \label{fig:constant-min-distance} \end{figure} Then $(x_P,f(x_P))$ has minimal distance to $P$. Every other point has higher distance. See Figure~\ref{fig:constant-min-distance}. \section{Defined on a closed interval of $\mdr$}