constant-functions.tex 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. \chapter{Constant functions}
  2. \section{Defined on $\mdr$}
  3. Let $f:\mdr \rightarrow \mdr$, $f(x) := c$ with $c \in \mdr$ be a constant function.
  4. The situation can be seen in Figure~\ref{fig:constant-min-distance}.
  5. \begin{figure}[htp]
  6. \centering
  7. \begin{tikzpicture}
  8. \begin{axis}[
  9. legend pos=north west,
  10. legend cell align=left,
  11. axis x line=middle,
  12. axis y line=middle,
  13. grid = major,
  14. width=0.8\linewidth,
  15. height=8cm,
  16. grid style={dashed, gray!30},
  17. xmin=-5, % start the diagram at this x-coordinate
  18. xmax= 5, % end the diagram at this x-coordinate
  19. ymin= 0, % start the diagram at this y-coordinate
  20. ymax= 3, % end the diagram at this y-coordinate
  21. axis background/.style={fill=white},
  22. xlabel=$x$,
  23. ylabel=$y$,
  24. tick align=outside,
  25. minor tick num=-3,
  26. enlargelimits=true,
  27. tension=0.08]
  28. \addplot[domain=-5:5, thick,samples=50, red] {1};
  29. \addplot[domain=-5:5, thick,samples=50, green] {2};
  30. \addplot[domain=-5:5, thick,samples=50, blue, densely dotted] {3};
  31. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  32. \addplot[blue, mark = *, nodes near coords=$P_{h,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(2, 3)};
  33. \addplot[green, mark = x, nodes near coords=$P_{g,\text{min}}$,every node near coord/.style={anchor=120}] coordinates {(2, 2)};
  34. \addplot[red, mark = *, nodes near coords=$P_{f,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(2, 1)};
  35. \draw[thick, dashed] (axis cs:2,0) -- (axis cs:2,3);
  36. \addlegendentry{$f(x)=1$}
  37. \addlegendentry{$g(x)=2$}
  38. \addlegendentry{$h(x)=3$}
  39. \end{axis}
  40. \end{tikzpicture}
  41. \caption{Three constant functions and their points with minimal distance}
  42. \label{fig:constant-min-distance}
  43. \end{figure}
  44. \begin{align}
  45. d_{P,f}(x) &= \sqrt{(x_P - x)^2 + (y_P - f(x))^2}\\
  46. &= \sqrt{(x_P^2 - 2x_P x + x^2) + (y_P^2 - 2 y_P c + c^2)} \\
  47. &= \sqrt{x^2 - 2 x_P x + (x_P^2 + y_P^2 - 2 y_P c + c^2)}\label{eq:constant-function-distance}\\
  48. \xRightarrow{\text{Theorem}~\ref{thm:fermats-theorem}} 0 &\stackrel{!}{=} (d_{P,f}(x)^2)'\\
  49. &= 2x - 2x_P\\
  50. \Leftrightarrow x &\stackrel{!}{=} x_P
  51. \end{align}
  52. Then $(x_P,f(x_P))$ has
  53. minimal distance to $P$. Every other point has higher distance.
  54. See Figure~\ref{fig:constant-min-distance} to see that intuition
  55. yields to the same results.
  56. This result means:
  57. \[S_0(f, P) = \Set{x_P} \text{ with } P = (x_P, y_P)\]
  58. \clearpage
  59. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  60. Let $f:[a,b] \rightarrow \mdr$, $f(x) := c$ with $a,b,c \in \mdr$ and
  61. $a \leq b$ be a constant function.
  62. \begin{figure}[htp]
  63. \centering
  64. \begin{tikzpicture}
  65. \begin{axis}[
  66. legend pos=north west,
  67. legend cell align=left,
  68. axis x line=middle,
  69. axis y line=middle,
  70. grid = major,
  71. width=0.8\linewidth,
  72. height=8cm,
  73. grid style={dashed, gray!30},
  74. xmin=-5, % start the diagram at this x-coordinate
  75. xmax= 5, % end the diagram at this x-coordinate
  76. ymin= 0, % start the diagram at this y-coordinate
  77. ymax= 3, % end the diagram at this y-coordinate
  78. axis background/.style={fill=white},
  79. xlabel=$x$,
  80. ylabel=$y$,
  81. tick align=outside,
  82. minor tick num=-3,
  83. enlargelimits=true,
  84. tension=0.08]
  85. \addplot[domain=-5:-2, thick,samples=50, red] {1};
  86. \addplot[domain=-1:3, thick,samples=50, green] {1.5};
  87. \addplot[domain=3:5, thick,samples=50, blue, densely dotted] {3};
  88. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  89. \addplot[blue, mark = *, nodes near coords=$P_{h,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(3, 3)};
  90. \addplot[green, mark = x, nodes near coords=$P_{g,\text{min}}$,every node near coord/.style={anchor=120}] coordinates {(2, 1.5)};
  91. \addplot[red, mark = *, nodes near coords=$P_{f,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(-2, 1)};
  92. \draw[thick, dashed] (axis cs:2,1.5) -- (axis cs:2,2);
  93. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:-2,1);
  94. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:3,3);
  95. \addlegendentry{$f(x)=1, D = [-5,-2]$}
  96. \addlegendentry{$g(x)=1.5, D = [-1,3]$}
  97. \addlegendentry{$h(x)=3, D = [3,5]$}
  98. \end{axis}
  99. \end{tikzpicture}
  100. \caption{Three constant functions and their points with minimal distance}
  101. \label{fig:constant-min-distance-closed-intervall}
  102. \end{figure}
  103. The point with minimum distance can be found by:
  104. \[\underset{x\in\mdr}{\arg \min d_{P,f}(x)} = \begin{cases}
  105. S_0(f,P) &\text{if } S_0(f,P) \cap [a,b] \neq \emptyset \\
  106. \Set{a} &\text{if } S_0(f,P) \ni x_P < a\\
  107. \Set{b} &\text{if } S_0(f,P) \ni x_P > b
  108. \end{cases}\]
  109. Because:
  110. \begin{align}
  111. \underset{x\in[a,b]}{\arg \min d_{P,f}(x)} &= \underset{x\in[a,b]}{\arg \min d_{P,f}(x)^2}\\
  112. &=\underset{x\in[a,b]}{\arg \min} x^2 - 2x_P x + (x_P^2 + y_P^2 - 2 y_P c + c^2)\\
  113. &=\underset{x\in[a,b]}{\arg \min} x^2 - 2 x_P x + x_P^2\\
  114. &=\underset{x\in[a,b]}{\arg \min} (x-x_P)^2
  115. \end{align}