linear-functions.tex 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 the points $(x, f(x))$ with minimal distance are given by:
  8. \[x = \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )\]
  9. \end{theorem}
  10. \begin{figure}[htp]
  11. \centering
  12. \begin{tikzpicture}
  13. \begin{axis}[
  14. legend pos=north east,
  15. legend cell align=left,
  16. axis x line=middle,
  17. axis y line=middle,
  18. grid = major,
  19. width=0.8\linewidth,
  20. height=8cm,
  21. grid style={dashed, gray!30},
  22. xmin= 0, % start the diagram at this x-coordinate
  23. xmax= 5, % end the diagram at this x-coordinate
  24. ymin= 0, % start the diagram at this y-coordinate
  25. ymax= 3, % end the diagram at this y-coordinate
  26. axis background/.style={fill=white},
  27. xlabel=$x$,
  28. ylabel=$y$,
  29. tick align=outside,
  30. minor tick num=-3,
  31. enlargelimits=true,
  32. tension=0.08]
  33. \addplot[domain=-5:5, thick,samples=50, red] {0.5*x};
  34. \addplot[domain=-5:5, thick,samples=50, blue, dashed] {-2*x+6};
  35. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  36. \addplot[blue, nodes near coords=$f_\bot$,every node near coord/.style={anchor=225}] coordinates {(1.5, 3)};
  37. \addplot[red, nodes near coords=$f$,every node near coord/.style={anchor=225}] coordinates {(0.9, 0.5)};
  38. \addlegendentry{$f(x)=\frac{1}{2}x$}
  39. \addlegendentry{$f_\bot(x)=-2x+6$}
  40. \end{axis}
  41. \end{tikzpicture}
  42. \caption{The shortest distance of $P$ to $f$ can be calculated by using the perpendicular}
  43. \label{fig:linear-min-distance}
  44. \end{figure}
  45. \begin{proof}
  46. Now you can drop a perpendicular $f_\bot$ through $P$ on $f(x)$. The
  47. slope of $f_\bot$ is $- \frac{1}{m}$ and $t_\bot$ can be calculated:\nobreak
  48. \begin{align}
  49. f_\bot(x) &= - \frac{1}{m} \cdot x + t_\bot\\
  50. \Rightarrow y_P &= - \frac{1}{m} \cdot x_P + t_\bot\\
  51. \Leftrightarrow t_\bot &= y_P + \frac{1}{m} \cdot x_P
  52. \end{align}
  53. The point $(x, f(x))$ where the perpendicular $f_\bot$ crosses $f$
  54. is calculated this way:
  55. \begin{align}
  56. f(x) &= f_\bot(x)\\
  57. \Leftrightarrow m \cdot x + t &= - \frac{1}{m} \cdot x + \left(y_P + \frac{1}{m} \cdot x_P \right)\\
  58. \Leftrightarrow \left (m + \frac{1}{m} \right ) \cdot x &= y_P + \frac{1}{m} \cdot x_P - t\\
  59. \Leftrightarrow x &= \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )\label{eq:solution-of-the-linear-problem}
  60. \end{align}
  61. There is only one point with minimal distance. I'll call the result
  62. from line~\ref{eq:solution-of-the-linear-problem} \enquote{solution of
  63. the linear problem} and the function that gives this solution
  64. $S_1(f,P)$.
  65. See Figure~\ref{fig:linear-min-distance}
  66. to get intuition about the geometry used. $\qed$
  67. \end{proof}
  68. \clearpage
  69. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  70. Let $f:[a,b] \rightarrow \mdr$, $f(x) := m\cdot x + t$ with $a,b,m,t \in \mdr$ and
  71. $a \leq b$, $m \neq 0$ be a linear function.
  72. \begin{figure}[htp]
  73. \centering
  74. \begin{tikzpicture}
  75. \begin{axis}[
  76. legend pos=north east,
  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= 0, % 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= 2:3, thick,samples=50, red] {0.5*x};
  96. \addplot[domain=-5:5, thick,samples=50, blue, dashed] {-2*x+6};
  97. \addplot[domain=1:1.5, thick, samples=50, orange] {3*x-3};
  98. \addplot[domain=4:5, thick, samples=50, green] {-x+5};
  99. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  100. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:1.5,1.5);
  101. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:4,1);
  102. \addlegendentry{$f(x)=\frac{1}{2}x, D = [2,3]$}
  103. \addlegendentry{$f_\bot(x)=-2x+6, D=[-5,5]$}
  104. \addlegendentry{$h(x)=3x-3, D=[1,1.5]$}
  105. \addlegendentry{$h(x)=-x+5, D=[4,5]$}
  106. \end{axis}
  107. \end{tikzpicture}
  108. \caption{Different situations when you have linear functions which
  109. are defined on a closed intervall}
  110. \label{fig:linear-min-distance-closed-intervall}
  111. \end{figure}
  112. The point with minimum distance can be found by:
  113. \[\underset{x\in[a,b]}{\arg \min d_{P,f}(x)} = \begin{cases}
  114. S_1(f, P) &\text{if } S_1(f, P) \cap [a,b] \neq \emptyset\\
  115. \Set{a} &\text{if } S_1(f, P) \ni x < a\\
  116. \Set{b} &\text{if } S_1(f, P) \ni x > b
  117. \end{cases}\]
  118. \todo[inline]{argument? proof?}