quadratic-functions.tex 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.
  57. \todo[inline]{Where are those closed formulas?}
  58. \begin{example}
  59. Let $a = 1, b = 0, c= 1, x_p= 0, y_p = 1$.
  60. So $f(x) = x^2 + 1$ and $P(0, 1)$.
  61. \begin{align}
  62. 0 &\stackrel{!}{=} 4 x^3 - 2x\\
  63. &=2x(2x^2 - 1)\\
  64. \Rightarrow x_1 &= 0 \;\;\; x_{2,3} = \pm \frac{1}{\sqrt{2}}
  65. \end{align}
  66. As you can easily verify, only $x_1$ is a minimum of $d_{P,f}$.
  67. \end{example}
  68. \subsection{Number of points with minimal distance}
  69. \begin{theorem}
  70. A point $P$ has either one or two points on the graph of a
  71. quadratic function $f$ that are closest to $P$.
  72. \end{theorem}
  73. In the following, I will do some transformations with $f = f_0$ and
  74. $P = P_0$ .
  75. Moving $f_0$ and $P_0$ simultaneously in $x$ or $y$ direction does
  76. not change the minimum distance. Furthermore, we can find the
  77. points with minimum distance on the moved situation and calculate
  78. the minimum points in the original situation.
  79. First of all, we move $f_0$ and $P_0$ by $\frac{b}{2a}$ in $x$ direction, so
  80. \[f_1(x) = ax^2 - \frac{b^2}{4a} + c \;\;\;\text{ and }\;\;\; P_1 = \left (x_p+\frac{b}{2a},\;\; y_p \right )\]
  81. Because:\footnote{The idea why you subtract $\frac{b}{2a}$ within
  82. $f$ is that when you subtract something from $x$ before applying
  83. $f$ it takes more time ($x$ needs to be bigger) to get to the same
  84. situation. So to move the whole graph by $1$ to the left whe have
  85. to add $+1$.}
  86. \begin{align}
  87. f(x-\nicefrac{b}{2a}) &= a (x-\nicefrac{b}{2a})^2 + b (x-\nicefrac{b}{2a}) + c\\
  88. &= a (x^2 - \nicefrac{b}{a} x + \nicefrac{b^2}{4a^2}) + bx - \nicefrac{b^2}{2a} + c\\
  89. &= ax^2 - bx + \nicefrac{b^2}{4a} + bx - \nicefrac{b^2}{2a} + c\\
  90. &= ax^2 -\nicefrac{b^2}{4a} + c
  91. \end{align}
  92. Then move $f_1$ and $P_1$ by $\frac{b^2}{4a}-c$ in $y$ direction. You get:
  93. \[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 )\]
  94. \textbf{Case 1:} As $f_2(x) = ax^2$ is symmetric to the $y$ axis, only points
  95. $P = (0, w)$ could possilby have three minima.
  96. Then compute:
  97. \begin{align}
  98. d_{P,{f_2}}(x) &= \sqrt{(x-0)^2 + (f_2(x)-w)^2}\\
  99. &= \sqrt{x^2 + (ax^2-w)^2}\\
  100. &= \sqrt{x^2 + a^2 x^4-2aw x^2+w^2}\\
  101. &= \sqrt{a^2 x^4 + (1-2aw) x^2 + w^2}\\
  102. &= \sqrt{\left (a^2 x^2 + \frac{1-2 a w}{2} \right )^2 + w^2 - (1-2 a w)^2}\\
  103. &= \sqrt{\left (a^2 x^2 + \nicefrac{1}{2}-a w \right )^2 + \big (w^2 - (1-2 a w)^2 \big)}
  104. \end{align}
  105. The term
  106. \[a^2 x^2 + (\nicefrac{1}{2}-a w)\]
  107. should get as close to $0$ as possilbe when we want to minimize
  108. $d_{P,{f_2}}$. For $w \leq \nicefrac{1}{2a}$ you only have $x = 0$ as a minimum.
  109. For all other points $P = (0, w)$, there are exactly two minima $x_{1,2} = \pm \sqrt{aw - \nicefrac{1}{2}}$.
  110. \textbf{Case 2:} $P = (z, w)$ is not on the symmetry axis, so $z \neq 0$. Then you compute:
  111. \begin{align}
  112. d_{P,{f_2}}(x) &= \sqrt{(x-z)^2 + (f(x)-w)^2}\\
  113. &= \sqrt{(x^2 - 2zx + z^2) + ((ax^2)^2 - 2 awx^2 + w^2)}\\
  114. &= \sqrt{a^2x^4 + (1- 2 aw)x^2 +(- 2z)x + z^2 + w^2}\\
  115. 0 &\stackrel{!}{=} \Big(\big(d_{P, {f_2}}(x)\big)^2\Big)' \\
  116. &= 4a^2x^3 + 2(1- 2 aw)x +(- 2z)\\
  117. &= 2 \left (2a^2x^2 + (1- 2 aw) \right )x - 2z\\
  118. \Leftrightarrow 0 &\stackrel{!}{=} (2a^2x^2 + (1- 2 aw)) x - z\\
  119. &= 2 a^2 x^3 + (1- 2 aw) x - z\\
  120. \Leftrightarrow 0 &\stackrel{!}{=} x^3 + \underbrace{\frac{(1- 2 aw)}{2 a^2}}_{=: \alpha} x + \underbrace{\frac{-z}{2 a^2}}_{=: \beta}\\
  121. &= x^3 + \alpha x + \beta\label{eq:simple-cubic-equation-for-quadratic-distance}
  122. \end{align}
  123. The solution of Equation~\ref{eq:simple-cubic-equation-for-quadratic-distance}
  124. is
  125. \[t := \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\]
  126. \[x = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}\]
  127. When you insert this in Equation~\ref{eq:simple-cubic-equation-for-quadratic-distance}
  128. you get:\footnote{Remember: $(a-b)^3 = a^3-3 a^2 b+3 a b^2-b^3$}
  129. \allowdisplaybreaks
  130. \begin{align}
  131. 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\\
  132. &= (\frac{t}{\sqrt[3]{18}})^3
  133. - 3 (\frac{t}{\sqrt[3]{18}})^2 \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}
  134. + 3 (\frac{t}{\sqrt[3]{18}})(\frac{\sqrt[3]{\frac{2}{3}} \alpha }{t})^2
  135. - (\frac{\sqrt[3]{\frac{2}{3}} \alpha }{t})^3
  136. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  137. &= \frac{t^3}{18}
  138. - \frac{3t^2}{\sqrt[3]{18^2}} \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t}
  139. + \frac{3t}{\sqrt[3]{18}} \frac{\sqrt[3]{\frac{4}{9}} \alpha^2 }{t^2}
  140. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  141. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  142. &= \frac{t^3}{18}
  143. - \frac{\sqrt[3]{18} t \alpha}{\sqrt[3]{18^2}}
  144. + \frac{\sqrt[3]{12} \alpha^2}{\sqrt[3]{18} t}
  145. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  146. + \alpha \left (\frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \right ) + \beta\\
  147. &= \frac{t^3}{18}
  148. - \frac{t \alpha}{\sqrt[3]{18}}
  149. \color{red}+ \frac{\sqrt[3]{2} \alpha^2}{\sqrt[3]{3} t} \color{black}
  150. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  151. + \color{red}\alpha \color{black} \left (\frac{t}{\sqrt[3]{18}} \color{red}- \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} \color{black}\right )
  152. + \beta\\
  153. &= \frac{t^3}{18} \color{blue}- \frac{t \alpha}{\sqrt[3]{18}} \color{black}
  154. - \frac{\frac{2}{3} \alpha^3 }{t^3}
  155. \color{blue}+ \frac{\alpha t}{\sqrt[3]{18}} \color{black}
  156. + \beta\\
  157. &= \frac{t^3}{18} - \frac{\frac{2}{3} \alpha^3 }{t^3} + \beta\\
  158. &= \frac{t^6 - 12 \alpha^3 + \beta 18 t^3}{18t^3}
  159. \end{align}
  160. Now only go on calculating with the numerator. Start with resubstituting
  161. $t$:
  162. \begin{align}
  163. 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)\\
  164. &= (\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)})^2 +(9\beta)^2 - 12 \alpha^3 -18\cdot 9\beta^2\\
  165. &= 3 \cdot (4 \alpha^3 + 27 \beta^2) -81 \beta^2 - 12 \alpha^3\\
  166. &= (4 \alpha^3 + 27 \beta^2) -27 \beta^2 - 4 \alpha^3\\
  167. &= 0
  168. \end{align}
  169. \goodbreak
  170. So the solution is given by
  171. \begin{align*}
  172. x_S &:= - \frac{b}{2a} \;\;\;\;\; \text{(the symmetry axis)}\\
  173. w &:= y_P+\frac{b^2}{4a}-c \;\;\; \text{ and } \;\;\; z := x_P+\frac{b}{2a}\\
  174. \alpha &:= \frac{(1- 2 aw)}{2 a^2} \;\;\;\text{ and }\;\;\; \beta := \frac{-z}{2 a^2}\\
  175. t &:= \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\\
  176. \underset{x\in\mdr}{\arg \min d_{P,f}(x)} &= \begin{cases}
  177. 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} \\
  178. x_2 = -\sqrt{a (y_p + \frac{b^2}{4a} - c) - \frac{1}{2}} + x_S\\
  179. x_1 = x_S &\text{if } x_P = x_S \text{ and } y_p + \frac{b^2}{4a} - c \leq \frac{1}{2a} \\
  180. x_1 = \frac{t}{\sqrt[3]{18}} - \frac{\sqrt[3]{\frac{2}{3}} \alpha }{t} &\text{if } x_P \neq x_S
  181. \end{cases}
  182. \end{align*}
  183. \section{Defined on a closed interval of $\mdr$}