constant-functions.tex 6.0 KB

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