quadratic-functions.tex 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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:fermats-theorem}:\nobreak
  44. \begin{align}
  45. 0 &\overset{!}{=} (d_{P,f}^2)'\\
  46. &= 2x -2 x_p -2y_p f'(x) + \left (f(x)^2 \right )'\\
  47. &= 2x -2 x_p -2y_p f'(x) + 2 f(x) \cdot f'(x) \rlap{\hspace*{3em}(chain rule)}\label{eq:minimizingFirstDerivative}\\
  48. \Leftrightarrow 0 &\overset{!}{=} x -x_p -y_p f'(x) + f(x) \cdot f'(x) \rlap{\hspace*{3em}(divide by 2)}\label{eq:minimizingFirstDerivative}\\
  49. &= x -x_p -y_p (2ax+b) + (ax^2+bx+c)(2ax+b)\\
  50. &= x -x_p -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 -x_p -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:fermats-theorem}
  58. has to be a solution to the given problem.
  59. \goodbreak
  60. \begin{example}\label{ex:false-positive}
  61. Let $a = 1, b = 0, c= 1, x_p= 0, y_p = 1$.
  62. So $f(x) = x^2 - 1$ and $P(0, 1)$.
  63. \begin{align}
  64. \xRightarrow{\text{Equation}~\ref{eq:quadratic-derivative-eq-0}} 0 &\stackrel{!}{=} 2x^3 - 3x\\
  65. &= x(2x^2-3)\\
  66. \Rightarrow x_{1,2} &= \pm \sqrt{\frac{3}{2}} \text{ and } x_3 = 0\\
  67. d_{P,f}(x_3) &= \sqrt{0^2 + (-1-1)^2} = 2\\
  68. d_{P,f} \left (\pm \sqrt{\frac{3}{2}} \right ) &= \sqrt{\left (\sqrt{\frac{3}{2} - 0} \right )^2 + \left (\frac{1}{2}-1 \right )^2}\\
  69. &= \sqrt{\nicefrac{3}{2}+\nicefrac{1}{4}} \\
  70. &= \sqrt{\nicefrac{7}{4}}\\
  71. \end{align}
  72. This means $x_3$ is not a point of minimal distance, although
  73. $(d_{P,f}(x_3))' = 0$.
  74. \end{example}
  75. \subsection{Number of points with minimal distance}
  76. \begin{theorem}
  77. A point $P$ has either one or two points on the graph of a
  78. quadratic function $f$ that are closest to $P$.
  79. \end{theorem}
  80. \begin{proof}
  81. The number of closests points of $f$ cannot be bigger than 3, because
  82. Equation~\ref{eq:quadratic-derivative-eq-0} is a polynomial function
  83. of degree 3. Such a function can have at most 3 roots.
  84. In the following, I will do some transformations with $f = f_0$ and
  85. $P = P_0$.
  86. Moving $f_0$ and $P_0$ simultaneously in $x$ or $y$ direction does
  87. not change the minimum distance. Furthermore, we can find the
  88. points with minimum distance on the moved situation and calculate
  89. the minimum points in the original situation.
  90. First of all, we move $f_0$ and $P_0$ by $\frac{b}{2a}$ in $x$ direction, so
  91. \[f_1(x) = ax^2 - \frac{b^2}{4a} + c \;\;\;\text{ and }\;\;\; P_1 = \left (x_p+\frac{b}{2a},\;\; y_p \right )\]
  92. Because:\footnote{The idea why you subtract $\frac{b}{2a}$ within
  93. $f$ is that when you subtract something from $x$ before applying
  94. $f$ it takes more time ($x$ needs to be bigger) to get to the same
  95. situation. In consequence, if we want to move the whole graph by 1
  96. to the left, we have to add $+1$.}
  97. \begin{align}
  98. f(x-\nicefrac{b}{2a}) &= a (x-\nicefrac{b}{2a})^2 + b (x-\nicefrac{b}{2a}) + c\\
  99. &= a (x^2 - \nicefrac{b}{a} x + \nicefrac{b^2}{4a^2}) + bx - \nicefrac{b^2}{2a} + c\\
  100. &= ax^2 - bx + \nicefrac{b^2}{4a} + bx - \nicefrac{b^2}{2a} + c\\
  101. &= ax^2 -\nicefrac{b^2}{4a} + c
  102. \end{align}
  103. Then move $f_1$ and $P_1$ by $\frac{b^2}{4a}-c$ in $y$ direction. You get:
  104. \[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 )\]
  105. As $f_2(x) = ax^2$ is symmetric to the $y$ axis, only points
  106. $P = (0, w)$ could possilby have three minima.
  107. Then compute:
  108. \begin{align}
  109. d_{P,{f_2}}(x) &= \sqrt{(x-0)^2 + (f_2(x)-w)^2}\\
  110. &= \sqrt{x^2 + (ax^2-w)^2}\\
  111. &= \sqrt{x^2 + a^2 x^4-2aw x^2+w^2}\\
  112. &= \sqrt{a^2 x^4 + (1-2aw) x^2 + w^2}\\
  113. &= \sqrt{\left (a x^2 + \frac{1-2 a w}{2a} \right )^2 + w^2 - \left (\frac{1-2 a w}{2a} \right )^2}\\
  114. &= \sqrt{\left (a x^2 + \nicefrac{1}{2a}- w \right )^2 + \left (w^2 - \left (\frac{1-2 a w}{2a} \right )^2 \right)}
  115. \end{align}
  116. The term
  117. \[a^2 x^2 + (\nicefrac{1}{2a}- w)\]
  118. should get as close to $0$ as possilbe when we want to minimize
  119. $d_{P,{f_2}}$. For $w \leq \nicefrac{1}{2a}$ you only have $x = 0$ as a minimum.
  120. For all other points $P = (0, w)$, there are exactly two minima $x_{1,2} = \pm \sqrt{\frac{\frac{1}{2a} - w}{a}}$.
  121. $\qed$
  122. \end{proof}
  123. \subsection{Solution formula}
  124. We start with the graph that was moved so that $f_2 = ax^2$.
  125. \textbf{Case 1:} $P$ is on the symmetry axis, hence $x_P = - \frac{b}{2a}$.
  126. In this case, we have already found the solution. If $w = y_P + \frac{b^2}{4a} - c > \frac{1}{2a}$,
  127. then there are two solutions:
  128. \[x_{1,2} = \pm \sqrt{\frac{\frac{1}{2a} - w}{a}}\]
  129. Otherwise, there is only one solution $x_1 = 0$.
  130. \textbf{Case 2:} $P = (z, w)$ is not on the symmetry axis, so $z \neq 0$. Then you compute:
  131. \begin{align}
  132. d_{P,{f_2}}(x) &= \sqrt{(x-z)^2 + (f(x)-w)^2}\\
  133. &= \sqrt{(x^2 - 2zx + z^2) + ((ax^2)^2 - 2 awx^2 + w^2)}\\
  134. &= \sqrt{a^2x^4 + (1- 2 aw)x^2 +(- 2z)x + z^2 + w^2}\\
  135. 0 &\stackrel{!}{=} \Big(\big(d_{P, {f_2}}(x)\big)^2\Big)' \\
  136. &= 4a^2x^3 + 2(1- 2 aw)x +(- 2z)\\
  137. &= 2 \left (2a^2x^2 + (1- 2 aw) \right )x - 2z\\
  138. \Leftrightarrow 0 &\stackrel{!}{=} 2a^2x^3 + (1- 2 aw) x - z\\
  139. \Leftrightarrow 0 &\stackrel{!}{=} x^3 + \underbrace{\frac{1- 2 aw}{2 a^2}}_{=: \alpha} x + \underbrace{\frac{-z}{2 a^2}}_{=: \beta}\\
  140. &= x^3 + \alpha x + \beta\label{eq:simple-cubic-equation-for-quadratic-distance}
  141. \end{align}
  142. Let $t$ be defined as
  143. \[t := \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\]
  144. I will make use of the following identities:
  145. \begin{align*}
  146. (1-i \sqrt{3})^2 &= -2 (1+i \sqrt{3})\\
  147. (1+i \sqrt{3})^2 &= -2 (1-i \sqrt{3})\\
  148. (1 \pm i \sqrt{3})^3 &= -8
  149. \end{align*}
  150. \textbf{Case 2.1:}
  151. \input{quadratic-case-2.1}
  152. \goodbreak
  153. \textbf{Case 2.2:}
  154. \input{quadratic-case-2.2}
  155. \textbf{Case 2.3:}
  156. \input{quadratic-case-2.3}
  157. \goodbreak
  158. So the solution is given by
  159. \todo[inline]{NO! Currently, there are erros in the solution.
  160. Check $f(x) = x^2$ and $P=(-2,4)$. Solution should be $x_1 = -2$, but it isn't!}
  161. \begin{align*}
  162. x_S &:= - \frac{b}{2a} \;\;\;\;\; \text{(the symmetry axis)}\\
  163. w &:= y_P+\frac{b^2}{4a}-c \;\;\; \text{ and } \;\;\; z := x_P+\frac{b}{2a}\\
  164. \alpha &:= \frac{1- 2 aw}{2 a^2} \;\;\;\text{ and }\;\;\; \beta := \frac{-z}{2 a^2}\\
  165. t &:= \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\\
  166. \underset{x\in\mdr}{\arg \min d_{P,f}(x)} &= \begin{cases}
  167. 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} \\
  168. x_2 = -\sqrt{a (y_p + \frac{b^2}{4a} - c) - \frac{1}{2}} + x_S\\
  169. x_1 = x_S &\text{if } x_P = x_S \text{ and } y_p + \frac{b^2}{4a} - c \leq \frac{1}{2a} \\
  170. x_1 = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} &\text{if } x_P \neq x_S
  171. \end{cases}
  172. \end{align*}
  173. I call this function $S_2: \Set{\text{Quadratic functions}} \times \mdr^2 \rightarrow \mathcal{P}({\mdr})$.
  174. \clearpage
  175. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  176. Now the problem isn't as simple as with constant and linear
  177. functions.
  178. If one of the minima in $S_2(P,f)$ is in $[a,b]$, this will be the
  179. shortest distance as there are no shorter distances.
  180. \todo[inline]{
  181. The following IS WRONG! Can I include it to help the reader understand the
  182. problem?}
  183. If the function (defined on $\mdr$) has only one shortest distance
  184. point $x$ for the given $P$, it's also easy: The point in $[a,b]$ that
  185. is closest to $x$ will have the sortest distance.
  186. \[\underset{x\in[a,b]}{\arg \min d_{P,f}(x)} = \begin{cases}
  187. S_2(f, P) \cap [a,b] &\text{if } S_2(f, P) \cap [a,b] \neq \emptyset \\
  188. \Set{a} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x < a\\
  189. \Set{b} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x > b\\
  190. todo &\text{if } |S_2(f, P)| = 2 \text{ and } S_2(f, P) \cap [a,b] = \emptyset
  191. \end{cases}\]