math-minimal-distance-to-cubic-function.tex 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. \documentclass[a4paper]{scrartcl}
  2. \usepackage{amssymb, amsmath} % needed for math
  3. \usepackage[utf8]{inputenc} % this is needed for umlauts
  4. \usepackage[english]{babel} % this is needed for umlauts
  5. \usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
  6. \usepackage[margin=2.5cm]{geometry} %layout
  7. \usepackage{hyperref} % links im text
  8. \usepackage{braket} % needed for \Set
  9. \usepackage{parskip}
  10. \usepackage[colorinlistoftodos]{todonotes}
  11. \usepackage{pgfplots}
  12. \pgfplotsset{compat=1.7,compat/path replacement=1.5.1}
  13. \usepackage{tikz}
  14. \title{Minimal distance to a cubic function}
  15. \author{Martin Thoma}
  16. \hypersetup{
  17. pdfauthor = {Martin Thoma},
  18. pdfkeywords = {},
  19. pdftitle = {Minimal Distance}
  20. }
  21. \def\mdr{\ensuremath{\mathbb{R}}}
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. % Begin document %
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25. \begin{document}
  26. \maketitle
  27. \begin{abstract}
  28. In this paper I want to discuss how to find all points on a a cubic
  29. function with minimal distance to a given point.
  30. \end{abstract}
  31. \section{Description of the Problem}
  32. Let $f: \mdr \rightarrow \mdr$ be a polynomial function and $P \in \mdr^2$
  33. be a point. Let $d: \mdr^2 \times \mdr^2 \rightarrow \mdr_0^+$
  34. be the euklidean distance of two points:
  35. \[d \left ((x_1, y_1), (x_2, y_2) \right) := \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}\]
  36. Now there is finite set of points $x_1, \dots, x_n$ such that
  37. \[\forall \tilde x \in \mathbb{R} \setminus \{x_1, \dots, x_n\}: d(P, (x_1, f(x_1))) = \dots = d(P, (x_n, f(x_n))) < d(P, (\tilde x, f(\tilde x)))\]
  38. \section{Minimal distance to a constant function}
  39. Let $f(x) = c$ with $c \in \mdr$ be a function.
  40. \begin{figure}[htp]
  41. \centering
  42. \begin{tikzpicture}
  43. \begin{axis}[
  44. legend pos=north west,
  45. axis x line=middle,
  46. axis y line=middle,
  47. grid = major,
  48. width=0.8\linewidth,
  49. height=8cm,
  50. grid style={dashed, gray!30},
  51. xmin=-5, % start the diagram at this x-coordinate
  52. xmax= 5, % end the diagram at this x-coordinate
  53. ymin= 0, % start the diagram at this y-coordinate
  54. ymax= 3, % end the diagram at this y-coordinate
  55. axis background/.style={fill=white},
  56. xlabel=$x$,
  57. ylabel=$y$,
  58. tick align=outside,
  59. minor tick num=-3,
  60. enlargelimits=true,
  61. tension=0.08]
  62. \addplot[domain=-5:5, thick,samples=50, red] {1};
  63. \addplot[domain=-5:5, thick,samples=50, green] {2};
  64. \addplot[domain=-5:5, thick,samples=50, blue] {3};
  65. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  66. \draw[thick, dashed] (axis cs:2,0) -- (axis cs:2,3);
  67. \addlegendentry{$f(x)=1$}
  68. \addlegendentry{$g(x)=2$}
  69. \addlegendentry{$h(x)=3$}
  70. \end{axis}
  71. \end{tikzpicture}
  72. \caption{3 constant functions}
  73. \end{figure}
  74. Then $(x_P,f(x_P))$ has
  75. minimal distance to $P$. Every other point has higher distance.
  76. \section{Minimal distance to a linear function}
  77. Let $f(x) = m \cdot x + t$ with $m \in \mdr \setminus \Set{0}$ and
  78. $t \in \mdr$ be a function.
  79. \begin{figure}[htp]
  80. \centering
  81. \begin{tikzpicture}
  82. \begin{axis}[
  83. legend pos=north east,
  84. axis x line=middle,
  85. axis y line=middle,
  86. grid = major,
  87. width=0.8\linewidth,
  88. height=8cm,
  89. grid style={dashed, gray!30},
  90. xmin= 0, % start the diagram at this x-coordinate
  91. xmax= 5, % end the diagram at this x-coordinate
  92. ymin= 0, % start the diagram at this y-coordinate
  93. ymax= 3, % end the diagram at this y-coordinate
  94. axis background/.style={fill=white},
  95. xlabel=$x$,
  96. ylabel=$y$,
  97. tick align=outside,
  98. minor tick num=-3,
  99. enlargelimits=true,
  100. tension=0.08]
  101. \addplot[domain=-5:5, thick,samples=50, red] {0.5*x};
  102. \addplot[domain=-5:5, thick,samples=50, blue] {-2*x+6};
  103. \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
  104. \addlegendentry{$f(x)=\frac{1}{2}x$}
  105. \addlegendentry{$g(x)=-2x+6$}
  106. \end{axis}
  107. \end{tikzpicture}
  108. \caption{The shortest distance of $P$ to $f$ can be calculated by using the perpendicular}
  109. \end{figure}
  110. Now you can drop a perpendicular through $P$ on $f(x)$. The slope $f_\bot$
  111. of the perpendicular is $- \frac{1}{m}$. Then:
  112. \begin{align}
  113. f_\bot(x) &= - \frac{1}{m} \cdot x + t_\bot\\
  114. \Rightarrow y_P &= - \frac{1}{m} \cdot x_P + t_\bot\\
  115. \Leftrightarrow t_\bot &= y_P + \frac{1}{m} \cdot x_P\\
  116. f(x) &= f_\bot(x)\\
  117. \Leftrightarrow m \cdot x + t &= - \frac{1}{m} \cdot x + \left(y_P + \frac{1}{m} \cdot x_P \right)\\
  118. \Leftrightarrow \left (m + \frac{1}{m} \right ) \cdot x &= y_P + \frac{1}{m} \cdot x_P - t\\
  119. \Leftrightarrow x &= \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )
  120. \end{align}
  121. There is only one point with minimal distance.
  122. \clearpage
  123. \section{Minimal distance to a quadratic function}
  124. Let $f(x) = a \cdot x^2 + b \cdot x + c$ with $a \in \mdr \setminus \Set{0}$ and
  125. $b, c \in \mdr$ be a function.
  126. \begin{figure}[htp]
  127. \centering
  128. \begin{tikzpicture}
  129. \begin{axis}[
  130. legend pos=north west,
  131. axis x line=middle,
  132. axis y line=middle,
  133. grid = major,
  134. width=0.8\linewidth,
  135. height=8cm,
  136. grid style={dashed, gray!30},
  137. xmin=-3, % start the diagram at this x-coordinate
  138. xmax= 3, % end the diagram at this x-coordinate
  139. ymin=-0.25, % start the diagram at this y-coordinate
  140. ymax= 9, % end the diagram at this y-coordinate
  141. axis background/.style={fill=white},
  142. xlabel=$x$,
  143. ylabel=$y$,
  144. %xticklabels={-2,-1.6,...,7},
  145. %yticklabels={-8,-7,...,8},
  146. tick align=outside,
  147. minor tick num=-3,
  148. enlargelimits=true,
  149. tension=0.08]
  150. \addplot[domain=-3:3, thick,samples=50, red] {0.5*x*x};
  151. \addplot[domain=-3:3, thick,samples=50, green] {x*x};
  152. \addplot[domain=-3:3, thick,samples=50, blue] {x*x + x};
  153. \addplot[domain=-3:3, thick,samples=50, orange] {x*x + 2*x};
  154. \addplot[domain=-3:3, thick,samples=50, black] {-x*x + 6};
  155. \addlegendentry{$f_1(x)=\frac{1}{2}x^2$}
  156. \addlegendentry{$f_2(x)=x^2$}
  157. \addlegendentry{$f_3(x)=x^2+x$}
  158. \addlegendentry{$f_4(x)=x^2+2x$}
  159. \addlegendentry{$f_5(x)=-x^2+6$}
  160. \end{axis}
  161. \end{tikzpicture}
  162. \caption{Quadratic functions}
  163. \end{figure}
  164. \subsection{Number of points with minimal distance}
  165. It is obvious that a quadratic function can have two points with
  166. minimal distance.
  167. For example, let $f(x) = x^2$ and $P = (0,5)$. Then $P_{f,1} \approx (2.179, 2.179^2)$
  168. has minimal distance to $P$, but also $P_{f,2}\approx (-2.179, 2.179^2)$.
  169. Obviously, there cannot be more than three points with minimal distance.
  170. But can there be three points?
  171. \begin{figure}[htp]
  172. \centering
  173. \begin{tikzpicture}
  174. \begin{axis}[
  175. legend pos=north west,
  176. axis x line=middle,
  177. axis y line=middle,
  178. grid = major,
  179. width=0.8\linewidth,
  180. height=8cm,
  181. grid style={dashed, gray!30},
  182. xmin=-0.7, % start the diagram at this x-coordinate
  183. xmax= 0.7, % end the diagram at this x-coordinate
  184. ymin=-0.25, % start the diagram at this y-coordinate
  185. ymax= 0.5, % end the diagram at this y-coordinate
  186. axis background/.style={fill=white},
  187. xlabel=$x$,
  188. ylabel=$y$,
  189. %xticklabels={-2,-1.6,...,7},
  190. %yticklabels={-8,-7,...,8},
  191. tick align=outside,
  192. minor tick num=-3,
  193. enlargelimits=true,
  194. tension=0.08]
  195. \addplot[domain=-0.7:0.7, thick,samples=50, orange] {x*x};
  196. \draw (axis cs:0,0.5) circle[radius=0.5];
  197. \draw[red, thick] (axis cs:0,0.5) -- (axis cs:0.101,0.0102);
  198. \draw[red, thick] (axis cs:0,0.5) -- (axis cs:-0.101,0.0102);
  199. \draw[red, thick] (axis cs:0,0.5) -- (axis cs:0,0);
  200. \addlegendentry{$f(x)=x^2$}
  201. \end{axis}
  202. \end{tikzpicture}
  203. \caption{3 points with minimal distance?}
  204. \todo[inline]{Is this possible? http://math.stackexchange.com/q/553097/6876}
  205. \end{figure}
  206. \subsection{Calculate points with minimal distance}
  207. \todo[inline]{Write this}
  208. \section{Minimal distance to a cubic function}
  209. Let $f(x) = a \cdot x^3 + b \cdot x^2 + c \cdot x + d$ with $a \in \mdr \setminus \Set{0}$ and
  210. $b, c, d \in \mdr$ be a function.
  211. \subsection{Number of points with minimal distance}
  212. \todo[inline]{Write this}
  213. \subsection{Special points}
  214. \todo[inline]{Write this}
  215. \subsection{Voronoi}
  216. For $b^2 \geq 3ac$
  217. \todo[inline]{Write this}
  218. \subsection{Calculate points with minimal distance}
  219. \todo[inline]{Write this}
  220. \end{document}