cubic-functions.tex 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. \chapter{Cubic functions}
  2. \section{Defined on $\mdr$}
  3. Let $f:\mdr \rightarrow \mdr, f(x) = a \cdot x^3 + b \cdot x^2 + c \cdot x + d$
  4. be a cubic function with $a \in \mdr \setminus \Set{0}$ and
  5. $b, c, d \in \mdr$.
  6. \begin{figure}[htp]
  7. \centering
  8. \begin{tikzpicture}
  9. \begin{axis}[
  10. legend pos=south east,
  11. axis x line=middle,
  12. axis y line=middle,
  13. grid = major,
  14. width=0.8\linewidth,
  15. height=8cm,
  16. grid style={dashed, gray!30},
  17. xmin=-3, % start the diagram at this x-coordinate
  18. xmax= 3, % end the diagram at this x-coordinate
  19. ymin=-3, % start the diagram at this y-coordinate
  20. ymax= 3, % end the diagram at this y-coordinate
  21. axis background/.style={fill=white},
  22. xlabel=$x$,
  23. ylabel=$y$,
  24. tick align=outside,
  25. minor tick num=-3,
  26. enlargelimits=true,
  27. tension=0.08]
  28. \addplot[domain=-3:3, thick,samples=50, red] {x*x*x};
  29. \addplot[domain=-3:3, thick,samples=50, green] {x*x*x+x*x};
  30. \addplot[domain=-3:3, thick,samples=50, blue] {x*x*x+2*x*x};
  31. \addplot[domain=-3:3, thick,samples=50, orange] {x*x*x+x};
  32. \addlegendentry{$f_1(x)=x^3$}
  33. \addlegendentry{$f_2(x)=x^3 + x^2$}
  34. \addlegendentry{$f_2(x)=x^3 + 2 \cdot x^2$}
  35. \addlegendentry{$f_1(x)=x^3 + x$}
  36. \end{axis}
  37. \end{tikzpicture}
  38. \caption{Cubic functions}
  39. \end{figure}
  40. %
  41. %\section{Special points}
  42. %\todo[inline]{Write this}
  43. %
  44. %\section{Voronoi}
  45. %
  46. %For $b^2 \geq 3ac$
  47. %
  48. %\todo[inline]{Write this}
  49. \subsection{Calculate points with minimal distance}
  50. \begin{theorem}\label{thm:no-finite-solution}
  51. There cannot be a finite, closed form solution to the problem of finding
  52. a closest point $(x, f(x))$ to a given point $P$ when $f$ is
  53. a polynomial function of degree $3$ or higher.
  54. \end{theorem}
  55. \begin{proof}
  56. Suppose you could solve the closest point problem for arbitrary
  57. cubic functions $f = ax^3 + bx^2 + cx + d$ and arbitrary points $P = (x_P, y_P)$.
  58. Then you could solve the following problem for $x$:
  59. \begin{align}
  60. 0 &\stackrel{!}{=} \left ((d_{P,f}(x))^2 \right )'\\
  61. &=-2 x_p + 2x -2y_p(f(x))' + (f(x)^2)'\\
  62. &= 2 f(x) \cdot f'(x) - 2 y_p f'(x) + 2x - 2 x_p\\
  63. &= f(x) \cdot f'(x) - y_p f'(x) + x - x_p\\
  64. &= \underbrace{f'(x) \cdot \left (f(x) - y_p \right )}_{\text{Polynomial of degree 5}} + x - x_p
  65. \end{align}
  66. General algebraic equations of degree 5 don't have a solution formula.\footnote{TODO: Quelle}
  67. Although here seems to be more structure, the resulting algebraic
  68. equation can be almost any polynomial of degree 5:\footnote{Thanks to Peter Košinár on \href{http://math.stackexchange.com/a/584814/6876}{math.stackexchange.com} for the idea.}
  69. \begin{align}
  70. 0 &\stackrel{!}{=} f'(x) \cdot \left (f(x) - y_p \right ) + (x - x_p)\\
  71. &= \underbrace{3 a^2}_{= \tilde{a}} x^5 + \underbrace{5ab}_{= \tilde{b}}x^4 + \underbrace{2(2ac + b^2 )}_{= \tilde{c}}x^3 &+& \underbrace{3(ad+bc-ay_p)}_{= \tilde{d}} x^2 \\
  72. & &+& \underbrace{(2 b d+c^2+1-2 b y_p)}_{= \tilde{e}}x+\underbrace{c d-c y_p-x_p}_{= \tilde{f}}\\
  73. 0 &\stackrel{!}{=} \tilde{a}x^5 + \tilde{b}x^4 + \tilde{c}x^3 + \tilde{d}x^2 + \tilde{e}x + \tilde{f}
  74. \end{align}
  75. \begin{enumerate}
  76. \item For any coefficient $\tilde{a} \in \mdr_{> 0}$ of $x^5$ we can choose $a := \frac{1}{3} \sqrt{\tilde{a}}$ such that we get $\tilde{a}$.
  77. \item For any coefficient $\tilde{b} \in \mdr \setminus \Set{0}$ of $x^4$ we can choose $b := \frac{1}{5a} \cdot \tilde{b}$ such that we get $\tilde{b}$.
  78. \item With $c := -2b^2 + \frac{1}{4a} \tilde{c}$, we can get any value of $\tilde{c} \in \mdr$.
  79. \item With $d := -bc + a y_p + \frac{1}{a} \tilde{d}$, we can get any value of $\tilde{d} \in \mdr$.
  80. \item With $y_p := \frac{1}{2b}(2bd + c^2)\cdot \tilde{e}$, we can get any value of $\tilde{e} \in \mdr$.
  81. \item With $x_p := cd - c y_P+\tilde{f}$, we can get any value of $\tilde{f} \in \mdr$.
  82. \end{enumerate}
  83. The first restriction guaratees that we have a polynomial of
  84. degree 5. The second one is necessary, to get a high range of
  85. $\tilde{e}$.
  86. This means that there is no finite solution formula for the problem of
  87. finding the closest points on a cubic function to a given point,
  88. because if there was one, you could use this formula for finding
  89. roots of polynomials of degree 5. $\qed$
  90. \end{proof}
  91. \subsection{Another approach}
  92. Just like we moved the function $f$ and the point to get in a
  93. nicer situation, we can apply this approach for cubic functions.
  94. \begin{figure}[htp]
  95. \centering
  96. \begin{tikzpicture}
  97. \begin{axis}[
  98. legend pos=south east,
  99. axis x line=middle,
  100. axis y line=middle,
  101. grid = major,
  102. width=0.8\linewidth,
  103. height=8cm,
  104. grid style={dashed, gray!30},
  105. xmin=-3, % start the diagram at this x-coordinate
  106. xmax= 3, % end the diagram at this x-coordinate
  107. ymin=-3, % start the diagram at this y-coordinate
  108. ymax= 3, % end the diagram at this y-coordinate
  109. axis background/.style={fill=white},
  110. xlabel=$x$,
  111. ylabel=$y$,
  112. tick align=outside,
  113. minor tick num=-3,
  114. enlargelimits=true,
  115. tension=0.08]
  116. \addplot[domain=-3:3, thick,samples=50, red] {x*x*x};
  117. \addplot[domain=-3:3, thick,samples=50, green] {x*x*x+x};
  118. \addplot[domain=-3:3, thick,samples=50, orange] {x*x*x-x};
  119. \addplot[domain=-3:3, thick,samples=50, blue, dotted] {x*x*x+2*x};
  120. \addplot[domain=-3:3, thick,samples=50, lime, dashed] {x*x*x+3*x};
  121. \addlegendentry{$f_1(x)=x^3$}
  122. \addlegendentry{$f_2(x)=x^3 + x$}
  123. \addlegendentry{$f_1(x)=x^3 - x$}
  124. \addlegendentry{$f_2(x)=x^3 + 2 \cdot x$}
  125. \addlegendentry{$f_2(x)=x^3 + 3 \cdot x$}
  126. \end{axis}
  127. \end{tikzpicture}
  128. \caption{Cubic functions with $b = d = 0$}
  129. \end{figure}
  130. First, we move $f_0$ by $\frac{b}{3a}$ in $x$ direction, so
  131. \[f_1(x) = ax^3 + \frac{b^2 (c-1)}{3a} x + \frac{2b^3}{27 a^2} - \frac{bc}{3a} + d \;\;\;\text{ and }\;\;\;P_1 = (x_P + \frac{b}{3a}, y_P)\]
  132. because
  133. \begin{align}
  134. f_1(x) &= a \left (x - \frac{b}{3a} \right )^3 + b \left (x-\frac{b}{3a} \right )^2 + c \left (x-\frac{b}{3a} \right ) + d\\
  135. &= a \left (x^3 - 3 \frac{b}{3a}x^2 + 3 (\frac{b}{3a})^2 x - \frac{b^3}{27a^3} \right )
  136. +b \left (x^2 - \frac{2b}{3a} x + \frac{b^2}{9a^2} \right )
  137. +c x - \frac{bc}{3a} + d\\
  138. &= ax^3 - bx^2 + \frac{b^2}{3a}x - \frac{b^3}{27 a^2}\\
  139. & \;\;\;\;\;\;+ bx^2 - \frac{2b^2}{3a}x + \frac{b^3}{9a^2}\\
  140. & \;\;\;\;\;\;\;\;\;\;\;\; + c x - \frac{bc}{3a} + d\\
  141. &= ax^3 + \frac{b^2}{3a}\left (1-2+c \right )x + \frac{b^3}{9a^2} \left (1-\frac{1}{3} \right )- \frac{bc}{3a} + d
  142. \end{align}
  143. The we move it in $y$ direction by $- (\frac{2b^3}{27 a^2} - \frac{bc}{3a} + d)$:
  144. \[f_2(x) = ax^3 + \frac{b^2 (c-1)}{3a} x \;\;\;\text{ and }\;\;\;P_2 = (x_P + \frac{b}{3a}, y_P - (\frac{2b^3}{27 a^2} - \frac{bc}{3a} + d))\]
  145. Multiply everything by $\sgn(a)$:
  146. \[f_3(x) = \underbrace{|a|}_{=: \alpha}x^3 + \underbrace{\frac{b^2 (c-1)}{3|a|}}_{=: \beta} x \;\;\;\text{ and }\;\;\;P_2 = (x_P + \frac{b}{3a}, \sgn(a) (y_P - \frac{2b^3}{27 a^2} + \frac{bc}{3a} - d))\]
  147. Now the problem seems to be much simpler. The function $\alpha x^3 + \beta x$
  148. with $\alpha > 0$ is centrally symmetric to $(0, 0)$.
  149. \todo[inline]{Und weiter?}
  150. \subsection{Number of points with minimal distance}
  151. As this leads to a polynomial of degree 5 of which we have to find
  152. roots, there cannot be more than 5 solutions.
  153. \todo[inline]{Can there be 3, 4 or even 5 solutions? Examples!
  154. After looking at function graphs of cubic functions, I'm pretty
  155. sure that there cannot be 4 or 5 solutions, no matter how you
  156. chose the cubic function $f$ and $P$.
  157. I'm also pretty sure that there is no polynomial (no matter what degree)
  158. that has more than 3 solutions.}
  159. \subsection{Interpolation and approximation}
  160. \subsubsection{Quadratic spline interpolation}
  161. You could interpolate the cubic function by a quadratic spline.
  162. \subsubsection{Bisection method}
  163. \todo[inline]{TODO}
  164. \subsubsection{Newtons method}
  165. One way to find roots of functions is Newtons method. It gives an
  166. iterative computation procedure that can converge quadratically
  167. if some conditions are met:
  168. \begin{theorem}[local quadratic convergence of Newton's method\footnotemark]
  169. Let $D \subseteq \mdr^n$ be open and $f: D \rightarrow \mdr^n \in C^2(\mdr)$.
  170. Let $x^* \in D$ with $f(x^*) = 0$ and the Jaccobi-Matrix $f'(x^*)$
  171. should not be invertable when evaluated at the root.
  172. Then there is a sphere
  173. \[K := K_\rho(x^*) = \Set{x \in \mdr^n | \|x- x^*\|_\infty \leq \rho} \subseteq D\]
  174. such that $x^*$ is the only root of $f$ in $K$. Furthermore,
  175. the elements of the sequence
  176. \[ x_{n+1} = x_n - \frac{f'(x_n)}{f(x_n)}\]
  177. are for every starting value $x_0 \in K$ again in $K$ and
  178. \[\lim_{n \rightarrow \infty} x_k = x^*\]
  179. Also, there is a constant $C > 0$ such that
  180. \[\|x^* - x_{n+1} \| = C \|x^* - x_n\|^2 \text{ for } n \in \mathbb{N}_0\|\]
  181. \end{theorem}
  182. \footnotetext{Translated from German to English from lecture notes of "Numerische Mathematik für die Fachrichtung Informatik
  183. und Ingenieurwesen" by Dr. Weiß, KIT}
  184. The approach is extraordinary simple. You choose a starting value
  185. $x_0$ and compute
  186. \[x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}\]
  187. As soon as the values don't change much, you are close to a root.
  188. The problem of this approach is choosing a starting value that is
  189. close enough to the root. So we have to have a \enquote{good}
  190. initial guess.
  191. \clearpage
  192. \subsubsection{Muller's method}
  193. Muller's method was first presented by David E. Muller in 1956.
  194. \todo[inline]{Paper? Might this be worth a try?}
  195. \subsubsection{Bisection method}
  196. The idea of the bisection method is the following:
  197. Suppose you know a finite intervall $[a,b]$ in which you have
  198. exactly one root $r \in (a,b)$ with $f(r) = 0$.
  199. Then you can half that interval:
  200. \[[a, b] = \left [a, \frac{a+b}{2} \right ] \cup \left [\frac{a+b}{2}, b \right ]\]
  201. Now three cases can occur:
  202. \begin{enumerate}
  203. \item[Case 1] $f(\frac{a+b}{2})=0$: You have found the exact root.
  204. \item[Case 2] $\sgn(a) = \sgn(\frac{a+b}{2})$: Continue searching in $[\frac{a+b}{2}, b]$
  205. \item[Case 3] $\sgn(b) = \sgn(\frac{a+b}{2})$: Continue searching in $[a, \frac{a+b}{2}]$
  206. \end{enumerate}
  207. \todo[inline]{Which intervall can I choose? How would I know that there is exactly one root?}
  208. \subsubsection{Bairstow's method}
  209. Cite from Wikipedia:
  210. The algorithm first appeared in the appendix of the 1920 book "Applied Aerodynamics" by Leonard Bairstow. The algorithm finds the roots in complex conjugate pairs using only real arithmetic.
  211. [...]
  212. \todo[inline]{Find a source for the following!}
  213. A particular kind of instability is observed when the polynomial has odd degree and only one real root.
  214. \section{Defined on a closed interval $[a,b] \subseteq \mdr$}
  215. The point with minimum distance can be found by:
  216. \[\underset{x\in[a,b]}{\arg \min d_{P,f}(x)} = \begin{cases}
  217. S_3(f, P) &\text{if } S_3(f, P) \cap [a,b] \neq \emptyset\\
  218. TODO &\text{if } S_3(f, P) \cap [a,b] = \emptyset
  219. \end{cases}\]