linear-functions.tex 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. \chapter{Linear function}
  2. \section{Defined on $\mdr$}
  3. Let $f(x) = m \cdot x + t$ with $m \in \mdr \setminus \Set{0}$ and
  4. $t \in \mdr$ be a linear function.
  5. \begin{figure}[htp]
  6. \centering
  7. \begin{tikzpicture}
  8. \begin{axis}[
  9. legend pos=north east,
  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= 0, % 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] {0.5*x};
  29. \addplot[domain=-5:5, thick,samples=50, blue] {-2*x+6};
  30. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  31. \addlegendentry{$f(x)=\frac{1}{2}x$}
  32. \addlegendentry{$f_\bot(x)=-2x+6$}
  33. \end{axis}
  34. \end{tikzpicture}
  35. \caption{The shortest distance of $P$ to $f$ can be calculated by using the perpendicular}
  36. \label{fig:linear-min-distance}
  37. \end{figure}
  38. Now you can drop a perpendicular $f_\bot$ through $P$ on $f(x)$. The
  39. slope of $f_\bot$ is $- \frac{1}{m}$ and $t_\bot$ can be calculated:\nobreak
  40. \begin{align}
  41. f_\bot(x) &= - \frac{1}{m} \cdot x + t_\bot\\
  42. \Rightarrow y_P &= - \frac{1}{m} \cdot x_P + t_\bot\\
  43. \Leftrightarrow t_\bot &= y_P + \frac{1}{m} \cdot x_P
  44. \end{align}
  45. The point $(x, f(x))$ where the perpendicular $f_\bot$ crosses $f$
  46. is calculated this way:
  47. \begin{align}
  48. f(x) &= f_\bot(x)\\
  49. \Leftrightarrow m \cdot x + t &= - \frac{1}{m} \cdot x + \left(y_P + \frac{1}{m} \cdot x_P \right)\\
  50. \Leftrightarrow \left (m + \frac{1}{m} \right ) \cdot x &= y_P + \frac{1}{m} \cdot x_P - t\\
  51. \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}
  52. \end{align}
  53. There is only one point with minimal distance. I'll call the result
  54. from line~\ref{eq:solution-of-the-linear-problem} \enquote{solution of
  55. the linear problem} and the function that gives this solution
  56. $S_1(f,P)$.
  57. See Figure~\ref{fig:linear-min-distance}
  58. to get intuition about the geometry used.
  59. \clearpage
  60. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  61. Let $f:[a,b] \rightarrow \mdr$, $f(x) := m\cdot x + t$ with $a,b,m,t \in \mdr$ and
  62. $a \leq b$, $m \neq 0$ be a linear function.
  63. \begin{figure}[htp]
  64. \centering
  65. \begin{tikzpicture}
  66. \begin{axis}[
  67. legend pos=north east,
  68. legend cell align=left,
  69. axis x line=middle,
  70. axis y line=middle,
  71. grid = major,
  72. width=0.8\linewidth,
  73. height=8cm,
  74. grid style={dashed, gray!30},
  75. xmin= 0, % start the diagram at this x-coordinate
  76. xmax= 5, % end the diagram at this x-coordinate
  77. ymin= 0, % start the diagram at this y-coordinate
  78. ymax= 3, % end the diagram at this y-coordinate
  79. axis background/.style={fill=white},
  80. xlabel=$x$,
  81. ylabel=$y$,
  82. tick align=outside,
  83. minor tick num=-3,
  84. enlargelimits=true,
  85. tension=0.08]
  86. \addplot[domain= 2:3, thick,samples=50, red] {0.5*x};
  87. \addplot[domain=-5:5, thick,samples=50, blue, dashed] {-2*x+6};
  88. \addplot[domain=1:1.5, thick, samples=50, orange] {3*x-3};
  89. \addplot[domain=4:5, thick, samples=50, green] {-x+5};
  90. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  91. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:1.5,1.5);
  92. \draw[thick, dashed] (axis cs:2,2) -- (axis cs:4,1);
  93. \addlegendentry{$f(x)=\frac{1}{2}x, D = [2,3]$}
  94. \addlegendentry{$f_\bot(x)=-2x+6, D=[-5,5]$}
  95. \addlegendentry{$h(x)=3x-3, D=[1,1.5]$}
  96. \addlegendentry{$h(x)=-x+5, D=[4,5]$}
  97. \end{axis}
  98. \end{tikzpicture}
  99. \caption{Different situations when you have linear functions which
  100. are defined on a closed intervall}
  101. \label{fig:linear-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_1(f, P) &\text{if } S_1(f, P) \cap [a,b] \neq \emptyset\\
  106. \Set{a} &\text{if } S_1(f, P) \ni x < a\\
  107. \Set{b} &\text{if } S_1(f, P) \ni x > b
  108. \end{cases}\]