%! TEX root = TA.tex
% vim: tw=50
% 15/02/2024 12PM

\begin{flashcard}[legendre-integral-formula]
\begin{theorem*}
  Let $\alpha_1, \alpha_2, \ldots, \alpha_n$ be
  the distinct roots of $p_n$ and $A_j$ the unique
  constants such that
  \[ \int_{-1}^1 P(t) \dd t = \sum_j A_j
  P(\alpha_j) \]
  for all $P \in \mathcal{P}_{n - 1}$. Then in
  fact \cloze{
  \[ \int_{-1}^1 P(t) \dd t = \sum_{j = 1}^n A_j
  P(\alpha_j) \]
  for all $P \in \mathcal{P}_{2n - 1}$.
  }
\end{theorem*}

\begin{proof}
  \cloze{Suppose $P \in \mathcal{P}_{2n - 1}$. By long
  division, write $P = Q p_n + R$ with $Q \in
  \mathcal{P}_{n - 1}$ and $R \in \mathcal{P}_{n -
  1}$. Then
  \begin{align*}
    \int_{-1}^1 P \dd t
    &= \int_{-1}^1 Q p_n + R \dd t \\
    &= \int Q p_n \dd t + \int R \dd t \\
    &= \int R \dd t
    &&\text{(since $p_n \perp Q$)} \\
    &= \sum_j A_j R(\alpha_j) \\
    &= \sum_j A_j(Q(\alpha_j) p(\alpha_j) +
    R(\alpha_j)) \\
    &= \sum_j A_j P(\alpha_j) \qedhere
  \end{align*}}
\end{proof}
\end{flashcard}

\begin{remark*}
  If $\beta_1, \ldots, \beta_n, B_1, \ldots, B_n$
  are such that
  \[ \int_{-1}^1 P(t) \dd t = \sum_j B_j P(\beta_j) \]
  for all $P \in \mathcal{P}_{2n - 1}$, then
  taking $F(t) = \prod_j (t - \beta_j)$ we have
  \begin{align*}
    \int_{-1}^1 F(t) Q(t) \dd t
    &= \sum_j B_j F(\beta_j) Q(\beta_j) \\
    &= \sum_j B_j 0 \\
    &= 0
  \end{align*}
  for all $Q \in \mathcal{P}_{n - 1}$, using the
  fact that $FQ \in \mathcal{P}_{2n - 1}$. So $F
  \perp Q$ for all $Q \in \mathcal{P}_{n - 1}$. So
  $F$ is a scalar multiple of $p_n$, so
  $\{\beta_1, \ldots, \beta_n\} = \{\alpha_1,
  \ldots, \alpha_n\}$.
\end{remark*}

\begin{flashcard}[main-point-legendre-approx]
This is \emph{not} the main point. The key
observation is that for $\alpha$ the zeroes of
$p_n$ and $A_j$ as before, we have:
\begin{enumerate}[(1)]
  \item \cloze{$A_j > 0$}
  \item \cloze{(less important) $\sum_j A_j =
  2$.}
\end{enumerate}
  
\begin{proof}
  \phantom{}
  \cloze{\begin{enumerate}[(1)]
    \item Consider $Q_j(t) = \prod_{i \neq j} (t -
      \alpha_i)^2$. $Q_j$ is non-constant and
      positive, so $\int Q > 0$ and $Q \in
      \mathcal{P}_{2n - 2} \subseteq
      \mathcal{P}_{2n - 1}$. So
      \[ 0 < \int_{-1}^1 Q_j(t) \dd t = \sum_i
      A_iQ_i(\alpha_j) = A_j Q(\alpha_j) \]
      so $A_j > 0$.
    \item $2 = \int_{-1}^1 1 \dd t = \sum_{j =
      1}^n A_j$. \qedhere
  \end{enumerate}}
\end{proof}
\end{flashcard}

\begin{corollary*}
  If $f \in C[-1, 1]$ and $\|P - f\|_\infty \le
  \eps$, $P \in \mathcal{P}_{2n - 1}$. Then
  \[ \left| \int_{-1}^1 f(t) \dd t - \sum_j A_j
  f(\alpha_j) \right| \le 4\eps .\]
