\documentclass{lecture}

\begin{document}

\section{Counting real roots}

In this section, we will study \emph{Sturm's method} of counting
the number of roots of a separable polynomial with coefficients
in a real-closed field $L$.

\begin{lemma}
    Let $(k, \le)$ be an ordered field and let $P \in k[t]$ be a separable polynomial.
    Assume that $P$ has a root $a \in k$. Then there exists $\delta > 0$ such that
    \begin{enumerate}[(i)]
        \item for $x \in \;]a- \delta, a + \delta[$ and $x \neq a$, $P(x) \neq 0$.
        \item for $x \in \;]a, a + \delta[$, $P(x)$ and $P'(x)$ have the same sign.
        \item for $x \in \;]a- \delta, a[$, $P(x)$ and $P'(x)$ have opposite signs.
        \item for $x \in \;]0, \delta[$, $P(a+h)$ and $P(a-h)$ have opposite signs.
    \end{enumerate}
    \label{lemma:root-signs-separable}
\end{lemma}

\begin{proof}
    Since $P$ is separable and $P(a) = 0$, it follows that $P'(a) \neq 0$.
    By continuity of $P'$, there exists $\delta > 0$ such that
    $P'$ has constant sign on $] a- \delta, a + \delta[$. Suppose $P'(x) > 0$.
    Since $k$ is real-closed,
    this implies that $P$ is strictly increasing on this interval. In particular,
    $P(x) < P(a) = 0$ for $x \in \;]a - \delta, a[$
    and $P(x) > P(a) = 0$ for $x \in \;]a, a + \delta[$. The case $P'(x) < 0$ is
    similar which concludes the proof.
\end{proof}

\begin{definition}
    Let $(k, \le )$ be an ordered field. A finite sequence $(P_0, \ldots, P_n)$ of polynomials
    $P_i \in k[t]$ is called a \emph{Sturm sequence} if it satisfies the following
    properties:
    \begin{enumerate}[(i)]
        \item $P_1 = P_0'$
        \item for all $x \in k$ and $i \in \{0, \ldots, n\}$, if $P_i(x) = 0$, then
            $P_{i+1}(x) \neq 0$.
        \item for all $x \in k$ and all $i \in \{1, \ldots, n-1\} $,
            if $P_i(x) = 0$ then $P_{i-1}(x) P_{i+1}(x) < 0$.
        \item $P_n \in k^{\times}$.
    \end{enumerate}
\end{definition}

\noindent If $P \in k[t]$ is separable and $k$ has characteristic $0$, then the greatest
common divisor of $P$ and $P'$ is $1$. To determine a Bézout relation between $P$ and $P'$,
one proceeds by successive Euclidean divisions:

First set $P_0 = P$ and $P_1 = P'$, next define $P_2$ such that $P_0 = P_1 Q_1 - P_2$
and $\text{deg}(P_2) < \text{deg}(P_1)$. Inductively, this
defines $P_i = P_{i+1} Q_{i+1} - P_{i+2}$ with $\text{deg}(P_{i+2}) < \text{deg}(P_{i+1})$.
This algorithm stops after at most $\text{deg}(P_0) $ steps
with $P_{n-1} = P_n Q_n$ and $P_n \neq 0$.
Then $P_n$ is a greatest common divisor of $P = P_0$ and $P' = P_1$. Since $P$ and
$P'$ are coprime, $P_n$ is a non-zero constant.

\begin{korollar}
    The sequence of polynomials $(P_0, \ldots, P_n)$ is a Sturm sequence.
    This is called the to $P$ associated Sturm sequence.
\end{korollar}

\begin{proof}
    (i) and (iv) are clear. For (ii) observe that if there exists $x \in k$ and
    $i \in \{0, \ldots, n\} $ such that $P_i(x) = P_{i+1}(x) = 0$, then
    $P_j(x) = 0$ for all $j \ge i$ which contradicts $P_n(x) = P_n \neq 0$.
    Finally for (iii), if $P_i(x) = 0$, then $P_{i-1}(x) = - P_{i+1}(x)$, so $P_{i-1}(x)$
    and $P_{i+1}(x)$ have opposite signs.
\end{proof}

\begin{bem}
    Let $(k, \le)$ be an ordered field.
    For a finite sequence of elements $(a_0, \ldots, a_n)$ in $k$ with $a_0 \neq 0$,
    the number of \emph{sign changes} in this sequence is the number of pairs
    $(i, j)$ such that $i < j$, $a_i \neq 0$ and $a_i a_j < 0$ with either $j = i+1$ or
    $j > i+1$ and $a_{i+1} = \ldots = a_{j-1} = 0$.
\end{bem}

\begin{theorem}[Sturm's algorithm]
    Let $k$ be a real-closed field equipped with its canonical ordering and let $P \in k[t]$
    be a separable polynomial. Let $(P_0, \ldots, P_n)$ be the associated Sturm sequence.
    For all $a \in k$, we denote by $\nu(a)$ the number of sign changes
    in the sequence $(P_0(a), \ldots, P_n(a))$. Then, for all pair $a, b \in k$ such that
    $a < b$ and $P_i(a)P_i(b) \neq 0$ for all $i$, the number of roots of $P$ in the interval
    $[a, b]$ is equal to $\nu(a) - \nu(b)$.
    \label{thm:sturm}
\end{theorem}

\begin{proof}
    Let $x_1 < \ldots < x_m$ be the elements of the finite set
    \[
    E = \{ x \in \; ]a, b[  \mid \exists i \in \{0, \ldots, n\} , P_i(x) = 0\} 
    .\]
    %For all $x \in E$, we can choose $\delta > 0$ such that
    %$] x - \delta, x + \delta[ \cap E = \{x\} $, i.e.
    %$]x - \delta , x + \delta [$ contains no other root of one of the $P_i$'s.
    There exists a partition of $[a,b]$ in subintervals
    $[\alpha_j, \alpha_{j+1}]$ where $\alpha_0 = a$, $\alpha_m = b$,
    and for all $j \in \{0, \ldots, m-1\} $, $\alpha_j \not\in E$,
    $[\alpha_j, \alpha_{j+1}] \cap E = \{x_j\} $.
    Also
    \[
    \sum_{j=0}^{m-1} (\nu(\alpha_j) - \nu(\alpha_{j+1}))
    = \nu(\alpha_0) - \nu(\alpha_1) + \nu(\alpha_1) - \ldots - \nu(\alpha_m)
    = \nu(a) - \nu(b)
    .\] Thus it suffices to show that for fixed $j \in \{0, \ldots, m-1\}$, the number of roots
    of $P$ in $[\alpha_j, \alpha_{j+1}]$ is equal to $\nu(\alpha_j) - \nu(\alpha_{j+1})$.
    By construction,
    $P$ has at most one root in $[\alpha_j, \alpha_{j+1}]$, at $x_j$, thus
    we want to show
    \[
    \nu(\alpha_j) - \nu(\alpha_{j+1}) = \begin{cases}
        0 & P(x_j) \neq 0 \\
        1 & P(x_j) = 0
    \end{cases}
    .\] 
    If $P(x_j) = 0$, then $P(\alpha_j)$ and $P(\alpha_{j+1})$ must have opposite sign. Indeed,
    by \ref{lemma:root-signs-separable} $P(x_j + h) P(x_j - h) < 0$ for all $h > 0$ small
    enough, but $P$ cannot change sign on $[\alpha_j, x_j -h]$ nor on
    $[x_j + h, \alpha_{j+1}]$, for otherwise the intermediate value theorem would
    imply the existence of a root $x \neq x_j$ in $[\alpha_j, \alpha_{j+1}]$.
    So $P(\alpha_j) P(\alpha_{j+1}) < 0$.
    If $P(\alpha_j) > 0$, then $P(\alpha_{j+1}) < 0$. With $P_1 = P'$ and
    \ref{lemma:root-signs-separable}, it follows that $P_1(x) < 0$ for
    $x$ close to $x_j$. But $P_1$ cannot change sign in $[\alpha_j, \alpha_{j+1}]$,
    otherwise its root in that interval would be $x_j$. Since $P$ is separable
    and $P_1 = P'$, this is impossible. Thus $P' < 0$
    and $P$ is strictly decreasing on $[\alpha_j, \alpha_{j+1}]$. So
    the sequence of signs in the sequence
    $(P_0(\alpha_j), P_1(\alpha_j), \ldots, P_n(\alpha_j))$ starts
    with $(+, -, \ldots)$ while the one at $\alpha_{j+1}$ starts
    with $(-, -, \ldots)$. Similarly, if $P(\alpha_j) < 0$, then
    the sequences are $(-, +, \ldots)$ and $(+, +, \ldots)$. In either case,
    there is one more sign change in the sequence corresponding to $\alpha_j$,
    so $\nu(\alpha_j) - \nu(\alpha_{j+1}) = 1$.

    Now suppose $P(x_j) \neq 0$. Observe that $P_0(\alpha_j)$ and
    $P_0(\alpha_{j+1})$ have the same sign, otherwise by the intermediate value theorem
    and the construction, $P_0(x_j) = 0$. Also a difference between
    $\nu(\alpha_j)$ and $\nu(\alpha_{j+1})$ only occurs if there exists
    $i \in \{0, \ldots, n-1\} $ such that $P_i(\alpha_j) P_i(\alpha_{j+1}) < 0$. In this
    case, again by the intermediate value theorem, we have $P_i(x_j) = 0$. By the definition
    of a Sturm sequence, we have $P_{i-1}(x_j)P_{i+1}(x_j) < 0$. If $P_{i-1}(x_j) < 0$
    then $P_{i-1} < 0$ on $[\alpha_j, \alpha_{j+1}]$, because $x_j$ is
    the only possible root for $P_{i-1}$ in $[\alpha_j, \alpha_{j+1}]$,
    so $P_{i-1}$ cannot change sign on that interval. Likewise,
    $P_{i+1}$ has the same sign on $[\alpha_j, \alpha_{j+1}]$ as it does at $x_j$. Proceeding
    similarly when $P_{i-1}(x_j) > 0$, we arrive at the following possibilities
    for the sign sequences of $P_{i-1}(\alpha_j) P_i(\alpha_j)P_{i+1}(\alpha_j)$
    and $P_{i-1}(\alpha_{j+1})P_i(\alpha_{j+1})P_{i+1}(\alpha_{j+1})$:

    \begin{figure}[h!]
        \centering
        \begin{subfigure}[c]{0.4\textwidth}
        \begin{tabular}{c|c|c}
            & $P_i(\alpha_j) < 0$ & $P_i(\alpha_j) > 0$ \\ \hline
            $P_{i-1}(x_j) < 0$ & $- - +$ & $- + + $ \\ \hline
            $P_{i-1}(x_j) > 0$ & $+ - -$ & $+ + -$
        \end{tabular}
        \subcaption{Sign sequence at $\alpha_{j}$}
        \end{subfigure}
        \hspace{1cm}
        \begin{subfigure}[c]{0.4\textwidth}
        \begin{tabular}{c|c|c}
            & $P_i(\alpha_j) < 0$ & $P_i(\alpha_j) > 0$ \\ \hline
            $P_{i-1}(x_j) < 0$ & $- + +$ & $- - + $ \\ \hline
            $P_{i-1}(x_j) > 0$ & $+ + -$ & $+ - -$
        \end{tabular}
        \subcaption{Sign sequence at $\alpha_{j+1}$}
        \end{subfigure}
    \end{figure}
    Since sign sequences located in cells of the two tables corresponding to the same case have
    the same number of sign changes, equal to $1$, we see that
    $\nu(\alpha_{j}) - \nu(\alpha_{j+1}) = 0$.
\end{proof}

We deduce from the previous result, this important result:

\begin{korollar}
    Let $(k, \le )$ be an ordered field and let $L_1, L_2$ be real-closed, orderable extensions
    of $k$. Let $P \in k[t]$ be an irreducible polynomial over $k$. Then $P$ has the same
    number of roots in $L_1$ as it does in $L_2$.
    \label{lemma:number-of-roots-in-real-closed-extension}
\end{korollar}

\begin{proof}
    For a polynomial $Q = c_n t^{n} + c_{n-1} t ^{n-1} + \ldots + c_0 \in k[t]$ with
    $c_n \neq 0$, the roots
    of $Q$ in an ordered real-closed extension $L$ of $k$ are bounded by
    \begin{salign*}
    M
    = 1 + \left| \frac{c_{n-1}}{c_n} \right|_L + \ldots + \left| \frac{c_0}{c_n} \right|_L
    = 1 + \left| \frac{c_{n-1}}{c_n} \right|_k + \ldots + \left| \frac{c_0}{c_n} \right|_k
    .\end{salign*}
    Note that $M$ is independent from $L$.
    So given $P \in k[t]$ irreducible and the associated Sturm sequence
    $(P_0, P_1, \ldots, P_n)$, there exists $M \in k$ such that all roots
    of all $P_i$'s in $L$ are contained in the interval $[-M, M] \subseteq L$. Since
    $\text{char } k = 0$, $P$ is separable, by \ref{thm:sturm}
    the number of roots of $P$ in $[-M, M] \subseteq L$ is equal
    to $\nu(-M) - \nu(M)$. Since $\pm M \in k$,
    all $P_i \in k[t]$ and the ordering of $L$ extends the one of $k$, the number
    of sign changes $\nu(\pm M)$ in the sequences
    $(P_0(-M), P_1(-M), \ldots, P_n(-M))$
    and $(P_0(M), P_1(M), \ldots, P_n(M))$ does not depend on $L$.
\end{proof}

\begin{bem}
    \begin{enumerate}[(i)]
    \item 
    In particular, if $P \in k[t]$ is an arbitrary polynomial, then if $P$ has a root
    in a real-closed extension $L$ of $k$, then it has a root in all real-closed extensions of $k$.

    A polynomial with coefficients in an ordered field $(k, \le)$ might not have roots
    in any real-closed extensions of $k$.
        \item 
    There is a proof of Sturm's algorithm that does not require $P$ to
    be separable. As a consequence \ref{lemma:number-of-roots-in-real-closed-extension}
    holds for all $P \in k[t]$, not only the irreducible ones.
    \end{enumerate}
\end{bem}

\end{document}
