quadratic-functions.tex 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. \chapter{Quadratic functions}
  2. \section{Defined on $\mdr$}
  3. Let $f(x) = a \cdot x^2 + b \cdot x + c$ with $a \in \mdr \setminus \Set{0}$ and
  4. $b, c \in \mdr$ be a quadratic function.
  5. \begin{figure}[htp]
  6. \centering
  7. \begin{tikzpicture}
  8. \begin{axis}[
  9. legend pos=north west,
  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=-3, % start the diagram at this x-coordinate
  17. xmax= 3, % end the diagram at this x-coordinate
  18. ymin=-0.25, % start the diagram at this y-coordinate
  19. ymax= 9, % 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=-3:3, thick,samples=50, red] {0.5*x*x};
  28. \addplot[domain=-3:3, thick,samples=50, green] { x*x};
  29. \addplot[domain=-3:3, thick,samples=50, blue] { x*x + x};
  30. \addplot[domain=-3:3, thick,samples=50, orange,dotted] { x*x + 2*x};
  31. \addplot[domain=-3:3, thick,samples=50, black,dashed] {-x*x + 6};
  32. \addlegendentry{$f_1(x)=\frac{1}{2}x^2$}
  33. \addlegendentry{$f_2(x)=x^2$}
  34. \addlegendentry{$f_3(x)=x^2+x$}
  35. \addlegendentry{$f_4(x)=x^2+2x$}
  36. \addlegendentry{$f_5(x)=-x^2+6$}
  37. \end{axis}
  38. \end{tikzpicture}
  39. \caption{Quadratic functions}
  40. \end{figure}
  41. \subsection{Calculate points with minimal distance}
  42. In this case, $d_{P,f}^2$ is polynomial of degree 4.
  43. We use Theorem~\ref{thm:required-extremum-property}:\nobreak
  44. \begin{align}
  45. 0 &\overset{!}{=} (d_{P,f}^2)'\\
  46. &= -2 x_p + 2x -2y_p f'(x) + \left (f(x)^2 \right )'\\
  47. &= -2 x_p + 2x -2y_p f'(x) + 2 f(x) \cdot f'(x) \rlap{\hspace*{3em}(chain rule)}\label{eq:minimizingFirstDerivative}\\
  48. \Leftrightarrow 0 &\overset{!}{=} -x_p + x -y_p f'(x) + f(x) \cdot f'(x) \rlap{\hspace*{3em}(divide by 2)}\label{eq:minimizingFirstDerivative}\\
  49. &= -x_p + x -y_p (2ax+b) + (ax^2+bx+c)(2ax+b)\\
  50. &= -x_p + x -y_p \cdot 2ax- y_p b + (2 a^2 x^3+2 a b x^2+2 a c x+ab x^2+b^2 x+bc)\\
  51. &= -x_p + x -2y_p ax- y_p b + (2a^2 x^3 + 3 ab x^2 + 2acx + b^2 x + bc)\\
  52. &= 2a^2 x^3 + 3 ab x^2 + (1 -2y_p a+ 2ac + b^2)x +(bc-by_p-x_p)\label{eq:quadratic-derivative-eq-0}
  53. \end{align}
  54. This is an algebraic equation of degree 3.
  55. There can be up to 3 solutions in such an equation. Those solutions
  56. can be found with a closed formula. But not every solution of the
  57. equation given by Theorem~\ref{thm:required-extremum-property}
  58. has to be a solution to the given problem.
  59. \begin{example}
  60. Let $a = 1, b = 0, c= 1, x_p= 0, y_p = 1$.
  61. So $f(x) = x^2 + 1$ and $P(0, 1)$.
  62. \begin{align}
  63. 0 &\stackrel{!}{=} 4 x^3 - 2x\\
  64. &=2x(2x^2 - 1)\\
  65. \Rightarrow x_1 &= 0 \;\;\; x_{2,3} = \pm \frac{1}{\sqrt{2}}
  66. \end{align}
  67. As you can easily verify, only $x_1$ is a minimum of $d_{P,f}$.
  68. \end{example}
  69. \subsection{Number of points with minimal distance}
  70. \begin{theorem}
  71. A point $P$ has either one or two points on the graph of a
  72. quadratic function $f$ that are closest to $P$.
  73. \end{theorem}
  74. \begin{proof}
  75. In the following, I will do some transformations with $f = f_0$ and
  76. $P = P_0$ .
  77. Moving $f_0$ and $P_0$ simultaneously in $x$ or $y$ direction does
  78. not change the minimum distance. Furthermore, we can find the
  79. points with minimum distance on the moved situation and calculate
  80. the minimum points in the original situation.
  81. First of all, we move $f_0$ and $P_0$ by $\frac{b}{2a}$ in $x$ direction, so
  82. \[f_1(x) = ax^2 - \frac{b^2}{4a} + c \;\;\;\text{ and }\;\;\; P_1 = \left (x_p+\frac{b}{2a},\;\; y_p \right )\]
  83. Because:\footnote{The idea why you subtract $\frac{b}{2a}$ within
  84. $f$ is that when you subtract something from $x$ before applying
  85. $f$ it takes more time ($x$ needs to be bigger) to get to the same
  86. situation. So to move the whole graph by $1$ to the left whe have
  87. to add $+1$.}
  88. \begin{align}
  89. f(x-\nicefrac{b}{2a}) &= a (x-\nicefrac{b}{2a})^2 + b (x-\nicefrac{b}{2a}) + c\\
  90. &= a (x^2 - \nicefrac{b}{a} x + \nicefrac{b^2}{4a^2}) + bx - \nicefrac{b^2}{2a} + c\\
  91. &= ax^2 - bx + \nicefrac{b^2}{4a} + bx - \nicefrac{b^2}{2a} + c\\
  92. &= ax^2 -\nicefrac{b^2}{4a} + c
  93. \end{align}
  94. Then move $f_1$ and $P_1$ by $\frac{b^2}{4a}-c$ in $y$ direction. You get:
  95. \[f_2(x) = ax^2\;\;\;\text{ and }\;\;\; P_2 = \Big (\underbrace{x_P+\frac{b}{2a}}_{=: z},\;\; \underbrace{y_P+\frac{b^2}{4a}-c}_{=: w} \Big )\]
  96. As $f_2(x) = ax^2$ is symmetric to the $y$ axis, only points
  97. $P = (0, w)$ could possilby have three minima.
  98. Then compute:
  99. \begin{align}
  100. d_{P,{f_2}}(x) &= \sqrt{(x-0)^2 + (f_2(x)-w)^2}\\
  101. &= \sqrt{x^2 + (ax^2-w)^2}\\
  102. &= \sqrt{x^2 + a^2 x^4-2aw x^2+w^2}\\
  103. &= \sqrt{a^2 x^4 + (1-2aw) x^2 + w^2}\\
  104. &= \sqrt{\left (a^2 x^2 + \frac{1-2 a w}{2} \right )^2 + w^2 - (1-2 a w)^2}\\
  105. &= \sqrt{\left (a^2 x^2 + \nicefrac{1}{2}-a w \right )^2 + \big (w^2 - (1-2 a w)^2 \big)}
  106. \end{align}
  107. The term
  108. \[a^2 x^2 + (\nicefrac{1}{2}-a w)\]
  109. should get as close to $0$ as possilbe when we want to minimize
  110. $d_{P,{f_2}}$. For $w \leq \nicefrac{1}{2a}$ you only have $x = 0$ as a minimum.
  111. For all other points $P = (0, w)$, there are exactly two minima $x_{1,2} = \pm \sqrt{aw - \nicefrac{1}{2}}$.
  112. $\qed$
  113. \end{proof}
  114. \subsection{Solution formula}
  115. We start with the graph that was moved so that $f_2 = ax^2$.
  116. \textbf{Case 1:} $P$ is on the symmetry axis, hence $x_P = - \frac{b}{2a}$.
  117. In this case, we have already found the solution. If $y_P + \frac{b^2}{4a} - c > \frac{1}{2a}$,
  118. then there are two solutions:
  119. \[x_{1,2} = \pm \sqrt{aw - \nicefrac{1}{2}}\]
  120. Otherwise, there is only one solution $x_1 = 0$.
  121. \textbf{Case 2:} $P = (z, w)$ is not on the symmetry axis, so $z \neq 0$. Then you compute:
  122. \begin{align}
  123. d_{P,{f_2}}(x) &= \sqrt{(x-z)^2 + (f(x)-w)^2}\\
  124. &= \sqrt{(x^2 - 2zx + z^2) + ((ax^2)^2 - 2 awx^2 + w^2)}\\
  125. &= \sqrt{a^2x^4 + (1- 2 aw)x^2 +(- 2z)x + z^2 + w^2}\\
  126. 0 &\stackrel{!}{=} \Big(\big(d_{P, {f_2}}(x)\big)^2\Big)' \\
  127. &= 4a^2x^3 + 2(1- 2 aw)x +(- 2z)\\
  128. &= 2 \left (2a^2x^2 + (1- 2 aw) \right )x - 2z\\
  129. \Leftrightarrow 0 &\stackrel{!}{=} (2a^2x^2 + (1- 2 aw)) x - z\\
  130. &= 2 a^2 x^3 + (1- 2 aw) x - z\\
  131. \Leftrightarrow 0 &\stackrel{!}{=} x^3 + \underbrace{\frac{1- 2 aw}{2 a^2}}_{=: \alpha} x + \underbrace{\frac{-z}{2 a^2}}_{=: \beta}\\
  132. &= x^3 + \alpha x + \beta\label{eq:simple-cubic-equation-for-quadratic-distance}
  133. \end{align}
  134. Let $t$ be defined as
  135. \[t := \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\]
  136. \textbf{Case 2.1:} $4 \alpha^3 + 27 \beta^2 \geq 0$:
  137. The solution of Equation~\ref{eq:simple-cubic-equation-for-quadratic-distance}
  138. is
  139. \[x = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}\]
  140. When you insert this in Equation~\ref{eq:simple-cubic-equation-for-quadratic-distance}
  141. you get:\footnote{Remember: $(a-b)^3 = a^3-3 a^2 b+3 a b^2-b^3$}
  142. \allowdisplaybreaks
  143. \begin{align}
  144. 0 &\stackrel{!}{=} \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right )^3 + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  145. &= (\frac{t}{\sqrt[3]{18}})^3
  146. - 3 (\frac{t}{\sqrt[3]{18}})^2 \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}
  147. + 3 (\frac{t}{\sqrt[3]{18}})(\frac{\sqrt[3]{\frac{2}{3}} \alpha }{t})^2
  148. - (\frac{\sqrt[3]{\frac{2}{3}} \alpha }{t})^3
  149. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  150. &= \frac{t^3}{18}
  151. - \frac{3t^2}{\sqrt[3]{18^2}} \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}
  152. + \frac{3t}{\sqrt[3]{18}} \frac{\sqrt[3]{\frac{4}{9}} \alpha^2 }{t^2}
  153. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  154. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  155. &= \frac{t^3}{18}
  156. - \frac{\sqrt[3]{18} t \alpha}{\sqrt[3]{18^2}}
  157. + \frac{\sqrt[3]{12} \alpha^2}{\sqrt[3]{18} t}
  158. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  159. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  160. &= \frac{t^3}{18}
  161. - \frac{t \alpha}{\sqrt[3]{18}}
  162. \color{red}+ \frac{\sqrt[3]{2} \alpha^2}{\sqrt[3]{3} t} \color{black}
  163. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  164. + \color{red}\alpha \color{black} \left (\frac{t}{\sqrt[3]{18}} \color{red}- \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \color{black}\right )
  165. + \beta\\
  166. &= \frac{t^3}{18} \color{blue}- \frac{t \alpha}{\sqrt[3]{18}} \color{black}
  167. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  168. \color{blue}+ \frac{\alpha t}{\sqrt[3]{18}} \color{black}
  169. + \beta\\
  170. &= \frac{t^3}{18} - \frac{\frac{2}{3} \alpha^3 }{t^3} + \beta\\
  171. &= \frac{t^6 - 12 \alpha^3 + \beta 18 t^3}{18t^3}
  172. \end{align}
  173. Now only go on calculating with the numerator. Start with resubstituting
  174. $t$:
  175. \begin{align}
  176. 0 &= (\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta)^2 - 12 \alpha^3 + \beta 18 (\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta)\\
  177. &= (\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)})^2 +(9\beta)^2 - 12 \alpha^3 -18\cdot 9\beta^2\\
  178. &= 3 \cdot (4 \alpha^3 + 27 \beta^2) -81 \beta^2 - 12 \alpha^3\\
  179. &= (4 \alpha^3 + 27 \beta^2) -27 \beta^2 - 4 \alpha^3\\
  180. &= 0
  181. \end{align}
  182. \textbf{Case 2.2:}
  183. \todo[inline]{calculate...}
  184. \[x = \frac{(1+i \sqrt{3})\alpha}{\sqrt[3]{12} \cdot t}
  185. -\frac{(1-i\sqrt{3}) t}{2\sqrt[3]{18}}\]
  186. \begin{align}
  187. x^3 &= \underbrace{\left (\frac{(1+i\sqrt{3})\alpha}{\sqrt[3]{12} \cdot t} \right)^3}_{=: \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {1}}}}
  188. \underbrace{- 3 \left(\frac{(1+i\sqrt{3})\alpha}{\sqrt[3]{12} \cdot t} \right)^2 \left(\frac{(1-i\sqrt{3})t}{2 \sqrt[3]{18}} \right)}_{=: \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {2}}}}\\
  189. &\hphantom{{}=}+ \underbrace{3 \left(\frac{(1+i\sqrt{3})\alpha}{\sqrt[3]{12} \cdot t} \right) \left(\frac{(1-i\sqrt{3})t}{2 \sqrt[3]{18}}\right)^2}_{=: \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {3}}}}
  190. \underbrace{- \left(\frac{(1-i\sqrt{3})t}{2 \sqrt[3]{18}}\right)^3}_{=: \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {4}}}}
  191. \end{align}
  192. Now simplify the summands:
  193. \begin{align}
  194. \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {1}}} &=
  195. \left (\frac{(1+i\sqrt{3})\alpha}{\sqrt[3]{12} \cdot t} \right)^3\\
  196. &= \frac{\alpha^3(1-3i\sqrt{3} - 3 \cdot 3 + \sqrt{27} i)}{12 t^3}\\
  197. &= \frac{-8\alpha^3}{12 t^3}\\
  198. &= \frac{-2 \alpha^3}{3 t^3}\\
  199. \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {2}}} &=- 3 \left(\frac{(1+i\sqrt{3})\alpha}{\sqrt[3]{12} \cdot t} \right)^2 \left(\frac{(1-i\sqrt{3})t}{2 \sqrt[3]{18}} \right)\\
  200. &= \frac{-3\alpha^2(1+2\sqrt{3}i-3)(1-i\sqrt{3})t}{t^2 \sqrt[3]{2^4 \cdot 3^2} \cdot 2 \sqrt[3]{2 \cdot 3^2}}\\
  201. &= \frac{-3\alpha^2((1+2\sqrt{3}i - 3)+(- i\sqrt{3}+2\cdot 3 + i\sqrt{3}))}{12 t \sqrt[3]{12}}\\
  202. &= \frac{-\alpha^2(4+2\sqrt{3}i)}{4t\sqrt[3]{12}}\\
  203. &= \frac{-\alpha^2(2+\sqrt{3}i)}{2t\sqrt[3]{12}}\\
  204. \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {3}}} &= 3 \left(\frac{(1+i\sqrt{3})\alpha}{\sqrt[3]{12} \cdot t} \right) \left(\frac{(1-i\sqrt{3})t}{2 \sqrt[3]{18}}\right)^2\\
  205. &= \frac{3(1+i\sqrt{3})\alpha (1-2i\sqrt{3} - 3)t}{4 \sqrt[3]{12 \cdot 18^2}}\\
  206. &= \frac{3 \alpha t((1-2i\sqrt{3}-3)+(i\sqrt{3} + 2\cdot 3 - 3i\sqrt{3}))}{4 \sqrt[3]{2^2 \cdot 3 \cdot (2 \cdot 3^2)^2}}\\
  207. &= \frac{3 \alpha t(4-4\sqrt{3}i)}{4 \cdot 2 \cdot 3 \sqrt[3]{2 \cdot 3^2}}\\
  208. &= \frac{\alpha t(1-\sqrt{3}i)}{2\sqrt[3]{18}}\\
  209. \raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {4}}} &= - \left(\frac{(1-i\sqrt{3})t}{2 \sqrt[3]{18}}\right)^3\\
  210. &= -\frac{(1-3i\sqrt{3} - 3 \cdot 3 + i \sqrt{27}) t^3}{8 \cdot 18}\\
  211. &=- \frac{t^3 (-8)}{8 \cdot 18}\\
  212. &= \frac{t^3}{18}
  213. \end{align}
  214. Now get back to the original equation:
  215. \begin{align}
  216. 0 &\stackrel{!}{=} x^3 + \alpha x + \beta \\
  217. &= \left (\frac{-2 \alpha^3}{3 t^3}
  218. + \frac{-\alpha^2(2+\sqrt{3}i)}{2t\sqrt[3]{12}}
  219. + \color{blue}\frac{\alpha t(1-\sqrt{3}i)}{2\sqrt[3]{18}}\color{black}
  220. + \frac{t^3}{18} \right )\\
  221. &\hphantom{{}=} + \color{blue}\alpha\color{black} \left (\frac{(1+i \sqrt{3})\alpha}{\sqrt[3]{12} \cdot t}
  222. \color{blue}-\frac{(1-i\sqrt{3}) t}{2\sqrt[3]{18}} \color{black} \right ) + \beta\\
  223. &= \frac{-2 \alpha^3}{3 t^3}
  224. + \frac{\alpha^2(2(1+i\sqrt{3})-(2+\sqrt{3}i))}{2t\sqrt[3]{12}}
  225. + \frac{t^3}{18}
  226. + \beta\\
  227. &= \frac{-24 \alpha^3 + (3\sqrt[3]{18}t^2)(\alpha^2\sqrt{3}i) + 2t^3+36 t^3 \beta}{36t^3}
  228. \end{align}
  229. \textbf{Case 2.3:}
  230. \todo[inline]{calculate...}
  231. \[x = \frac{(1-i \sqrt{3})a}{\sqrt[3]{12} \cdot t}
  232. -\frac{(1+i\sqrt{3}) t}{2\sqrt[3]{18}}\]
  233. \goodbreak
  234. So the solution is given by
  235. \todo[inline]{NO! Currently, there are erros in the solution.
  236. Check $f(x) = x^2$ and $P=(-2,4)$. Solution should be $x_1 = -2$, but it isn't!}
  237. \begin{align*}
  238. x_S &:= - \frac{b}{2a} \;\;\;\;\; \text{(the symmetry axis)}\\
  239. w &:= y_P+\frac{b^2}{4a}-c \;\;\; \text{ and } \;\;\; z := x_P+\frac{b}{2a}\\
  240. \alpha &:= \frac{1- 2 aw}{2 a^2} \;\;\;\text{ and }\;\;\; \beta := \frac{-z}{2 a^2}\\
  241. t &:= \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\\
  242. \underset{x\in\mdr}{\arg \min d_{P,f}(x)} &= \begin{cases}
  243. x_1 = +\sqrt{a (y_p + \frac{b^2}{4a} - c) - \frac{1}{2}} + x_S \text{ and } &\text{if } x_P = x_S \text{ and } y_p + \frac{b^2}{4a} - c > \frac{1}{2a} \\
  244. x_2 = -\sqrt{a (y_p + \frac{b^2}{4a} - c) - \frac{1}{2}} + x_S\\
  245. x_1 = x_S &\text{if } x_P = x_S \text{ and } y_p + \frac{b^2}{4a} - c \leq \frac{1}{2a} \\
  246. x_1 = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} &\text{if } x_P \neq x_S
  247. \end{cases}
  248. \end{align*}
  249. I call this function $S_2: \Set{\text{Quadratic functions}} \times \mdr^2 \rightarrow \mathcal{P}({\mdr})$.
  250. \clearpage
  251. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  252. Now the problem isn't as simple as with constant and linear
  253. functions.
  254. If one of the minima in $S_2(P,f)$ is in $[a,b]$, this will be the
  255. shortest distance as there are no shorter distances.
  256. \todo[inline]{
  257. The following IS WRONG! Can I include it to help the reader understand the
  258. problem?}
  259. If the function (defined on $\mdr$) has only one shortest distance
  260. point $x$ for the given $P$, it's also easy: The point in $[a,b]$ that
  261. is closest to $x$ will have the sortest distance.
  262. \[\underset{x\in\mdr}{\arg \min d_{P,f}(x)} = \begin{cases}
  263. S_2(f, P) \cap [a,b] &\text{if } S_2(f, P) \cap [a,b] \neq \emptyset \\
  264. \Set{a} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x < a\\
  265. \Set{b} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x > b\\
  266. todo &\text{if } |S_2(f, P)| = 2 \text{ and } S_2(f, P) \cap [a,b] = \emptyset
  267. \end{cases}\]