linear-functions.tex 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. axis x line=middle,
  11. axis y line=middle,
  12. grid = major,
  13. width=0.8\linewidth,
  14. height=8cm,
  15. grid style={dashed, gray!30},
  16. xmin= 0, % start the diagram at this x-coordinate
  17. xmax= 5, % end the diagram at this x-coordinate
  18. ymin= 0, % start the diagram at this y-coordinate
  19. ymax= 3, % end the diagram at this y-coordinate
  20. axis background/.style={fill=white},
  21. xlabel=$x$,
  22. ylabel=$y$,
  23. tick align=outside,
  24. minor tick num=-3,
  25. enlargelimits=true,
  26. tension=0.08]
  27. \addplot[domain=-5:5, thick,samples=50, red] {0.5*x};
  28. \addplot[domain=-5:5, thick,samples=50, blue] {-2*x+6};
  29. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  30. \addlegendentry{$f(x)=\frac{1}{2}x$}
  31. \addlegendentry{$g(x)=-2x+6$}
  32. \end{axis}
  33. \end{tikzpicture}
  34. \caption{The shortest distance of $P$ to $f$ can be calculated by using the perpendicular}
  35. \label{fig:linear-min-distance}
  36. \end{figure}
  37. Now you can drop a perpendicular $f_\bot$ through $P$ on $f(x)$. The
  38. slope of $f_\bot$ is $- \frac{1}{m}$ and $t_\bot$ can be calculated:\nobreak
  39. \begin{align}
  40. f_\bot(x) &= - \frac{1}{m} \cdot x + t_\bot\\
  41. \Rightarrow y_P &= - \frac{1}{m} \cdot x_P + t_\bot\\
  42. \Leftrightarrow t_\bot &= y_P + \frac{1}{m} \cdot x_P
  43. \end{align}
  44. The point $(x, f(x))$ where the perpendicular $f_\bot$ crosses $f$
  45. is calculated this way:
  46. \begin{align}
  47. f(x) &= f_\bot(x)\\
  48. \Leftrightarrow m \cdot x + t &= - \frac{1}{m} \cdot x + \left(y_P + \frac{1}{m} \cdot x_P \right)\\
  49. \Leftrightarrow \left (m + \frac{1}{m} \right ) \cdot x &= y_P + \frac{1}{m} \cdot x_P - t\\
  50. \Leftrightarrow x &= \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )
  51. \end{align}
  52. There is only one point with minimal distance. See Figure~\ref{fig:linear-min-distance}.
  53. \section{Defined on a closed interval of $\mdr$}