constant-functions.tex 5.9 KB

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