diff --git a/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.pdf b/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.pdf new file mode 100644 index 0000000..6f1a751 Binary files /dev/null and b/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.pdf differ diff --git a/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.tex b/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.tex index cb6fc00..4e92fef 100644 --- a/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.tex +++ b/documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.tex @@ -15,6 +15,7 @@ \usepackage[framed,amsmath,thmmarks,hyperref]{ntheorem} \usepackage{framed} \usepackage{nicefrac} +\usepackage{siunitx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Define theorems % @@ -334,7 +335,7 @@ Because: Then move $f_1$ and $P_1$ by $\frac{b^2}{4a}-c$ in $y$ direction. You get: \[f_2(x) = ax^2\;\;\;\text{ and }\;\;\; P_2 = \left (x_p+\frac{b}{2a},\;\; y_p+\frac{b^2}{4a}-c \right )\] -As $f_2(x) = ax^2$ is symmetric to the $y$ axis, only points +\textbf{Case 1:} As $f_2(x) = ax^2$ is symmetric to the $y$ axis, only points $P = (0, w)$ could possilby have three minima. Then compute: @@ -353,8 +354,43 @@ should get as close to $0$ as possilbe when we want to minimize $d_{P,{f_2}}$. For $w \leq \nicefrac{1}{2a}$ you only have $x = 0$ as a minimum. For all other points $P = (0, w)$, there are exactly two minima $x_{1,2} = \pm \sqrt{aw - \nicefrac{1}{2}}$. -So the solution is given by +\textbf{Case 2:} $P = (z, w)$ is not on the symmetry axis, so $z \neq 0$. Then you compute: +\begin{align} + d_{P,{f_2}}(x) &= \sqrt{(x-z)^2 + (f(x)-w)^2}\\ + &= \sqrt{(x^2 - 2zx + z^2) + ((ax^2)^2 - 2 awx^2 - w^2)}\\ + &= \sqrt{a^2x^4 + (1- 2 aw)x^2 +(- 2z)x + z^2 - w^2}\\ + 0 &\stackrel{!}{=} d_{P, {f_2}}'(x) \\ + &= 4a^2x^3 + 2(1- 2 aw)x +(- 2z)\\ + &= 2 \left (2a^2x^2 + (1- 2 aw) \right )x - 2z\\ + \Leftrightarrow z &\stackrel{!}{=} (2a^2x^2 + (1- 2 aw)) x\\ + \Leftrightarrow 0 &\stackrel{!}{=} 2 a^2 x^3 + (1- 2 aw)x - z\label{line:solution-equation} +\end{align} +The solution for this equation was computated with Wolfram|Alpha. +I will only verify that the solution is correct. As there is only +one solution in this case, we only have to check this one. + +\begin{align} + t &:= \sqrt[3]{108a^4z + \sqrt{\num{11664}a^8 z^2 + 864 a^6 (1-2aw)^3}}\\ + x &= \frac{t}{6 \sqrt[3]{2} a^2} - \frac{\sqrt[3]{2}(1-2aw)}{t}\\ + \xRightarrow{x \text{ in line }\ref{line:solution-equation}} 0 &\stackrel{!}{=} 2a^2 \left ( \frac{t}{6 \sqrt[3]{2} a^2} - \frac{\sqrt[3]{2}(1-2aw)}{t} \right )^3 + (1-2aw) (\frac{t}{6 \sqrt[3]{2} a^2} - \frac{\sqrt[3]{2}(1-2aw)}{t}) - z\\ + &= 2a^2 \underbrace{\left ( \frac{t}{6 \sqrt[3]{2} a^2} - \frac{\sqrt[3]{2}(1-2aw)}{t} \right )^3}_{=: \alpha} + \frac{t \cdot (1-2aw)}{6 \sqrt[3]{2} a^2} - \frac{\sqrt[3]{2} (1-2aw)^2}{t} - z +\end{align} + +Now compute $\alpha$. We know that $(a-b)^3 = a^3 - 3a^2 b +3ab^2 - b^3$: +\begin{align} + \alpha &= \left (\frac{t}{6 \sqrt[3]{2} a^2} \right )^3 - 3 \left (\frac{t}{6 \sqrt[3]{2} a^2} \right )^2 \left (\frac{\sqrt[3]{2}(1-2aw)}{t} \right ) + 3 \left (\frac{t}{6 \sqrt[3]{2} a^2} \right ) \left (\frac{\sqrt[3]{2}(1-2aw)}{t} \right )^2 - \left (\frac{\sqrt[3]{2}(1-2aw)}{t} \right )^3\\ + &= \frac{t^3}{216 \cdot 2 \cdot a^6} - \frac{3t^2}{36 \sqrt[3]{4} a^4} \cdot \frac{\sqrt[3]{2}(1-2aw)}{t} + + \frac{3t}{6 \sqrt[3]{2} a^2} \cdot \frac{\sqrt[3]{4} (1-2aw)^2}{t^2} - \frac{2 (1-2aw)^3}{t^3}\\ + &= \frac{t^3}{432a^6} - \frac{t (1-2aw)}{12\sqrt[3]{2} a^4} + \frac{\sqrt[3]{2} (1-2aw)^2}{2ta^2} - \frac{2 (1-2aw)^3}{t^3}\\ + &= \frac{t^3}{432a^6} + \frac{t^2 (2aw-1) + 6 \sqrt[3]{4} a^2 (1-2aw)^2}{12\sqrt[3]{2} a^4} - \frac{2 (1-2aw)^3}{t^3}\\ + &= \frac{t^3- 2 (1-2aw)^3 \cdot 432a^6}{432a^6 t^3} + \frac{t^2 (2aw-1) + 6 \sqrt[3]{4} a^2 (1-2aw)^2}{12\sqrt[3]{2} a^4}\\ + &= \frac{\sqrt[3]{2}(t^3- 2 (1-2aw)^3 \cdot 432a^6) + 36 a^2 t^3 (t^2 (2aw-1) + 6 \sqrt[3]{4} a^2 (1-2aw)^2)}{432 \sqrt[3]{2} a^6 t^3}\\ + &= \frac{\sqrt[3]{2} t^3 - \sqrt[3]{2} (1-2aw)^3 \cdot 864a^6 + 36 a^2 t^3 (2awt^1-t^2 + 6 \sqrt[3]{4} a^2 (1-2aw)^2)}{6 \sqrt[3]{2} a^2 t \cdot 2a^2 \cdot 36 a^2 t^2} +\end{align} + +\goodbreak +So the solution is given by \begin{align*} x_S &:= - \frac{b}{2a} \;\;\;\;\; \text{(the symmetry axis)}\\ \underset{x\in\mdr}{\arg \min d_{P,f}(x)} &= \begin{cases} @@ -459,6 +495,68 @@ $\tilde{e}$. This means, that there is no solution formula for the problem of finding the closest points on a cubic function to a given point. +\subsection{Another approach} +Just like we moved the function $f$ and the point to get in a +nicer situation, we can apply this approach for cubic functions. + +\begin{figure}[htp] + \centering +\begin{tikzpicture} + \begin{axis}[ + legend pos=south east, + axis x line=middle, + axis y line=middle, + grid = major, + width=0.8\linewidth, + height=8cm, + grid style={dashed, gray!30}, + xmin=-3, % start the diagram at this x-coordinate + xmax= 3, % end the diagram at this x-coordinate + ymin=-3, % start the diagram at this y-coordinate + ymax= 3, % end the diagram at this y-coordinate + axis background/.style={fill=white}, + xlabel=$x$, + ylabel=$y$, + %xticklabels={-2,-1.6,...,7}, + %yticklabels={-8,-7,...,8}, + tick align=outside, + minor tick num=-3, + enlargelimits=true, + tension=0.08] + \addplot[domain=-3:3, thick,samples=50, red] {x*x*x}; + \addplot[domain=-3:3, thick,samples=50, green] {x*x*x+x}; + \addplot[domain=-3:3, thick,samples=50, orange] {x*x*x-x}; + \addplot[domain=-3:3, thick,samples=50, blue, dotted] {x*x*x+2*x}; + \addplot[domain=-3:3, thick,samples=50, lime, dashed] {x*x*x+3*x}; + \addlegendentry{$f_1(x)=x^3$} + \addlegendentry{$f_2(x)=x^3 + x$} + \addlegendentry{$f_1(x)=x^3 - x$} + \addlegendentry{$f_2(x)=x^3 + 2 \cdot x$} + \addlegendentry{$f_2(x)=x^3 + 3 \cdot x$} + \end{axis} +\end{tikzpicture} + \caption{Cubic functions with $b = d = 0$} +\end{figure} + +First, we move $f_0$ by $\frac{b}{3a}$ to the right, so + +\[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)\] + +because + +\begin{align} + 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\\ + &= a \left (x^3 - 3 \frac{b}{3a}x^2 + 3 (\frac{b}{3a})^2 x - \frac{b^3}{27a^3} \right ) + +b \left (x^2 - \frac{2b}{3a} x + \frac{b^2}{9a^2} \right ) + +c x - \frac{bc}{3a} + d\\ + &= ax^3 - bx^2 + \frac{b^2}{3a}x - \frac{b^3}{27 a^2}\\ + & \;\;\;\;\;\;+ bx^2 - \frac{2b^2}{3a}x + \frac{b^3}{9a^2}\\ + & \;\;\;\;\;\;\;\;\;\;\;\; + c x - \frac{bc}{3a} + d\\ + &= 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 +\end{align} + +\todo[inline]{Which way to move might be clever?} + \subsection{Number of points with minimal distance} As there is an algebraic equation of degree 5, there cannot be more than 5 solutions.