constant-functions.tex 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. \chapter{Constant functions}
  2. \section{Defined on $\mdr$}
  3. Let $f(x) = c$ with $c \in \mdr$ be a constant function.
  4. \begin{figure}[htp]
  5. \centering
  6. \begin{tikzpicture}
  7. \begin{axis}[
  8. legend pos=north west,
  9. axis x line=middle,
  10. axis y line=middle,
  11. grid = major,
  12. width=0.8\linewidth,
  13. height=8cm,
  14. grid style={dashed, gray!30},
  15. xmin=-5, % start the diagram at this x-coordinate
  16. xmax= 5, % end the diagram at this x-coordinate
  17. ymin= 0, % start the diagram at this y-coordinate
  18. ymax= 3, % end the diagram at this y-coordinate
  19. axis background/.style={fill=white},
  20. xlabel=$x$,
  21. ylabel=$y$,
  22. tick align=outside,
  23. minor tick num=-3,
  24. enlargelimits=true,
  25. tension=0.08]
  26. \addplot[domain=-5:5, thick,samples=50, red] {1};
  27. \addplot[domain=-5:5, thick,samples=50, green] {2};
  28. \addplot[domain=-5:5, thick,samples=50, blue, densely dotted] {3};
  29. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  30. \addplot[blue, mark = *, nodes near coords=$P_{h,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(2, 3)};
  31. \addplot[green, mark = x, nodes near coords=$P_{g,\text{min}}$,every node near coord/.style={anchor=120}] coordinates {(2, 2)};
  32. \addplot[red, mark = *, nodes near coords=$P_{f,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(2, 1)};
  33. \draw[thick, dashed] (axis cs:2,0) -- (axis cs:2,3);
  34. \addlegendentry{$f(x)=1$}
  35. \addlegendentry{$g(x)=2$}
  36. \addlegendentry{$h(x)=3$}
  37. \end{axis}
  38. \end{tikzpicture}
  39. \caption{Three constant functions and their points with minimal distance}
  40. \label{fig:constant-min-distance}
  41. \end{figure}
  42. Then $(x_P,f(x_P))$ has
  43. minimal distance to $P$. Every other point has higher distance.
  44. See Figure~\ref{fig:constant-min-distance}.
  45. \section{Defined on a closed interval of $\mdr$}