Pārlūkot izejas kodu

added some ideas for the case of intervalls [a,b] of R

Martin Thoma 11 gadi atpakaļ
vecāks
revīzija
d53905494b

+ 61 - 2
documents/math-minimal-distance-to-cubic-function/constant-functions.tex

@@ -1,12 +1,13 @@
 \chapter{Constant functions}
 \section{Defined on $\mdr$}
-Let $f(x) = c$ with $c \in \mdr$ be a constant function. 
+Let $f:\mdr \rightarrow \mdr$, $f(x) := c$ with $c \in \mdr$ be a constant function. 
 
 \begin{figure}[htp]
     \centering
     \begin{tikzpicture}
         \begin{axis}[
             legend pos=north west,
+            legend cell align=left,
             axis x line=middle,
             axis y line=middle,
             grid = major,
@@ -45,4 +46,62 @@ Then $(x_P,f(x_P))$ has
 minimal distance to $P$. Every other point has higher distance.
 See Figure~\ref{fig:constant-min-distance}.
 
-\section{Defined on a closed interval of $\mdr$}
+This means:
+
+\[S_0(f, P) = \Set{x_P} \text{ with } P = (x_P, y_P)\]
+\clearpage
+
+\section{Defined on a closed interval $[a,b] \subseteq \mdr$}
+Let $f:[a,b] \rightarrow \mdr$, $f(x) := c$ with $a,b,c \in \mdr$ and 
+$a \leq b$ be a constant function. 
+
+\begin{figure}[htp]
+    \centering
+    \begin{tikzpicture}
+        \begin{axis}[
+            legend pos=north west,
+            legend cell align=left,
+            axis x line=middle,
+            axis y line=middle,
+            grid = major,
+            width=0.8\linewidth,
+            height=8cm,
+            grid style={dashed, gray!30},
+            xmin=-5, % start the diagram at this x-coordinate
+            xmax= 5, % end   the diagram at this x-coordinate
+            ymin= 0, % 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$,
+            tick align=outside,
+            minor tick num=-3,
+            enlargelimits=true,
+            tension=0.08]
+          \addplot[domain=-5:-2, thick,samples=50, red] {1};
+          \addplot[domain=-1:3, thick,samples=50, green] {1.5};
+          \addplot[domain=3:5, thick,samples=50, blue, densely dotted] {3};
+          \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
+
+          \addplot[blue, mark = *, nodes near coords=$P_{h,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(3, 3)};
+          \addplot[green, mark = x, nodes near coords=$P_{g,\text{min}}$,every node near coord/.style={anchor=120}] coordinates {(2, 1.5)};
+          \addplot[red, mark = *, nodes near coords=$P_{f,\text{min}}$,every node near coord/.style={anchor=225}] coordinates {(-2, 1)};
+
+          \draw[thick, dashed] (axis cs:2,1.5) -- (axis cs:2,2);
+          \draw[thick, dashed] (axis cs:2,2) -- (axis cs:-2,1);
+          \draw[thick, dashed] (axis cs:2,2) -- (axis cs:3,3);
+          \addlegendentry{$f(x)=1, D = [-5,-2]$}
+          \addlegendentry{$g(x)=1.5, D = [-1,3]$}
+          \addlegendentry{$h(x)=3, D = [3,5]$}
+        \end{axis} 
+    \end{tikzpicture}
+    \caption{Three constant functions and their points with minimal distance}
+    \label{fig:constant-min-distance-closed-intervall}
+\end{figure}
+
+The point with minimum distance can be found by:
+\[\underset{x\in\mdr}{\arg \min d_{P,f}(x)} = \begin{cases}
+ S_0(f,P) &\text{if } S_0(f,P) \cap [a,b] \neq \emptyset \\
+  \Set{a} &\text{if } S_0(f,P) \ni x_P < a\\
+  \Set{b} &\text{if } S_0(f,P) \ni x_P > b
+    \end{cases}\]

+ 1 - 0
documents/math-minimal-distance-to-cubic-function/cubic-functions.tex

@@ -214,5 +214,6 @@ initial guess.
 
 \subsubsection{Quadratic minimization}
 \todo[inline]{TODO}
+\clearpage
 
 \section{Defined on a closed interval of $\mdr$}

+ 62 - 4
documents/math-minimal-distance-to-cubic-function/linear-functions.tex

@@ -8,6 +8,7 @@ $t \in \mdr$ be a linear function.
     \begin{tikzpicture}
         \begin{axis}[
             legend pos=north east,
+            legend cell align=left,
             axis x line=middle,
             axis y line=middle,
             grid = major,
@@ -29,7 +30,7 @@ $t \in \mdr$ be a linear function.
           \addplot[domain=-5:5, thick,samples=50, blue] {-2*x+6};
           \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
           \addlegendentry{$f(x)=\frac{1}{2}x$}
-          \addlegendentry{$g(x)=-2x+6$}
+          \addlegendentry{$f_\bot(x)=-2x+6$}
         \end{axis} 
     \end{tikzpicture}
     \caption{The shortest distance of $P$ to $f$ can be calculated by using the perpendicular}
@@ -50,9 +51,66 @@ is calculated this way:
     f(x) &= f_\bot(x)\\
     \Leftrightarrow m \cdot x + t &= - \frac{1}{m} \cdot x + \left(y_P + \frac{1}{m} \cdot x_P \right)\\
     \Leftrightarrow \left (m + \frac{1}{m} \right ) \cdot x &= y_P + \frac{1}{m} \cdot x_P - t\\
-    \Leftrightarrow x &= \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )
+    \Leftrightarrow x &= \frac{m}{m^2+1} \left ( y_P + \frac{1}{m} \cdot x_P - t \right )\label{eq:solution-of-the-linear-problem}
 \end{align}
 
-There is only one point with minimal distance. See Figure~\ref{fig:linear-min-distance}.
+There is only one point with minimal distance. I'll call the result
+from line~\ref{eq:solution-of-the-linear-problem} \enquote{solution of 
+the linear problem} and the function that gives this solution 
+$S_1(f,P)$.
 
-\section{Defined on a closed interval of $\mdr$}
+See Figure~\ref{fig:linear-min-distance}
+to get intuition about the geometry used.
+\clearpage
+
+\section{Defined on a closed interval $[a,b] \subseteq \mdr$}
+Let $f:[a,b] \rightarrow \mdr$, $f(x) := m\cdot x + t$ with $a,b,m,t \in \mdr$ and 
+$a \leq b$, $m \neq 0$  be a linear function.
+
+\begin{figure}[htp]
+    \centering
+    \begin{tikzpicture}
+        \begin{axis}[
+            legend pos=north east,
+            legend cell align=left,
+            axis x line=middle,
+            axis y line=middle,
+            grid = major,
+            width=0.8\linewidth,
+            height=8cm,
+            grid style={dashed, gray!30},
+            xmin= 0, % start the diagram at this x-coordinate
+            xmax= 5, % end   the diagram at this x-coordinate
+            ymin= 0, % 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$,
+            tick align=outside,
+            minor tick num=-3,
+            enlargelimits=true,
+            tension=0.08]
+          \addplot[domain= 2:3, thick,samples=50, red] {0.5*x};
+          \addplot[domain=-5:5, thick,samples=50, blue, dashed] {-2*x+6};
+          \addplot[domain=1:1.5, thick, samples=50, orange] {3*x-3};
+          \addplot[domain=4:5, thick, samples=50, green] {-x+5};
+          \addplot[black, mark = *, nodes near coords=$P$,every node near coord/.style={anchor=225}] coordinates {(2, 2)};
+          \draw[thick, dashed] (axis cs:2,2) -- (axis cs:1.5,1.5);
+          \draw[thick, dashed] (axis cs:2,2) -- (axis cs:4,1);
+          \addlegendentry{$f(x)=\frac{1}{2}x, D = [2,3]$}
+          \addlegendentry{$f_\bot(x)=-2x+6, D=[-5,5]$}
+          \addlegendentry{$h(x)=3x-3, D=[1,1.5]$}
+          \addlegendentry{$h(x)=-x+5, D=[4,5]$}
+        \end{axis} 
+    \end{tikzpicture}
+    \caption{Different situations when you have linear functions which
+             are defined on a closed intervall}
+    \label{fig:linear-min-distance-closed-intervall}
+\end{figure}
+
+The point with minimum distance can be found by:
+\[\underset{x\in\mdr}{\arg \min d_{P,f}(x)} = \begin{cases}
+ S_1(f, P) &\text{if } S_1(f, P) \cap [a,b] \neq \emptyset\\
+   \Set{a} &\text{if } S_1(f, P) \ni x < a\\
+   \Set{b} &\text{if } S_1(f, P) \ni x > b
+    \end{cases}\]

BIN
documents/math-minimal-distance-to-cubic-function/math-minimal-distance-to-cubic-function.pdf


+ 8 - 0
documents/math-minimal-distance-to-cubic-function/problem-description.tex

@@ -19,3 +19,11 @@ But minimizing $d_{P,f}$ is the same as minimizing $d_{P,f}^2$:
 
     Then: $f'(x_0) = 0$.
 \end{theorem}
+
+Let $S_n$ be the function that returns the set of solutions for a
+polynomial of degree $n$ and a point:
+
+\[S_n: \Set{\text{Polynomials of degree } n \text{ defined on } \mdr} \times \mdr^2 \rightarrow \mathcal{P}({\mdr})\]
+\[S_n(f, P) := \underset{x\in\mdr}{\arg \min d_{P,f}(x)}\]
+
+If possible, I will explicitly give this function.

+ 27 - 4
documents/math-minimal-distance-to-cubic-function/quadratic-functions.tex

@@ -56,9 +56,9 @@ We use Theorem~\ref{thm:required-extremum-property}:\nobreak
 
 This is an algebraic equation of degree 3.
 There can be up to 3 solutions in such an equation. Those solutions
-can be found with a closed formula.
-
-\todo[inline]{Where are those closed formulas?}
+can be found with a closed formula. But not every solution of the
+equation given by Theorem~\ref{thm:required-extremum-property}
+has to be a solution to the given problem.
 
 \begin{example}
     Let $a = 1,  b = 0,  c= 1, x_p= 0, y_p = 1$.
@@ -204,4 +204,27 @@ t &:= \sqrt[3]{\sqrt{3 \cdot (4 \alpha^3 + 27 \beta^2)} -9\beta}\\
     \end{cases}
 \end{align*}
 
-\section{Defined on a closed interval of $\mdr$}
+I call this function $S_2: \Set{\text{Quadratic functions}} \times \mdr^2 \rightarrow \mathcal{P}({\mdr})$.  
+\clearpage
+
+\section{Defined on a closed interval $[a,b] \subseteq \mdr$}
+Now the problem isn't as simple as with constant and linear
+functions.
+
+If one of the minima in $S_2(P,f)$ is in $[a,b]$, this will be the
+shortest distance as there are no shorter distances.
+
+\todo[inline]{
+The following IS WRONG! Can I include it to help the reader understand the 
+problem?}
+
+If the function (defined on $\mdr$) has only one shortest distance
+point $x$ for the given $P$, it's also easy: The point in $[a,b]$ that
+is closest to $x$ will have the sortest distance. 
+
+\[\underset{x\in\mdr}{\arg \min d_{P,f}(x)} = \begin{cases}
+ S_2(f, P) \cap [a,b] &\text{if } S_2(f, P) \cap [a,b] \neq \emptyset \\
+              \Set{a} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x < a\\
+              \Set{b} &\text{if } |S_2(f, P)| = 1 \text{ and } S_2(f, P) \ni x > b\\
+                 todo &\text{if } |S_2(f, P)| = 2 \text{ and } S_2(f, P) \cap [a,b] = \emptyset
+    \end{cases}\]