linear-functions.tex 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. \chapter{Linear function}
  2. \section{Defined on $\mdr$}
  3. \begin{theorem}[Solution formula for linear functions on $\mdr$]
  4. Let $f: \mdr \rightarrow \mdr $ be a linear function
  5. $f(x) := m \cdot x + t$ with $m \in \mdr \setminus \Set{0}$ and
  6. $t \in \mdr$ be a linear function.
  7. Then there is only one point $(x, f(x))$ on the graph of $f$ with
  8. minimal distance to $P = (x_P, y_P)$. This point is given by
  9. \[x = \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )\]
  10. \end{theorem}
  11. \begin{figure}[htp]
  12. \centering
  13. \begin{tikzpicture}
  14. \begin{axis}[
  15. legend pos=north east,
  16. legend cell align=left,
  17. axis x line=middle,
  18. axis y line=middle,
  19. grid = major,
  20. width=0.8\linewidth,
  21. height=8cm,
  22. grid style={dashed, gray!30},
  23. xmin= 0, % start the diagram at this x-coordinate
  24. xmax= 5, % end the diagram at this x-coordinate
  25. ymin= 0, % start the diagram at this y-coordinate
  26. ymax= 3, % end the diagram at this y-coordinate
  27. axis background/.style={fill=white},
  28. xlabel=$x$,
  29. ylabel=$y$,
  30. tick align=outside,
  31. minor tick num=-3,
  32. enlargelimits=true,
  33. tension=0.08]
  34. \addplot[domain=-5:5, thick,samples=50, red] {0.5*x};
  35. \addplot[domain=-5:5, thick,samples=50, blue, dashed] {-2*x+6};
  36. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  37. \newcommand{\R}{0.9}
  38. \addplot [domain=0:2*pi,samples=50, dotted]({\R*cos(deg(x))+2},{\R*sin(deg(x))+2});
  39. \addplot[blue, nodes near coords=$f_\bot$,every node near coord/.style={anchor=225}] coordinates {(1.5, 3)};
  40. \addplot[red, nodes near coords=$f$,every node near coord/.style={anchor=225}] coordinates {(0.9, 0.5)};
  41. \addlegendentry{$f(x)=\frac{1}{2}x$}
  42. \addlegendentry{$f_\bot(x)=-2x+6$}
  43. \end{axis}
  44. \end{tikzpicture}
  45. \caption{The shortest distance of $P$ to $f$ can be calculated by using the perpendicular}
  46. \label{fig:linear-min-distance}
  47. \end{figure}
  48. \begin{proof}
  49. With Theorem~\ref{thm:fermats-theorem} you get:
  50. \begin{align}
  51. 0 &\stackrel{!}{=} (d_{P,f}(x)^2)'\\
  52. &= 2(x-x_P) + 2 (f(x) - y_P)f'(x)\\
  53. \Leftrightarrow 0 &\stackrel{!}{=} x - x_P + (f(x) - y_P) f'(x)\\
  54. &= x- x_P + (mx+t - y_P)\cdot m\\
  55. &= x (m+1) + m(t-y_P) - x_P\\
  56. \Leftrightarrow x &\stackrel{!}{=} \frac{x_p - m(t-y_p)}{m^2+1}\\
  57. &= \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )\label{eq:solution-linear-r}
  58. \end{align}
  59. It is obvious that a minium has to exist, the $x$ from Equation~\ref{eq:solution-linear-r}
  60. has to be this minimum. $\qed$
  61. \end{proof}
  62. \clearpage
  63. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  64. Let $f:[a,b] \rightarrow \mdr$, $f(x) := m\cdot x + t$ with $a,b,m,t \in \mdr$ and
  65. $a \leq b$, $m \neq 0$ be a linear function.
  66. \begin{figure}[htp]
  67. \centering
  68. \begin{tikzpicture}
  69. \begin{axis}[
  70. legend pos=north east,
  71. legend cell align=left,
  72. axis x line=middle,
  73. axis y line=middle,
  74. grid = major,
  75. width=0.8\linewidth,
  76. height=8cm,
  77. grid style={dashed, gray!30},
  78. xmin= 0, % start the diagram at this x-coordinate
  79. xmax= 5, % end the diagram at this x-coordinate
  80. ymin= 0, % start the diagram at this y-coordinate
  81. ymax= 3, % end the diagram at this y-coordinate
  82. axis background/.style={fill=white},
  83. xlabel=$x$,
  84. ylabel=$y$,
  85. tick align=outside,
  86. minor tick num=-3,
  87. enlargelimits=true,
  88. tension=0.08]
  89. \addplot[domain= 2:3, thick,samples=50, red] {0.5*x};
  90. \addplot[domain=-5:5, thick,samples=50, blue, dashed] {-2*x+6};
  91. \addplot[domain=1:1.5, thick, samples=50, orange] {3*x-3};
  92. \addplot[domain=4:5, thick, samples=50, green] {-x+5};
  93. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  94. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:1.5,1.5);
  95. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:4,1);
  96. \addlegendentry{$f(x)=\frac{1}{2}x, D = [2,3]$}
  97. \addlegendentry{$f_\bot(x)=-2x+6, D=[-5,5]$}
  98. \addlegendentry{$h(x)=3x-3, D=[1,1.5]$}
  99. \addlegendentry{$h(x)=-x+5, D=[4,5]$}
  100. \end{axis}
  101. \end{tikzpicture}
  102. \caption{Different situations when you have linear functions which
  103. are defined on a closed intervall}
  104. \label{fig:linear-min-distance-closed-intervall}
  105. \end{figure}
  106. The point with minimum distance can be found by:
  107. \[\underset{x\in[a,b]}{\arg \min d_{P,f}(x)} = \begin{cases}
  108. S_1(f, P) &\text{if } S_1(f, P) \cap [a,b] \neq \emptyset\\
  109. \Set{a} &\text{if } S_1(f, P) \ni x < a\\
  110. \Set{b} &\text{if } S_1(f, P) \ni x > b
  111. \end{cases}\]
  112. If $S_1(f, P) \cap [a,b] \neq \emptyset$, then $\underset{x\in[a,b]}{\arg \min d_{P,f}(x)} = S_1(f,P) \cap [a,b]$,
  113. because $S_1(f,P)$ gives all global minima of $f$. Those are also
  114. minima for the intervall $[a,b]$. There are not more minima, because
  115. $S_1$ gives all minima of $P$ to $f$.
  116. If $S_1(f, P) \cap [a,b] = \emptyset$, then it is not that simple.
  117. But we can calculate the distance function:
  118. \begin{align}
  119. d_{P,f}(x) &= \sqrt{(x-x_P)^2 + (f(x) - y_P)^2}\\
  120. &= \sqrt{(x^2 - 2x x_P + x_P^2) + (mx + (t-y_P))^2}\\
  121. &= \sqrt{(x^2 - 2x x_P + x_P^2) + m^2 x^2 + 2mx(t-y_P) + (t-y_P)^2}\\
  122. &= \sqrt{x^2(1+m^2) + x(-2 x_P + 2m(t-y_P)) + (x_P^2 + (t-y_P)^2)}
  123. \end{align}
  124. This function (defined on $\mdr$) is symmetry to the axis
  125. \begin{align}
  126. x_S &= - \frac{-2 x_P + 2m(t-y_P)}{2(1+m^2)}\\
  127. &= \frac{x_P - m(t-y_P)}{1+m^2}\\
  128. &= \frac{m}{m^2+1} (y_P + \frac{1}{m} x_P - t)
  129. \end{align}
  130. $f$ is on $(-\infty, x_S]$ strictly monotonically decreasing and
  131. on $[x_S, + \infty)$ strictly monotonically increasing.
  132. Thus we can conclude:
  133. \[\forall x,y \in \mdr: x \leq y < x_S \Rightarrow d_{P,f}(x_S) < d_{P,f}(y) \leq d_{P,f}(x)\]
  134. \[\forall x,y \in \mdr: x_S < y \leq x \Rightarrow d_{P,f}(x_S) < d_{P,f}(y) \leq d_{P,f}(x)\]
  135. When $S_1(f, P) \cap [a,b] = \emptyset$, then you can have two cases:
  136. \begin{itemize}
  137. \item $a \leq b < x_S$: $b$ has the shortest distance in $[a,b]$
  138. on the graph of $f$ to $P$.
  139. \item $x_S < a \leq b$: $a$ has the shortest distance in $[a,b]$
  140. on the graph of $f$ to $P$.
  141. \end{itemize}