quadratic-functions.tex 9.8 KB

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