\end{corollary*}

\begin{proof}
  \begin{align*}
    \left| \int f - \sum_j A_j f(\alpha_j) \right|
    &= \left| \int f - \int P + \sum A_j
    P(\alpha_j) - \sum A_j f(\alpha_j) \right| \\
    &\le \left| \int_{-1}^1 (f - P) \right| +
    \sum |A_j| |P(\alpha_j) - f(\alpha_j)| \\
    &\le 2\|f - P\|_\infty + 2\|f - P\|_\infty \\
    &= 4\|f - P\|_\infty \\
    &\le 4\eps \qedhere
  \end{align*}
\end{proof}

\begin{corollary*}
  By Weierstrass's theorem, Gaussian interpolation
  of higher and higher degree converges to the
  correct answer.
\end{corollary*}

\newpage
\section{Hausdorff Metric (and simpler things)}

[ALL SETS IN THIS SECTION ARE NON-EMPTY UNLESS
OTHERWISE STATED].

Recall in $\RR^n$, if $A$ is closed and non-empty,
then
\[ d(\bf{x}, A) = \inf_{\bf{a} \in A} \|\bf{x} -
\bf{a}\| \]
is well-defined and $\bf{x} \mapsto d(\bf{x}, A)$
is continuous.

\begin{proof}[Proof of continuity]
  If $\bf{x}, \bf{y}$ given. For any $\eps > 0$,
  there exists $\bf{a} \in A$ such that $\|\bf{x}
  - \bf{a}\| \le \eps + d(\bf{x}, A)$. Then
  \[ \|\bf{y} - \bf{a}\| \le \|\bf{x} - \bf{y}\| +
  \|\bf{x} - \bf{a}\|\| \le \|\bf{x} - \bf{y}\| +
  \eps + d(x, A) .\]
  $\eps$ is arbitrary, so $\|\bf{y} - \bf{a}\| \le
  \|x - y\| + d(x, A)$. So
  \[ d(y, A) \le d(x, y) + d(x, A) .\]
  Similarly
  \[ d(x, A) \le d(x, y) + d(y, A) \]
  so
  \[ |d(x, A) - d(y, A)| \le d(x, y) . \qedhere \]
\end{proof}

Thus for example there exists $\bf{a}_x \in A$
such that $\|\bf{x} - \bf{a}_x\| = d(x, A)$.

\begin{proof}
  Choose $R \gg 0$ such that $\ol{B(\bf{x}, R)}
  \cap A \neq \emptyset$. $A \cap \ol{B(x, R)}$ is
  compact, so $d(x, A)$ attains a minimum, and
  this must be a global minimum (if $R$ is
  sufficiently large).
\end{proof}

The closest point is not necessarily unique. For
example, $A = \{a : \|a\| = 1\}$, $x = 0$. If $A$
is convex, then the nearest point is unique.
Suppose $a, b \in A$, $d(x, a) = d(x, b) = d(x,
A)$. Then $\frac{a + b}{2} \in A$ and
\[ d(x, \frac{a + b}{2}) < d(x, a) \]
unless $a = b$.
\begin{center}
  \includegraphics[width=0.6\linewidth]{images/e393758171c54e28.png}
\end{center}

We now investigate if we can find a metric to
compare compact non-empty subsets of $\RR^n$.

Recall the required properties of a metric:
\begin{itemize}
  \item $d(x, y) \ge 0$
  \item $d(x, y) = 0 \iff x = 0$
  \item $d(x, y) = d(y, x)$
  \item $d(x, y) + d(y, z) \ge d(x, z)$.
\end{itemize}

First try
\[ \tau(A, B) = \inf_{a \in A} d(\bf{a}, B) \]
This satisfies $\tau(A, B) \ge 0$, but fails at
the second hurdle:
\begin{align*}
  \tau(A, B) = 0
  &\iff \exists a \in A \cap B \\
  &\iff A \cap B \neq \emptyset
\end{align*}
We will end up using
\[ \sigma(A, B) = \sup_{a \in A} d(a, B) \]
