quadratic-functions.tex 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. In the following, I will do some transformations with $f = f_0$ and
  75. $P = P_0$ .
  76. Moving $f_0$ and $P_0$ simultaneously in $x$ or $y$ direction does
  77. not change the minimum distance. Furthermore, we can find the
  78. points with minimum distance on the moved situation and calculate
  79. the minimum points in the original situation.
  80. First of all, we move $f_0$ and $P_0$ by $\frac{b}{2a}$ in $x$ direction, so
  81. \[f_1(x) = ax^2 - \frac{b^2}{4a} + c \;\;\;\text{ and }\;\;\; P_1 = \left (x_p+\frac{b}{2a},\;\; y_p \right )\]
  82. Because:\footnote{The idea why you subtract $\frac{b}{2a}$ within
  83. $f$ is that when you subtract something from $x$ before applying
  84. $f$ it takes more time ($x$ needs to be bigger) to get to the same
  85. situation. So to move the whole graph by $1$ to the left whe have
  86. to add $+1$.}
  87. \begin{align}
  88. f(x-\nicefrac{b}{2a}) &= a (x-\nicefrac{b}{2a})^2 + b (x-\nicefrac{b}{2a}) + c\\
  89. &= a (x^2 - \nicefrac{b}{a} x + \nicefrac{b^2}{4a^2}) + bx - \nicefrac{b^2}{2a} + c\\
  90. &= ax^2 - bx + \nicefrac{b^2}{4a} + bx - \nicefrac{b^2}{2a} + c\\
  91. &= ax^2 -\nicefrac{b^2}{4a} + c
  92. \end{align}
  93. Then move $f_1$ and $P_1$ by $\frac{b^2}{4a}-c$ in $y$ direction. You get:
  94. \[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 )\]
  95. \textbf{Case 1:} As $f_2(x) = ax^2$ is symmetric to the $y$ axis, only points
  96. $P = (0, w)$ could possilby have three minima.
  97. Then compute:
  98. \begin{align}
  99. d_{P,{f_2}}(x) &= \sqrt{(x-0)^2 + (f_2(x)-w)^2}\\
  100. &= \sqrt{x^2 + (ax^2-w)^2}\\
  101. &= \sqrt{x^2 + a^2 x^4-2aw x^2+w^2}\\
  102. &= \sqrt{a^2 x^4 + (1-2aw) x^2 + w^2}\\
  103. &= \sqrt{\left (a^2 x^2 + \frac{1-2 a w}{2} \right )^2 + w^2 - (1-2 a w)^2}\\
  104. &= \sqrt{\left (a^2 x^2 + \nicefrac{1}{2}-a w \right )^2 + \big (w^2 - (1-2 a w)^2 \big)}
  105. \end{align}
  106. The term
  107. \[a^2 x^2 + (\nicefrac{1}{2}-a w)\]
  108. should get as close to $0$ as possilbe when we want to minimize
  109. $d_{P,{f_2}}$. For $w \leq \nicefrac{1}{2a}$ you only have $x = 0$ as a minimum.
  110. For all other points $P = (0, w)$, there are exactly two minima $x_{1,2} = \pm \sqrt{aw - \nicefrac{1}{2}}$.
  111. \textbf{Case 2:} $P = (z, w)$ is not on the symmetry axis, so $z \neq 0$. Then you compute:
  112. \begin{align}
  113. d_{P,{f_2}}(x) &= \sqrt{(x-z)^2 + (f(x)-w)^2}\\
  114. &= \sqrt{(x^2 - 2zx + z^2) + ((ax^2)^2 - 2 awx^2 + w^2)}\\
  115. &= \sqrt{a^2x^4 + (1- 2 aw)x^2 +(- 2z)x + z^2 + w^2}\\
  116. 0 &\stackrel{!}{=} \Big(\big(d_{P, {f_2}}(x)\big)^2\Big)' \\
  117. &= 4a^2x^3 + 2(1- 2 aw)x +(- 2z)\\
  118. &= 2 \left (2a^2x^2 + (1- 2 aw) \right )x - 2z\\
  119. \Leftrightarrow 0 &\stackrel{!}{=} (2a^2x^2 + (1- 2 aw)) x - z\\
  120. &= 2 a^2 x^3 + (1- 2 aw) x - z\\
  121. \Leftrightarrow 0 &\stackrel{!}{=} x^3 + \underbrace{\frac{1- 2 aw}{2 a^2}}_{=: \alpha} x + \underbrace{\frac{-z}{2 a^2}}_{=: \beta}\\
  122. &= x^3 + \alpha x + \beta\label{eq:simple-cubic-equation-for-quadratic-distance}
  123. \end{align}
  124. The solution of Equation~\ref{eq:simple-cubic-equation-for-quadratic-distance}
  125. is
  126. \todo[inline]{Can $4 \alpha^3 + 27 \beta^2$ be negative for $\alpha=\frac{1-2aw}{2a^2}$ and $\beta = \frac{-z}{2a^2}$?}
  127. \[t := \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\]
  128. \[x = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}\]
  129. When you insert this in Equation~\ref{eq:simple-cubic-equation-for-quadratic-distance}
  130. you get:\footnote{Remember: $(a-b)^3 = a^3-3 a^2 b+3 a b^2-b^3$}
  131. \allowdisplaybreaks
  132. \begin{align}
  133. 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\\
  134. &= (\frac{t}{\sqrt[3]{18}})^3
  135. - 3 (\frac{t}{\sqrt[3]{18}})^2 \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}
  136. + 3 (\frac{t}{\sqrt[3]{18}})(\frac{\sqrt[3]{\frac{2}{3}} \alpha }{t})^2
  137. - (\frac{\sqrt[3]{\frac{2}{3}} \alpha }{t})^3
  138. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  139. &= \frac{t^3}{18}
  140. - \frac{3t^2}{\sqrt[3]{18^2}} \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}
  141. + \frac{3t}{\sqrt[3]{18}} \frac{\sqrt[3]{\frac{4}{9}} \alpha^2 }{t^2}
  142. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  143. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  144. &= \frac{t^3}{18}
  145. - \frac{\sqrt[3]{18} t \alpha}{\sqrt[3]{18^2}}
  146. + \frac{\sqrt[3]{12} \alpha^2}{\sqrt[3]{18} t}
  147. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  148. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  149. &= \frac{t^3}{18}
  150. - \frac{t \alpha}{\sqrt[3]{18}}
  151. \color{red}+ \frac{\sqrt[3]{2} \alpha^2}{\sqrt[3]{3} t} \color{black}
  152. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  153. + \color{red}\alpha \color{black} \left (\frac{t}{\sqrt[3]{18}} \color{red}- \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \color{black}\right )
  154. + \beta\\
  155. &= \frac{t^3}{18} \color{blue}- \frac{t \alpha}{\sqrt[3]{18}} \color{black}
  156. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  157. \color{blue}+ \frac{\alpha t}{\sqrt[3]{18}} \color{black}
  158. + \beta\\
  159. &= \frac{t^3}{18} - \frac{\frac{2}{3} \alpha^3 }{t^3} + \beta\\
  160. &= \frac{t^6 - 12 \alpha^3 + \beta 18 t^3}{18t^3}
  161. \end{align}
  162. Now only go on calculating with the numerator. Start with resubstituting
  163. $t$:
  164. \begin{align}
  165. 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)\\
  166. &= (\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)})^2 +(9\beta)^2 - 12 \alpha^3 -18\cdot 9\beta^2\\
  167. &= 3 \cdot (4 \alpha^3 + 27 \beta^2) -81 \beta^2 - 12 \alpha^3\\
  168. &= (4 \alpha^3 + 27 \beta^2) -27 \beta^2 - 4 \alpha^3\\
  169. &= 0
  170. \end{align}
  171. \goodbreak
  172. So the solution is given by
  173. \todo[inline]{NO! Currently, there are erros in the solution.
  174. Check $f(x) = x^2$ and $P=(-2,4)$. Solution should be $x_1 = -2$, but it isn't!}
  175. \begin{align*}
  176. x_S &:= - \frac{b}{2a} \;\;\;\;\; \text{(the symmetry axis)}\\
  177. w &:= y_P+\frac{b^2}{4a}-c \;\;\; \text{ and } \;\;\; z := x_P+\frac{b}{2a}\\
  178. \alpha &:= \frac{1- 2 aw}{2 a^2} \;\;\;\text{ and }\;\;\; \beta := \frac{-z}{2 a^2}\\
  179. t &:= \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\\
  180. \underset{x\in\mdr}{\arg \min d_{P,f}(x)} &= \begin{cases}
  181. 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} \\
  182. x_2 = -\sqrt{a (y_p + \frac{b^2}{4a} - c) - \frac{1}{2}} + x_S\\
  183. x_1 = x_S &\text{if } x_P = x_S \text{ and } y_p + \frac{b^2}{4a} - c \leq \frac{1}{2a} \\
  184. x_1 = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} &\text{if } x_P \neq x_S
  185. \end{cases}
  186. \end{align*}
  187. I call this function $S_2: \Set{\text{Quadratic functions}} \times \mdr^2 \rightarrow \mathcal{P}({\mdr})$.
  188. \clearpage
  189. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  190. Now the problem isn't as simple as with constant and linear
  191. functions.
  192. If one of the minima in $S_2(P,f)$ is in $[a,b]$, this will be the
  193. shortest distance as there are no shorter distances.
  194. \todo[inline]{
  195. The following IS WRONG! Can I include it to help the reader understand the
  196. problem?}
  197. If the function (defined on $\mdr$) has only one shortest distance
  198. point $x$ for the given $P$, it's also easy: The point in $[a,b]$ that
  199. is closest to $x$ will have the sortest distance.
  200. \[\underset{x\in\mdr}{\arg \min d_{P,f}(x)} = \begin{cases}
  201. S_2(f, P) \cap [a,b] &\text{if } S_2(f, P) \cap [a,b] \neq \emptyset \\
  202. \Set{a} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x < a\\
  203. \Set{b} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x > b\\
  204. todo &\text{if } |S_2(f, P)| = 2 \text{ and } S_2(f, P) \cap [a,b] = \emptyset
  205. \end{cases}\]