linear-functions.tex 5.0 KB

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