%!TEX root = da2020-11.tex

\Chapter{11}{Hardness of Coloring}

\noindent
This week we will apply round elimination to coloring. We will show that 3-coloring paths requires $\Omega(\log^* n)$ rounds. This matches the fast coloring algorithms that we saw in Chapter~\chapterref{1}.

To prove this result, we will see how to apply round elimination to randomized algorithms. Previously round elimination was purely deterministic: a $T$-round deterministic algorithm would imply a $(T-1)$-round deterministic algorithm for the output problem. With randomized algorithms, round elimination affects the success probability of the algorithm: a $T$-round randomized algorithm implies a $(T-1)$-round randomized algorithm for the output problem with a worse success probability.

We will see how round elimination can be applied in the presence of inputs. These inputs can be, in addition to randomness, e.g.\ a coloring or an orientation of the edges. The critical property for round elimination is that there are no \emph{long range dependencies} in the input.

\section{Coloring and Round Elimination}

We begin by applying round elimination to coloring on paths, or $(2,2)$-biregular trees. For technical reasons, we also encode a consistent orientation in the coloring. That is, in addition to computing a coloring, we require that the nodes also orient the path consistently from one endpoint to the other. This is a hard problem, as we saw in the previous chapter; therefore we will assume that the input is \emph{already oriented}. We will show that $3$-coloring a path requires $\Omega(\log^* n)$ rounds \emph{even if the path is consistently oriented}.

\subsection{Encoding Coloring}

\begin{figure}
	\centering
	\includegraphics[page=\PEncodingThreeColoring,scale=0.4]{figs.pdf}
	\caption{Encoding of 3-coloring in the bipartite formalism. On top, a 3-coloring of a path fragment. Below, the corresponding 3-coloring as a bipartite locally verifiable problem. The path is assumed to be consistently oriented, so each node has an incoming and an outgoing edge. They use the regular label on the incoming edge, and the barred label on the outgoing edge. Passive nodes verify that the colors differ and have different type.} \label{fig:3col-encoding}
\end{figure}

We will study the problem of $3$-coloring the \emph{active nodes} of a $(2,2)$-biregular tree. We will say that two active nodes are \emph{adjacent} if they share a passive neighbor.

To encode the orientation, we use two versions of each color label: e.g.\ 1 and $\bar{1}$. We call these \emph{regular} and \emph{barred} labels, respectively. For 3-coloring, we have the following problem $\Pi_0 = (\Sigma_0, \collA_0, \collP_0)$:
\begin{align*}
	\Sigma_0 &= \{ 1,\bar{1},2,\bar{2},3,\bar{3} \}, \\
	\collA_0 &= \bigl\{ [ 1, \bar{1} ],\, [2,\bar{2}],\, [3,\bar{3}] \bigr\}, \\
	\collP_0 &= \bigl\{ [ 1, \bar{2}],\, [1, \bar{3}],\, [2, \bar{1}],\, [2, \bar{3}],\,[3,\bar{1}],\,[3,\bar{2}] \bigr\}.
\end{align*}
The encoding of 3-coloring is shown in Figure~\ref{fig:3col-encoding}. The active configurations ensure that each node chooses a color and an orientation of its edges: we can think of the edges labeled with $\bar{1}$, $\bar{2}$ or $\bar{3}$ as outgoing edges, and the regular labels as incoming edges. The passive configurations ensure that adjacent active nodes are properly colored and that the passive node is properly oriented (has incident labels of different types).

We will also need to define coloring with more colors. We say that a label \emph{matches} with its barred version: $1 \sim \bar{1}$, $2 \sim \bar{2}$ and so on. A label \emph{does not match} with the other labels: e.g.\ $1 \nsim \bar{2}$.

We define $c$-coloring as the following problem $\Pi = (\Sigma, \collA, \collP)$:
\begin{align*}
	\Sigma &= \{ 1,\bar{1},2,\bar{2},\dots,c,\bar{c} \}, \\
	\collA &= \bigl\{ [ x, \bar x ] \bigm| x \in \{1,2,\dots,c\} \bigr\}, \\
	\collP &= \bigl\{ [ x, \bar y ] \bigm| x, y \in \{1,2,\dots,c\},\, x \nsim \bar y \bigr\}.
\end{align*}

\subsection{Output Problem of Coloring}

We start by assuming that we have a fast algorithm that solves the $3$-coloring problem $\Pi_0$. Let us now compute the output problem $\Pi_1 = \re(\Pi_0)$ of $3$-coloring~$\Pi_0$.

Let $\Pi_1 = (\Sigma_1, \collA_1, \collP_1)$ denote the output problem. For now, we will let $\Sigma_1$ consist of all non-empty subsets of $\Sigma_0$, and prune it later.

Recall that passive configurations $\collP_0$ consist of all non-matching pairs of a regular and barred label. Therefore the active configurations in $\Pi_1$ consist of all pairs of sets such that
\begin{itemize}[noitemsep]
	\item one set consists of regular and one of barred labels, and
	\item there are no matching labels.
\end{itemize}
We get that
\[
	\collA_1 = \bigl\{ [X,Y] \bigm| X \subseteq \{1,2,3\}, Y \subseteq \{\bar{1},\bar{2},\bar{3}\}, \forall x \in X, y \in Y: x \nsim y \bigr\}.
\]

Next we make the sets maximal: when neither the regular or the barred version of a label is contained in either set, we can add the corresponding variant to either set. Thus the maximal active configurations \emph{split} the color set over their edges:
\[\begin{split}
	\collA_1 = \Bigl\{&
	\bigl[\{1\},\{\bar{2},\bar{3}\}\bigr],\,
	\bigl[\{2\},\{\bar{1},\bar{3}\}\bigr],\,
	\bigl[\{3\},\{\bar{1},\bar{2}\}\bigr],\, \\
	&\bigl[\{\bar{1}\},\{2,3\}\bigr],\,
	\bigl[\{\bar{2}\},\{1,3\}\bigr],\,
	\bigl[\{\bar{3}\},\{1,2\}\bigr]
	\Bigr\}
\end{split}\]
No label can be added to any of the configurations, and the above labels contain all active configurations.

We have the following alphabet:
\[\begin{split}
	\Sigma_1 = \bigl\{&
	\{1\}, \{2\}, \{3\}, \{1,2\},\{1,3\}, \{2,3\}, \\
	&\{\bar{1}\}, \{\bar{2}\}, \{\bar{3}\}, \{\bar{1},\bar{2}\},\{\bar{1},\bar{3}\}, \{\bar{2},\bar{3}\} \bigr\}.
\end{split}\]

Finally, the passive configurations consist of all pairs such that it is possible to pick matching regular and barred labels, forming a configuration in $\collA_0$:
\[
	\collP_1 = \bigl\{ [X,Y] \bigm| (1 \in X, \bar{1} \in Y) \vee (2 \in X, \bar{2} \in Y) \vee (3 \in X, \bar{3} \in Y) \bigr\}.
\]

\subsection{Simplification}

The output problem of 3-coloring looks much more complicated than the problem we started with. If we kept applying round elimination, it would become extremely difficult to understand the structure of the problem. Therefore we will \emph{simplify} the problem: we will map it back to a coloring with a \emph{larger number of colors}.

The intuition is the following. Assume that our original labels consist of some set of $c$ colors, and the output problem has sets of these colors as labels. Then there are at most $2^c$ different sets. If adjacent nodes have always different sets, we can treat it as a coloring with $2^c$ colors by mapping the sets to the labels $1,2,\dots, 2^c$.

Now consider the output problem of 3-coloring, $\Pi_1$. We will treat the different sets of the regular labels as the color classes. Each of them is paired with a unique set of barred labels. Enumerating all options, we rename the labels as follows to match the alphabet of $6$-coloring:
\begingroup
\allowdisplaybreaks
\begin{alignat*}{2}
	\{ 1 \} &\mapsto 1, & \quad\{\bar{2},\bar{3} \} &\mapsto \bar{1}, \\
	\{ 2 \} &\mapsto 2, & \{\bar{1},\bar{3} \} &\mapsto \bar{2}, \\
	\{ 3 \} &\mapsto 3, & \{\bar{1},\bar{2} \} &\mapsto \bar{3}, \\
	\{ 1,2 \} &\mapsto 4, & \{\bar{3}\} &\mapsto \bar{4}, \\
	\{ 1,3 \} &\mapsto 5, & \{ \bar{2} \} &\mapsto \bar{5}, \\
	\{ 2,3 \} &\mapsto 6, & \{ \bar{1} \} &\mapsto \bar{6}.
\end{alignat*}
\endgroup

Now let us verify that this is indeed a 6-coloring. After renaming, the active configurations are
\begin{align*}
	\collA_1 = \bigl\{&
	[1,\bar{1}],\,
	[2,\bar{2}],\,
	[3,\bar{3}],\, \\
	&[\bar{6},6],\,
	[\bar{5},5],\,
	[\bar{4},4]
	\bigr\}.
\end{align*}
By rearrangement we can see that these match exactly the definition of $6$-coloring. The passive configurations, before renaming, were the pairs of sets, one consisting of the regular labels and the other of the barred labels, that contained a matching label. We get that
\begin{align*}
	\collP_1
	      = {}&\bigl\{ [1, x] \bigm| x \in \{ \bar{2}, \bar{3}, \bar{6} \} \bigr\} \\
	{} \cup {}&\bigl\{ [2, x] \bigm| x \in \{ \bar{1}, \bar{3}, \bar{5} \} \bigr\} \\
	{} \cup {}&\bigl\{ [3, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{4} \} \bigr\} \\
	{} \cup {}&\bigl\{ [4, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{3}, \bar{5}, \bar{6} \} \bigr\} \\
	{} \cup {}&\bigl\{ [5, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{3}, \bar{4}, \bar{6} \} \bigr\} \\
	{} \cup {}&\bigl\{ [6, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{3}, \bar{4}, \bar{5} \} \bigr\}.
\end{align*}

We notice that these are a subset of the passive configurations of 6-coloring: colors 1, 2, and 3 cannot be paired with some of the non-matching colors. This means that $\Pi_1$ is \emph{at least as hard} to solve as 6-coloring.

We may \emph{relax} the output problem $\Pi_1$ and construct a new problem $\Pi'_1 = (\Sigma'_1, \collA'_1, \collP'_1)$ as follows:
\begingroup
\allowdisplaybreaks
\begin{align*}
 \collA'_1 = {}&\collA_1,\\
 \collP'_1
       = {}&\bigl\{ [1, x] \bigm| x \in \{ \bar{2}, \bar{3}, \bar{4}, \bar{5}, \bar{6} \} \bigr\} \\
 {} \cup {}&\bigl\{ [2, x] \bigm| x \in \{ \bar{1}, \bar{3}, \bar{4}, \bar{5}, \bar{6} \} \bigr\} \\
 {} \cup {}&\bigl\{ [3, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{4}, \bar{5}, \bar{6} \} \bigr\} \\
 {} \cup {}&\bigl\{ [4, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{3}, \bar{5}, \bar{6} \} \bigr\} \\
 {} \cup {}&\bigl\{ [5, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{3}, \bar{4}, \bar{6} \} \bigr\} \\
 {} \cup {}&\bigl\{ [6, x] \bigm| x \in \{ \bar{1}, \bar{2}, \bar{3}, \bar{4}, \bar{5} \} \bigr\}.
\end{align*}
\endgroup
Note that $\Pi'_1$ is exactly the $6$-coloring problem. As we have got that $\collA'_1 = \collA_1$ and $\collP'_1 \supseteq \collP_1$, any solution to $\Pi_1$ is also a solution to $\Pi'_1$. We conclude that if we can solve problem $\Pi_0$ in $T$ rounds, we can solve $\Pi_1 = \re(\Pi_0)$ \emph{exactly} one round faster, and we can solve its relaxation $\Pi'_1$ \emph{at least} one round faster.

\subsection{Generalizing Round Elimination for Coloring}

Let us now see how to generalize the first round elimination step. In the first step, we saw that 6-coloring is at least as easy to solve as the output problem of 3-coloring.

Now consider applying round elimination to the $c$-coloring problem. Let $\re(\Pi_0) = \Pi_1 = (\Sigma_1,\collA_1, \collP_1)$ denote the output problem of $c$-coloring $\Pi_0$.

Again, the active configurations in $\collA_1$ consist of all splits of the colors. For a set $X \subseteq \{1,2,\dots,c\}$, let $\bar{X}$ denote the \emph{barred complement of $X$}:
\[
	\bar{X} = \{ \bar{x} \bigm| x \in \{ 1,2,\dots,c\} \setminus X \}.
\]
Then the active configurations are
\[
	\collA_1 = \bigl\{ [X, \bar{X}] \bigm| \emptyset \ne X \subsetneq \{1,2,\dots,c\} \bigr\}.
\]
The labels are all non-empty and non-full subsets of the regular and barred labels, respectively. The passive configurations in $\collP_1$ consists of pairs of sets such that it is possible to pick matching regular and barred labels from them:
\[
	\collP_1 = \bigl\{ [X,Y] \bigm| x \in X, \bar{x} \in Y: x \sim \bar{x} \bigr\}.
\]
We do the exact same renaming trick as in the previous section. There are a total of $2^c - 2$ different sets on regular labels. We rename them in some order with the integers from $1$ to $2^c-2$. For each set $X$ renamed to integer $y$, we rename the unique barred complement $\bar{X}$ to $\bar{y}$. The active configurations after renaming are
\[
	\collA_1 = \bigl\{ [x,\bar{x}] \bigm| x \in \{1,2,\dots, 2^c-2 \} \bigr\}.
\]
We note that passive configurations never include $[x,\bar{x}]$ for any $x$. This is because $\bar{x}$ represents the complement of $x$ as a set: it is not possible to pick a matching element from $x$ and $\bar{x}$. Therefore we may again \emph{relax} the passive configurations to be the configurations for $c$-coloring:
\[
	\collP_1 = \bigl\{ [x,\bar y] \bigm| x, y \in \{1,2,\dots,2^c-2\},\, x \nsim \bar y \bigr\}.
\]
The resulting problem is \emph{at least as easy} as the output problem of $c$-coloring: if $c$-coloring can be solved in $T$ rounds, then coloring with $2^c-2$ colors can be solved in \emph{at most} $T-1$ rounds.

Now in what follows, it will be awkward to use the expression $2^c-2$, so we will simply round it up to $2^c$. Clearly, coloring with $2^c$ colors is at least as easy as coloring with $2^c-2$ colors.

\subsection{Sequence of Output Problems}

We have shown that $2^c$-coloring is \emph{at least as easy} as the output problem of $c$-coloring.
Now if we were to iteratively apply round elimination $k$ times in the $\PN$-model we would get the following sequence of problems:
\[\begin{split}
	\Pi_0 = 3\text{-coloring}
	&\to \Pi_1 = 2^3\text{-coloring} \\
	&\to \Pi_2 = 2^{2^3}\text{-coloring} \\
	&\to \Pi_3 = 2^{2^{2^3}}\text{-coloring} \\
	&\phantom{{}\to{}} {\cdots} \\
	&\to \Pi_k = C(k)\text{-coloring},
\end{split}\]
where
\[
	C(k) = \underbrace{\,2^{2^{\scriptstyle\cdot^{\scriptstyle\cdot^{\scriptstyle\cdot^{\scriptstyle 2^{\scriptstyle 3}}}}}}}_{\text{\makebox[0pt]{$k$ times $2$ and one $3$}}}.
\]
Now if we show that coloring with $C(k)$ colors cannot be solved in $0$ rounds in the $\PN$ model with deterministic algorithms, it would imply that $3$-coloring cannot be solved in $k$ rounds in the $\PN$ model. This result, however, would not be very meaningful. As we have already seen in Chapter~\chapterref{7}, the vertex coloring problem cannot be solved at all in the $\PN$-model! Therefore we must strengthen the round elimination technique itself to apply in the $\LOCAL$ model.

\section{Round Elimination with Inputs}

If we try to do round elimination in the $\LOCAL$ model, we run into a technical challenge. In round elimination, the nodes simulate the outputs of their neighbors. It is crucial that the inputs of the neighbors are independent: for each combination of possible outputs, there must exist a network in which the algorithm actually produces those outputs. This step no longer holds in the $\LOCAL$ model: the identifiers are globally unique, and therefore do not repeat. The inputs of the neighbors \emph{are dependent}: if one of the regions contains, e.g., a node with identifier 1, then another region cannot contain identifier 1, and vice versa.

To overcome this difficulty, we will consider \emph{randomized algorithms}. In Exercise~\longref{6.2}{ex:randomness-to-unique-ids} we saw that randomness can be used to generate unique identifiers. Therefore the $\PN$-model, equipped with randomness, is at least as powerful as the $\LOCAL$ model: if a problem $\Pi$ can be solved in time $T(n)$ in the $\LOCAL$ model, then we can generate unique identifiers with high probability and simulate the $\LOCAL$-algorithm in $T(n)$ rounds. This clearly succeeds if the random identifiers were unique. Therefore any impossibility results we prove for randomized algorithms also hold for the $\LOCAL$ model.

For the remainder of the chapter, we assume that the nodes receive two types of inputs.
\begin{enumerate}
	\item Random inputs. Each node receives some arbitrary but finite number of uniform random bits as input. In addition, to simplify the proof, we will assume that the port numbers are assigned randomly. This latter assumption is made only for the purposes of this proof, we do not change the standard assumptions about the models.
	\item Consistent orientation. As we mentioned in the beginning, for technical reasons we consider a variant of coloring that includes an orientation. To solve this part of the problem easily, we include the required orientation as input.
\end{enumerate}
It is crucial that we can apply round elimination in the presence of these inputs. First, consider the orientation. In the round elimination step, each node must simulate the outputs of its neighbors over all possible inputs. Now we add the promise that each node, in addition to its usual inputs, receives an orientation of its edges as input. In particular, they form a \emph{consistent orientation} of the whole path from one end to the other. Clearly nodes can include this input in their simulation, as the orientation of the remaining edges is fixed after seeing the orientation of just one edge. Similarly, random inputs do not have any long-range dependencies. They do, however, affect the simulation step. We will discuss randomized round elimination in the next section.

\subsection{Randomized Round Elimination Step} \label{ssec:rand-re}

We will now introduce a variant of the Round Elimination Lemma that we proved in Chapter~\chapterref{9}. Assume that we have a randomized algorithm that solves problem $\Pi$ in $T(n)$ rounds with \emph{local failure probability $q$}: that is, each active node chooses an active configuration of $\Pi$ with probability \emph{at least} $1-q$, and each passive node is labeled according to some passive configuration of $\Pi$ with probability \emph{at least} $1-q$. Then we want to show that there is an algorithm that solves the output problem $\re(\Pi)$ in $T(n)-1$ rounds with some local failure probability at most $f(q)$ for some function $f$.

\begin{figure}
	\centering
	\includegraphics[page=\PRandomizedRE,scale=0.4]{figs.pdf}
	\caption{The randomized round elimination step. Assume an algorithm $A$ for $c$-coloring with running time $T = 3$. The simulation functions as follows. The active node gathers its $(T-1)$-neighborhood, including the assignment of random port numbers and random bits $r_1, r_2, r_3, r_4$ and $r_5$. Then it simulates $A$ on its right and left neighbor. On the right, over all possible assignments of ports $A, B, C$, $D$ and random bit strings $X, Y$. On the left, over all possible assignments of ports $E,F,G,H$ and random bit strings $Z,W$. For each edge, it outputs the set of labels that appear as outputs for at least fraction $t(q)$ of inputs.} \label{fig:rand-re}
\end{figure}

The round elimination step works essentially as in the $\PN$-model. Each $\re(\Pi)$-active node simulates the outputs of its $\Pi$-active nodes over all possible inputs, including the random bits. We make one modification to the model: we assume that the port numbers are assigned randomly instead of being assigned by an adversary. This modification is made to simplify the analysis that follows. It does not affect the power of the model: the nodes could use their local randomness to shuffle the ports and any algorithm designed for the worst-case port numbering also works, by definition, with a random port numbering. We will also only consider nodes that are internal nodes in the $(2,2)$-biregular tree: we assume that $T$-neighborhoods of the neighbors of $\re(\Pi)$-active nodes do not contain the endpoints of the path.

It no longer makes sense to construct the set of \emph{all possible} outputs. We can imagine an algorithm that tries to make round elimination hard: it always uses each possible output label with at least one specific random input labeling. These outputs would make no sense, but would cause the set of \emph{possible} output labels to always be the full set of labels. Since the random inputs can be arbitrarily large (but finite!), the failure probability this would add to the algorithm would be small.

To avoid this issue, we will define a \emph{threshold $t(q)$}: an output label $\sigma \in \Sigma$ is \emph{frequent} if it appears as the output label with probability at least $t(q)$.
More formally, for a fixed $\re(\Pi)$-active node $u$, an assignment of random inputs to $\ball_N(u,T-1)$, and a neighbor $v$, label $\sigma \in \Sigma$ is frequent for the edge $\{ u, v \}$ if the probability that $v$ outputs $\sigma$ on $\{u,v\}$, conditioned on fixing the random inputs in $\ball_N(u, T-1)$, is at least $t(q)$. We will fix the value of this threshold later.

The randomized simulation step is defined as follows. Each $\Pi_1$-active node $u$ gathers its $(T-1)$-neighborhood. Then it computes for each edge $\{u,v\}$ the set of frequent labels $S(u,v)$ and outputs that set on $\{u,v\}$. See Figure~\ref{fig:rand-re} for an illustration.

We will prove that randomized round elimination works for the special case of $c$-coloring $(2,2)$-biregular trees. This can be generalized to cover all bipartite locally verifiable problems in $(d,\delta)$-biregular trees, for any parameters $d$ and $\delta$.

\begin{lemma}[Randomized Round Elimination Lemma] \label{lem:rand-re}
	Assume that there is an algorithm that solves the $c$-coloring problem on $(2,2)$-biregular trees in the randomized $\PN$-model in $T(n)$ rounds with local failure probability at most $q$. Then there exists an algorithm that solves the $2^c$-coloring problem in $T(n)-1$ rounds with local failure probability at most $3cq^{1/3}$.
\end{lemma}

Intuitively the lemma is true, as in most neighborhoods the true outputs must also appear frequently in the simulation. Similarly, combinations of non-configurations cannot be frequent too often, as this would imply that the original algorithms also fails often.

We prove the lemma in Section~\ref{ssec:rand-re-proof}. Next we will see how to apply it to prove an impossibility result for 3-coloring.

\section{Iterated Randomized Round Elimination}

Given the randomized round elimination lemma, we will proceed as follows.
\begin{enumerate}[label=(\arabic*)]
	\item Assume there is a randomized $(\log^* n - 4)$-round algorithm for solving 3-coloring on \emph{consistently oriented} $(2,2)$-biregular trees. Since randomized algorithms are assumed to succeed \emph{with high probability}, the local failure probability $q_0$ must be at most $1/n^k$ for some constant $k$.
	\item Apply randomized round elimination $T(n) = \log^* n - 4$ times to get a $0$-round randomized algorithm for $c_{T(n)}$-coloring with some local failure probability $q_{T(n)}$. For the chosen value of $T(n)$ show that we have $q_{T(n)} < 1/c_{T(n)}$. \label{item:part2}
	\item Prove that there are no 0-round algorithms for solving $c_{T(n)}$-coloring with local failure probability $q_{T(n)} < 1/c_{T(n)}$. \label{item:part3}
\end{enumerate}

We must show that fast coloring algorithms imply 0-round coloring algorithms that do not fail with large enough probability. In Section~\ref{ssec:prob-re} we will prove the following lemma.

\begin{lemma} \label{lem:color-re}
	Assume that there is a $(\log^* n - 4)$-round 3-coloring algorithm in the randomized $\PN$-model. Then there is a 0-round $c$-coloring algorithm with local failure probability $q < 1/c$.
\end{lemma}

We must also show that any 0-round $c$-coloring algorithm fails locally with probability at least $1/c$.

\begin{lemma} \label{lem:0round-ccol}
	Any 0-round $c$-coloring algorithm fails locally with probability at least $1/c$.
\end{lemma}

\begin{proof}
	Any 0-round $c$-coloring algorithm defines a probability distribution over the possible output colors. This distribution is the same for each active node inside a path: they are indistinguishable from each other in 0 rounds. The algorithm fails if two adjacent nodes select the same color.

	Let $p_i = b_i + 1/c$ denote the probability that the algorithm outputs color $i$. The terms $b_i$ denote the deviation of each probability $p_i$ from the average: we must have that
	\[
		\sum_{i=1}^c b_i = 0.
	\]
	The local failure probability is at least
	\begin{align*}
		\sum_{i=1}^c p_i^2 &= \sum_{i=1}^c (b_i + 1/c)^2 \\
		&= \sum_{i=1}^c \bigl(b_i^2 + 2b_i/c + 1/c^2\bigr) \\
		&= 1/c + \biggl(\sum_{i=1}^c b_i^2\biggr) + 2/c \cdot \biggl(\sum_{i=1}^c b_i\biggr) \\
		&= 1/c + \biggl(\sum_{i=1}^c b_i^2\biggr) + 0.
	\end{align*}
	This is clearly minimized by setting $b_i = 0$ for all $i$. Thus the local failure probability is minimized when $p_i = 1/c$ for all $i$, and we get that it is at least $1/c$.
\end{proof}

The bound on the failure probability of 0-round coloring algorithms combined with Lemma~\ref{lem:color-re} shows that there is no 3-coloring algorithm that runs in at most $\log^* n - 4$ rounds in the randomized $\PN$-model, even if we know $n$ and the path is consistently oriented. Since the randomized $\PN$-model can simulate the $\LOCAL$ model with high probability, this implies that there is no (randomized) 3-coloring algorithm in the $\LOCAL$ model that runs in at most $\log^* n - 4$ rounds.

\begin{theorem}
	3-coloring (in the bipartite formalism) cannot be solved in the $\LOCAL$ model in less than $\log^* n - 4$ rounds.
\end{theorem}

\begin{corollary}
	3-coloring (in the usual sense) cannot be solved in the $\LOCAL$ model in less than $\frac{1}{2} \log^* n - 2$ rounds.
\end{corollary}
\begin{proof}
	Distances between nodes increase by a factor of $2$ when we switch to the bipartite encoding (see Figure~\ref{fig:3col-encoding}).
\end{proof}

This result is asymptotically optimal: already in Chapter~\chapterref{1} we saw that paths \emph{can be colored} with 3 colors in time $O(\log^* n)$.

In the final two sections we give the proofs for Lemmas~\ref{lem:rand-re}~and~\ref{lem:color-re}.

\subsection{Proof of Lemma~\ref{lem:rand-re}} \label{ssec:rand-re-proof}

In this section we prove Lemma~\ref{lem:rand-re}. The proof consists of bounding the local failure probability of the simulation algorithm given in Section~\ref{ssec:rand-re}.

\begin{proof}[Proof of Lemma~\ref{lem:rand-re}]
Let $\Pi_0 = (\Sigma_0, \collA_0, \collP_0)$ denote the $c$-coloring problem for some $c$, and let $\Pi_1 = \re(\Pi_0) = (\Sigma_1, \collA_1, \collP_1)$ denote the output problem of $c$-coloring. Assume that there is a $T$-round randomized algorithm $A$ for solving $\Pi_0$ with local failure probability $q$.
Consider an arbitrary $\Pi_1$-active node $u$ with some fixed $(T-1)$-neighborhood $\ball_N(u,T-1)$ (including the random inputs).

The passive configurations $\collP_0$ consist of pairs $[x, \bar{y}]$ that do not match. The algorithm $A$ fails if it outputs any $x$ and $\bar{x}$, or two labels of the same type on the incident edges of a $\Pi_0$-passive node. We say that the $(T-1)$-neighborhood $\ball_N(u,T-1)$ is \emph{lucky}, if the algorithm $A$ fails in labeling the incident edges of $u$, given $\ball_N(u,T-1)$, with probability less than $t^2$. Here $t$ is the probability threshold for frequent labels; we will choose the value of $t$ later.

We want to prove that most random bit assignments must be lucky, and that in lucky neighborhoods the simulation succeeds with a good probability. We will ignore the other cases, and simply assume that in those cases the simulation can fail.

Consider any fixed $\ball_N(u,T+1)$ \emph{without} the random bits and the random port numbering: since we consider nodes inside the path, the remaining structure is the same for all nodes. The randomness determines whether $A$ succeeds around $u$. Let $L$ denote the event that $\ball_N(u,T-1)$ is lucky. Since we know that $A$ fails in any neighborhood with probability at most $q$, we can bound the probability of a neighborhood \emph{not being lucky} as follows:
\begin{align*}
	\Pr[A \text{ fails at } u] &\geq
	\Pr[A \text{ fails at } u \mid \text{not } L]\cdot\Pr[\text{not } L] \\
	\implies \Pr[\text{not } L] &\leq \frac{\Pr[A \text{ fails at } u]}{\Pr[A \text{ fails at } u \mid \text{not } L]}
	< \frac{q}{t^2}.
\end{align*}

From now on we will assume that $\ball_N(u,T-1)$ is lucky. Let $v$ and $w$ denote the passive neighbors of $\re(\Pi)$-active node $u$. The simulation fails if and only if the sets $S(u,v)$ and $S(u,w)$ contain labels $x$ and $y$ such that $[x,y] \notin \collP_0$ (all choices do not yield a configuration in $\collP_0$). Since both of these labels are frequent (included in the output), each of them must appear with probability at least $t$ given $\ball_N(u,T-1)$. But since these labels are frequent, we have that the original algorithm fails, given $\ball_N(u,T-1)$ with probability at least $t^2$, and the neighborhood cannot be lucky. We can deduce that the simulation \emph{always succeeds in lucky neighborhoods}. Therefore we have that
\[
	\Pr[\text{simulation fails}] \leq \Pr[\text{not } L] < \frac{q}{t^2}.
\]

Next we must determine the failure probability of the simulation around \emph{passive nodes}. The $\re(\Pi)$-passive nodes succeed when the \emph{true output} of the algorithm is contained in the sets of frequent outputs. For a $\re(\Pi)$-passive neighbor $v$, consider the event that its output on edge $\{u,v\}$ in the original algorithm is not contained in the set of frequent outputs $S(u,v)$ based on $\ball_N(u,T-1)$. By definition, for each fixed $\ball_N(u,T-1)$ each infrequent label is the true output with probability at most $t$. There are $c$ colors, so by union bound one of these is the true output color with probability at most $ct$. There are two neighbors, so by another union bound the total failure probability for a passive node is at most $2ct$. Since the simulation can also fail when the original algorithm fails, we get for each passive node that
\[
	\Pr[\text{simulation fails}] \leq q + 2ct.
\]
To minimize the maximum of the two failure probabilities, we can for example set $t = q^{1/3}$ and get that
\[
	\frac{q}{t^2} = q^{1/3} \leq q + 2cq^{1/3} \leq 3cq^{1/3}. \qedhere
\]
\end{proof}

\subsection{Proof of Lemma~\ref{lem:color-re}} \label{ssec:prob-re}

It remains to show that a fast 3-coloring algorithm implies a 0-round $c$-coloring algorithm that fails locally with a probability less than $1/c$.

\begin{proof}[Proof of Lemma~\ref{lem:color-re}]
Assume there is a $T$-round 3-coloring algorithm that succeeds with high probability. This implies that it has a local failure probability $q_0 \leq 1/n^k$ for some constant $k \ge 1$. Applying the round elimination lemma, this implies the following coloring algorithms and local failure probabilities $q_i$:
\begin{align*}
	C(0) &= 3 \text{ colors: }&& q_0 \leq 1/n^k \leq 1/n, \\
	C(1) &= 2^3 \text{ colors: }&& q_1 \leq 3 C(0) \cdot q_0^{1/3}, \\
	C(2) &= 2^{2^3} \text{ colors: }&& q_2 \leq 3 C(1) \cdot q_1^{1/3} = 3 C(1) \cdot \bigl(3 C(0) \cdot q_0^{1/3}\bigr)^{1/3}.
\end{align*}
Generalizing, we see that after $T$ iterations, the local failure probability is bounded by
\[
	q_T \leq \Biggl( \prod_{i=0}^T 3^{1/3^i} \Biggr)\Biggl( \prod_{i=0}^T C(T-i)^{1/3^i} \Biggr) \cdot n^{-1/3^T},
\]
and the algorithm uses
\[
	C(T) \,=\,
	\underbrace{\,2^{2^{\scriptstyle\cdot^{\scriptstyle\cdot^{\scriptstyle\cdot^{\scriptstyle 2^{\scriptstyle 3}}}}}}}_{\text{\makebox[0pt]{\parbox{3cm}{\centering $T$ times $2$\\[-5pt]and one $3$}}}}
	\,<\,
	\underbrace{\,2^{2^{\scriptstyle\cdot^{\scriptstyle\cdot^{\scriptstyle\cdot^{\scriptstyle 2^{\scriptstyle 2^{\scriptstyle 2}}}}}}}}_{\text{\makebox[0pt]{$T+2$ times $2$}}}
	\,=\, {}^{T+2} 2
\]
colors. To finish the proof, we must show that for any $T(n) \leq \log^* n - 4$ and for a sufficiently large $n$ we have that $q_T < 1/C(T)$, or, equivalently, $q_T \cdot C(T) < 1$ or
\begin{equation} \label{eq:prob}
	\log q_T + \log C(T) < 0;
\end{equation}
here all logarithms are to the base $2$.
Evaluating the expression $\log q_T$, we get that
\begin{align*}
	\log q_T &\leq \sum_{i=0}^T \frac{1}{3^i} \log 3 + \sum_{i=0}^T \frac{1}{3^i} \log C(T-i) - 3^{-T} \log n \\
	&\leq \frac{3}{2}\log 3 + \frac{3}{2}\log C(T) - 3^{-T} \log n,
\end{align*}
since the sums are converging geometric sums. Therefore
\begin{equation}\label{eq:logqTlogCT}
	\log q_T + \log C(T) \le \frac{3}{2}\log 3 + \frac{5}{2}\log C(T) - 3^{-T} \log n.
\end{equation}
Note that
\[
	n \le {}^{\log^* n} 2 < 2^n.
\]
Therefore for $T = \log^* n - 4$ we have that
\begin{equation}\label{eq:logCT}
	\log C(T) < \log {}^{T+2} 2 = \log \log \log {}^{T+4} 2 < \log \log n.
\end{equation}
On the other hand, for a large enough $n$ we have that
\[
	3^T < 3^{\log^* n} < 3^{\log_3 \log \log n} < \log \log n,
\]
and therefore
\begin{equation}\label{eq:fact3Tlogn}
	3^{-T} \log n > \frac{\log n}{\log \log n}.
\end{equation}
Now \eqref{eq:logCT} and \eqref{eq:fact3Tlogn} imply that for a sufficiently large $n$, term $3^{-T} \log n$ will dominate the right hand side of \eqref{eq:logqTlogCT}, and we will eventually have
\[
	\log q_T + \log C(T) < 0,
\]
which is exactly what we needed for Equation~\eqref{eq:prob}.
\end{proof}

\section{Quiz}

Construct the \emph{smallest possible} (i.e., fewest nodes) properly 4-colored cycle $C$ such that the following holds: if you take \emph{any} deterministic 0-round $\PN$-algorithm $A$ and apply it to $C$, then the output of $A$ is not a valid 3-coloring of $C$.

Please note that here we are working in the usual $\PN$ model, exactly as it was originally specified in Chapter~3, and we are doing graph coloring in the usual sense (we do not use the bipartite formalism here).
Please give the answer by listing the $n$ colors of the $n$-cycle $C$.

\section{Exercises}

\begin{ex}[randomized 2-coloring]
	Prove that solving 2-coloring paths in the randomized $\PN$-model requires $\Omega(n)$ rounds.
\end{ex}

\begin{ex}[coloring grids]
	Prove that 5-coloring 2-dimensional grids in the deterministic $\LOCAL$ model requires $\Omega(\log^* n)$ rounds.

	A 2-dimensional grid $G = (V,E)$ consists of $n^2$ nodes $v_{i,j}$ for $i,j \in \{1,\dots, n\}$ such that if $i < n$,  add $\{ v_{i,j}, v_{i+1,j} \}$ to $E$ for each $j$, and if $j < n$ add $\{v_{i,j},v_{i,j+1}\}$ to $E$ for each $i$.
	\hint{Show that a fast 5-coloring algorithm could be simulated on any path to 5-color it. Then turn a 5-coloring into a 3-coloring yielding an algorithm that contradicts the 3-coloring lower bound.}
\end{ex}

\begin{ex}[more colors]
	Prove that cycles cannot be colored with $O(\log^* n)$ colors in $o(\log^* n)$ rounds in the deterministic $\LOCAL$ model.
	\hint{Show that an $O(\log^* n)$-coloring could be used to color cycles fast, which contradicts the lower bound for 3-coloring. Note that our lower bound is for paths: why does it also apply to cycles?}
\end{ex}

\begin{ex}[lying about $n$]
	Show that if a bipartite locally verifiable labeling problem can be solved in $o(\log n)$ rounds in the deterministic $\PN$-model in $(d,\delta)$-biregular trees, then it can be solved in $O(1)$ rounds.
	\hint{Show that we can run an algorithm for graphs of size $n_0$, for some constant $n_0$, on all networks of size $n \geq n_0$, and get a correct solution. In particular, show that for any $T(n) = o(\log n)$ and a sufficiently large $n_0$, networks on $n_0$ nodes are locally indistinguishable from networks on $n$ nodes, for $n \geq n_0$, in $O(T(n))$ rounds.}
\end{ex}

\begin{ex}[hardness of sinkless orientation]
	Let $\Pi$ denote the sinkless orientation problem as defined in Chapter~\chapterref{10}.
	Prove the following.
	\begin{subex}
		\item Sinkless orientation requires $\Omega(\log \log n)$ rounds in the randomized $\PN$-model. \label{hint:so-a}
		\item Sinkless orientation requires $\Omega(\log \log n)$ rounds in the deterministic and randomized $\LOCAL$ model. \label{hint:so-b}
	\end{subex}
	\hint{\ref{hint:so-a} Show that if $\re(\Pi)$ can be solved by a randomized $\PN$-algorithm in $T$ rounds with local failure probability $q$, then it can be solved in $T-1$ rounds with local failure probability $\poly(q)$. Analyze the failure probability over $T$ iterations for $T = o(\log \log n)$ and show that it is $\omega(1)$.}
\end{ex}

\begin{exs}
	Show that sinkless orientation requires $\Omega(\log n)$ rounds in the deterministic $\LOCAL$ model.
	\hint{One approach is the following. Prove that any \emph{deterministic} $o(\log n)$-time algorithm for sinkless orientation implies an $O(\log^* n)$-time deterministic algorithm for sinkless orientation. To prove this speedup, ``lie'' to the algorithm about the size of the graph. Take an algorithm $A$ for $(3,3)$-biregular trees on $n_0$ nodes, for a sufficiently large constant $n_0$. On any network $N$ of size $n > n_0$, compute a coloring of $N$ that \emph{locally} looks like an assignment of unique identifiers in a network of size $n_0$. Then simulate $A$ given this identifier assignment to find a sinkless orientation.}
\end{exs}

\section{Bibliographic Notes}

Linial~\cite{linial92locality} showed that $3$-coloring cycles with a deterministic algorithm is not possible in $o(\log^* n)$ rounds, and Naor~\cite{Naor1991} proved the same lower bound for randomized algorithms. Our presentation uses the ideas from these classic proofs, but in the modern round elimination formalism.


\documentclass[]{article}
\usepackage{float,graphicx}
\usepackage{tikz}

\title{test}

\begin{document}
    \section{lines}
    % [xscale=2.5, yscale=0.5]
    \begin{tikzpicture}[scale=1]
        \draw[help lines] (0,0) grid(5,5);
        \draw (0,0) -- (1,2)--(3,0) --(5,5);

        \draw [->] (0,0) -- (2,1);

        \draw [<-] (2,3) -- (5,0);

        \draw [|->] (0.5,3) -- (0,4);

        \draw [<->] (0,6) -- (0,0) -- (6,0);

    \end{tikzpicture}

    \begin{tikzpicture}
        \draw[help lines] (0,0) grid(5,5);
        \draw[thick] (0.5, 0.5) -- (3,3);
        % [ultra thick, thick, thin, very thick]
        \draw[line width=0.2cm] (1,0) -- (3,2);
    \end{tikzpicture}

    \begin{tikzpicture}
        \draw[help lines] (0,0) grid(5,5);
        \draw[ultra thick, dotted] (0,0) -- (2,3);
        \draw[line width=0.2cm, dotted,red] (2,2) -- (4,0);

        %[red, blue, green, cyan, magenta, yellow, black, gray, darkgray, lightgray, browbn, lime, olive, orange, pink, purple, teal, violet, white]
    \end{tikzpicture}
    \newpage
    \section{curves}

    \begin{tikzpicture}
        \draw[help lines] (0,0) grid(5,5);
        \draw[blue] (1,1) rectangle(3,3);
        \draw[red] (2,2) circle[radius=2];
        \draw[green] (1,0) arc [radius=1,start angle=180,end angle=360];

        \draw[<->, rounded corners, thick, purple] (0,5) -- (0,0) -- (5,0);

    \end{tikzpicture}

    \begin{tikzpicture}[xscale=10,yscale=5]
    \draw [<->, help lines] (0.6,1.34) -- (0.6,1) -- (1.05,1);
    \draw[orange] (0.6, 1.0385) --
(0.61, 1.06372) -- (0.62, 1.08756) -- (0.63, 1.11012) -- (0.64,
1.13147) -- (0.65, 1.15166) -- (0.66, 1.17074) -- (0.67, 1.18874) -- (0.68,
1.20568) -- (0.69, 1.22157) -- (0.7, 1.23643) -- (0.71, 1.25026) -- (0.72,
1.26307) -- (0.73, 1.27486) -- (0.74, 1.28561) -- (0.75, 1.29534) -- (0.76,
1.30402) -- (0.77, 1.31165) -- (0.78, 1.31821) -- (0.79, 1.32369) -- (0.8,
1.32806) -- (0.81, 1.33131) -- (0.82, 1.3334) -- (0.83, 1.33431) -- (0.84,
1.334) -- (0.85, 1.33244) -- (0.86, 1.32956) -- (0.87, 1.32533) -- (0.88,
1.31966) -- (0.89, 1.3125) -- (0.9, 1.30373) -- (0.91, 1.29325) -- (0.92,
1.2809) -- (0.93, 1.26649) -- (0.94, 1.24976) -- (0.95, 1.23032) -- (0.96,
1.2076) -- (0.97, 1.18065) -- (0.98, 1.14763) -- (0.99, 1.1038) -- (0.991,
1.09836) -- (0.992, 1.09261) -- (0.993, 1.0865) -- (0.994, 1.07994) -- (0.995,
1.07282) -- (0.996, 1.06497) -- (0.997, 1.0561) -- (0.998, 1.04563) -- (0.999,
1.03209) -- (0.9991, 1.03042) -- (0.9992, 1.02866) -- (0.9993,
1.02679) -- (0.9994, 1.02478) -- (0.9995, 1.0226) -- (0.9996, 1.02019) -- (0.9997,
1.01747) -- (0.9998, 1.01424) -- (0.9999, 1.01005) -- (0.9999,
1.01005) -- (0.99991, 1.00953) -- (0.99992, 1.00898) -- (0.99993,
1.0084) -- (0.99994, 1.00778) -- (0.99995, 1.0071) -- (0.99996,
1.00634) -- (0.99997, 1.00549) -- (0.99998, 1.00448) -- (0.99999, 1.00317) -- (1,
1) ;

    \end{tikzpicture}

    This gives us a curve from (0,0) to (2,1.5) which leaves at an angle of 90◦ and
arrive at an angle of 195◦

    \begin{tikzpicture}
    \draw[help lines] (0,0) grid(2,2);
        \draw[ultra thick](0,0) to [out=90,int=195] (2,1.5);
    \end{tikzpicture}

    \begin{tikzpicture}
        \draw[help lines] (0,0) grid(6,3);
        \draw[blue, thick] (0,0) to[out=90,in=180] (1,1) to[in=270,out=360] (2,2)
        to[in=180,out=90] (3,3) to[in=90,out=360] (4,2) to[in=180,out=270] (5,1)
        to[in=90, out=0] (6,0);
    \end{tikzpicture}

    \section{plotting functions}

    \begin{tikzpicture}[xscale=6,yscale=6]

        \draw[<->] (0,0.8) -- (0,0) -- (0.8,0);
        \draw[green,thick,domain=0:0.5]
        plot(\x, {0.025+\x*\x});

        \draw[red, thick, domain=0:0.5]
        plot(\x, {sqrt(\x)});

        \draw[blue, thick, domain=0:0.5]
        plot(\x, {abs(\x)});

    \end{tikzpicture}

    \begin{tikzpicture}[yscale=2]
    \draw [help lines, <->] (0,0) -- (6.5,0);
    \draw [help lines, ->] (0,-1.1) -- (0,1.1);
        \draw [green,domain=0:2*pi] plot (\x, {(sin(\x r)* ln(\x+1))/2});
        \draw [red,domain=0:pi] plot (\x, {sin(\x r)});
        \draw [blue, domain=pi:2*pi] plot (\x, {cos(\x r)*exp(\x/exp(2*pi))});

    \end{tikzpicture}

    \section{Filling up areas}

        \begin{tikzpicture}
            \draw[fill=red,ultra thick] (0,0) rectangle(1,1);

            \draw[fill=red,ultra thin, red] (2,0) rectangle(3,1);

            \draw[fill] (5,0) circle[radius=1];

            \draw [fill=orange] (9,0) rectangle (11,1);
            \draw [fill=white] (9.25,0.25) rectangle (10,1.5);

        \end{tikzpicture}

    \begin{tikzpicture}
        \path [fill=gray] (0,0) rectangle (1.5,1);
        \draw [fill=yellow] (2,0) rectangle (3.5,1);
    \end{tikzpicture}

    \section{putting labels in pictures}

    \begin{tikzpicture}
        \draw[<->,black, thick] (0,-1) -- (0,1);
        \draw[<->,black, thick] (1, 0) -- (-1,0);
        \path[thick, fill=red] (0,0) circle[radius=0.1];

        \node[right] at (1,0) {0/360};
        \node[above] at (0, 1) {90};
        \node[left] at (-1, 0) {180};
        \node[below] at (0,-1) {270};
    \end{tikzpicture}

    \begin{tikzpicture}[scale=2]
        \draw [thick, <->] (0,1) -- (0,0) -- (1,0);
        \draw[fill] (1,1) circle [radius=0.025];
        \node [below right, red] at (.5,.75) {below right};
        \node [above left, green] at (.5,.75) {above left};
        \node [below left, purple] at (.5,.75) {below left};
        \node [above right, magenta] at (.5,.75) {above right};
    \end{tikzpicture}

    \begin{tikzpicture}[scale=2]
        \draw[<->, thick] (0,1) -- (0,0) -- (1,0);
        \node[above left, black, thick] at (0,1) {$y$};
        \node[below right, black, thick] at (1,0) {$x$};
        \draw[fill=black] (0.5,0.5) circle[radius=0.5pt];
        \draw[red] (0.5,0.5) circle[radius=0.1];

        \node[above right] at (0.5,0.5) {$A$};
    \end{tikzpicture}

    \begin{tikzpicture}[xscale=3, yscale=3]
    \draw [thick, <->] (0,1) node [left] {$y$}
    -- (0,0) -- (1,0) node [below right] {$x$};
    \draw[fill] (.4,.6) circle [radius=.5pt]
    node[above right] (.4,.6) {$A$};
    \end{tikzpicture}

    \begin{tikzpicture}[xscale=1.3]
    \draw [thick] (0,0) -- (9,0);
    \draw (0,-.2) -- (0, .2);
    \draw (3,-.2) -- (3, .2);
    \draw (6,-.2) -- (6, .2);
    \draw (9,-.2) -- (9, .2);
    \node[align=left, below] at (1.5,-.5)%
    {This happens\\in period 1\\and is aligned\\ left};
    \node[align=center, below] at (4.5,-.5)%
    {This happens\\in period 2\\and is centered};
    \node[align=right, below] at (7.5,-.5)%
    {This happens\\in period 2\\and is right\\aligned};
    \end{tikzpicture}

    \begin{tikzpicture}
        \draw[help lines] (0,0) grid(3,3);
        \draw[thick] (0,0,0) -- (0,0,3);
        \draw[thick] (0,0,0) -- (0,3,0);
        \draw[thick] (0,0,0) -- (3,0,0);
    \end{tikzpicture}

\end{document}


% jam 2004-09-02

\section{Derivatives}
\label{sec:Derivatives}

One way to view the derivative of a function
$\f:\Vspace \mapsto \Wspace$,
at a point $\v$,
is as the linear transformation $\Lmap:\Vspace \mapsto \Wspace$,
that best approximates the local 'slope' of $\f$ at $\v$.
(In the following, $\v$, $\u$, and $\t$ are elements of $\Vspace$.)
To be a little more precise, we want
\begin{equation}
\lim_{ \|{\bf \delta}  \| \mapsto 0}
\frac{ \| \f(\v + {\bf \delta}) - (\f(\v) + \Lmap({\bf\delta})) \|}
{\|{\bf \delta}  \| }
 = 0
\end{equation}
For a concise discussion, see Spivak \cite{spivak-1965}.

Note that for a linear map $\Lmap$,
the derivative is constant over the domain
and the value is $\Lmap$ itself.

\begin{itemize}

\item $\Da{\f}$

In its most general form,
I denote the derivative of $\f$ by $\Da{\f}$.
Note that this is linear-map-valued function of the domain of $\f$.

\item $\Db{\f}{\u}$

I denote the derivative of $\f$ at $\u$ by $\Db{\f}{\u}$.
$\Db{\f}{\u}$ is a specific linear transformation from
the domain of $\f$ to the codomain of $\f$.

\item $\Dc{\f}{\u}{\t}$

The derivative is most often represented by the {\it Jacobian},
the $m \times n$ matrix of partial derivatives
with respect to some bases for $\Vspace$ and $\Wspace$.
However, it's often easier to express the derivative clearly if we
explicitly include the argument of the linear transformation.
In this case, I write $\Dc{\f}{\u}{\t}$
for the derivative of $f$ at the point $\u$
applied to the vector $\t$.

\item $\Dd{\v_i}{\f}{(\u_0 \ldots \u_{n-1})}{\t_i}$

For functions on direct sum spaces,
$\f(\v_0,\v_1 \ldots \v_{n-1})$, $\v_i \in \Vspace_i$,
it's often easier to consider the derivative
with respect to one argument at a time.
I write $\Dd{\v_i}{\f}{(\u_0 \ldots \u_{n-1})}{\t_0 \ldots \t_{n-1}}$
for the derivative of $\f$ with respect to $\v_i$,
at the point $(\u_0 \ldots \u_{n-1}) \in \oplus_{i=0}^{n-1} \Vspace_i$,
applied to the vector $\t_i \in \Vspace_i$.

\item $\da{j}{\f} = \da{v_j}{\f}$

The traditional partial derivative of $\f$ is with respect to
a single coordinate $v_j$ of the domain.
More formally, this is the directional derivative of $\f$
in the direction of the $j$-th canonical basis vector $\e_j^{\Vspace}$.

$\da{j}{\f}$ is a map from the domain of $\f$ to the co-domain of $\f$.
$\db{j}{\f}{\u}$ is the value of that map at $\u$.
The partial derivative is related to the derivative by
\begin{eqnarray}
\label{eq:partial-full-dervatives}
\Db{\f}{\u}
& = &
\sum_{j=0}^{m-1} \db{j}{\f}{\u} \otimes \e_j^{\Vspace}
\\
\db{j}{\f}{\u}
& = &
\Db{\f}{\u} \e_j^{\Vspace}
\nonumber
\end{eqnarray}

\item $\da{j}{\f_i}$

The Jacobian partial derivatives are the derivatives of
a particular coordinate of $\f$, $\f_i$, with respect to
a single coordinate $v_j$ of the domain.
$\da{j}{\f_i}$ is a real-valued function on the domain of $\f$.
$\db{j}{\f_i}{\u}$ is the value of that function at $\u$.
The Jacobian partial derivatives form the 'matrix' representation of the derivative:
\begin{equation}
\Db{\f}{\u} =
\sum_{i=0}^{m-1}
\sum_{j=0}^{n-1}
\db{j}{\f_i}{\u} \left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
\end{equation}

\end{itemize}

In minimizing a real-valued function, $f(\v)$, $\v \in \Vspace$,
we frequently need to know both the direction of maximum increase of $f$
the rate of increase, or slope, of $f$ in that direction.

$\Ga{f}$ is the {\it gradient} of $f$.
The gradient has a close relationship to the derivative, $\Da{f}$,
and the two are often confused.
Recall that the derivative is a linear transformation
from the domain of $f$ to its codomain.
In the case of real-valued functions,
this means the derivative is a linear function on $\Vspace$,
an element of the dual space of $\Vspace$, a 'row' vector.
It's easy to see that the gradient is simply the dual (the 'transpose')
of the derivative, $\Ga{f} = (\Da{f})^{\dagger}$
(see Spivak \cite[p.~96, ex.~4-18]{spivak-1965}).

$\Ga{f}$ maps $\Vspace \mapsto \Vspace$.
$\Gb{f}{\u} \in \Vspace$ is the gradient of $f$ at $\u \in \Vspace$;
it points in the direction of most rapid increase of
$f$ and its magnitude $\| \Gb{f}{\u} \|$ is the
slope of $f$ in that direction.

Notation for the various versions of the gradient
follows that for derivatives:
$\Gc{\v_i}{f}{\u}$ is the partial gradient of $f$ with respect to $\v_i$ at
$\u = \left( \u_0 \ldots \u_{n-1} \right) \in \Vspace = \oplus_{i=0}^{n-1} \Vspace_i$
$\Gc{\v_i}{f}{\u}$ is an element of $\Vspace_i$.

$(\Gb{f}{\u}) \bullet  \t$
and
$(\Gc{\v_i}{f}{\u}) \bullet \t_i$
are the analogs to exressing the derivative as a linear transformation
with an explicit argument.
$(\Gb{f}{\u}) \bullet  \t$ is a real number.
If we take $t$ to be the canonical basis for $\Vspace$
we get an expression for $\Ga{f}$ in terms of the partial derivatives of $f$:
\begin{equation}
\label{eq:gradient-from-partials}
\Gb{f}{\u} = \sum_{j=0}^{m-1} \left( \db{j}{f}{\u} \right) \e_j^{\Vspace}
\end{equation}

$\Ga{\f_i}$ is the gradient of a particular (real-valued) coordinate
of a vector-valued map. It is related to the derivative $\Da{\f}$
in a way simlilar to the relationship between $\Da{\f}$ and its partials $\da{j}{\f}$.
\begin{equation}
\Db{\f}{\u} = \sum_{i=0}^{n-1}  \e_i^{\Wspace} \otimes \Gb{\f_i}{\u}
\end{equation}

The most general identity used in computing derivatives is the {\it chain rule.}
Suppose
$\f:\Uspace \mapsto \Vspace$,
$\g:\Vspace \mapsto \Wspace$,
and
$\h = \g \circ \f : \Uspace_0 \mapsto \Wspace$
Then
\begin{equation}
\label{eq:chain-rule}
\Db{\h}{\u}
=  \Db{(\g \circ \f)}{\v}
=  \Db{\g}{\f(\v)}  \circ  \Db{\f} {\v}.
\end{equation}

It is sometimes useful to express this in terms of the partial derivatives:
\begin{equation}
\label{eq:chain-rule_partials}
\Db{\h}{\u} =  \sum_{i=0}^{n-1} \db{i}{\g}{\f(\u)} \otimes  \Gb{\f_i}{\u}.
\end{equation}

See Spivak \cite[Theorem~2-2]{spivak-1965}.

%------------------------------------------------------------------

\subsection{Vector-valued maps}

%------------------------------------------------------------------

\subsubsection{Multilinear maps}
\label{sec:Multilinear-maps}

A map $\f(\v_0 \ldots \v_k):\Vspace_0 \oplus \ldots \oplus \Vspace_k \mapsto \Wspace$
is {\it multilinear} if
\begin{equation}
\f(a_{00} \v_{00} + a_{01} \v_{01}, \ldots, a_{k0} \v_{k0} + a_{k1} \v_{k1})
 =  \sum_{i_0 \ldots i_k = 0,1} (a_{0i_0} \ldots a_{ki_k}) \f(\v_{0i_0} \ldots \v_{ki_k}).
\end{equation}

The derivative of $\f$
at the point $(\v_0 \ldots \v_k)$, applied to the vector $(\u_0 \ldots \u_k)$ is

\begin{equation}
\Dc{\f}{(\v_0 \ldots \v_k)}{\u_0 \ldots \u_k}
 =  \sum_{i=0,k} \f(\v_0 \ldots \v_{i-1},\u_i,\v_{i+1} \ldots \v_k).
\end{equation}

See Spivak \cite[ex.~2-14]{spivak-1965}.

%------------------------------------------------------------------

\subsubsection{Bilinear maps}
\label{sec:Bilinear-maps}

Bilinear maps are a useful special case of multilinear maps.

A map $\f(\v,\u):\Vspace_0 \oplus \Vspace_1 \mapsto \Wspace$
is {\it bilinear} if
\begin{eqnarray}
\f(a_0 \v_0 + a_1 \v_1, b_0 \u_0 + b_1 \u_1)
& =  & a_0 b_0 f(\v_0,\u_0)
+  a_0 b_1 f(\v_0,\u_1)
\\
& +  & a_1 b_0 f(\v_q,\u_0)
 +  a_1 b_1 f(\v_q,\u_1).
\nonumber
\end{eqnarray}

The derivative of $\f$
at the point $(\v_0,\u_0)$, applied to the vector $(\v,\u)$ is
\begin{equation}
\label{eq:bilinear-derivative}
\Dc{\f}{(\v_0,\u_0)}{\v,\u} = \f(\v_0,\u) + \f(\v,\u_0).
\end{equation}

See Spivak \cite[ex.~2-12]{spivak-1965}.

%------------------------------------------------------------------

\subsubsection{Cross products}
\label{sec:Derivatives-of-cross-products}

We can view the 3-dimensional cross product
$ \times $
as a bilinear map
$\times(\v,\u) = \v \times \u : \Reals^3 \oplus \Reals^3 \mapsto \Reals^3$.
From equation \ref{eq:bilinear-derivative},
$\Dc{\times}{(\v_0,\u_0)}{\v,\u} = \v_0 \times \u + \v \times \u_0$.

Suppose
$\f:\Vspace \mapsto \Reals^3$, and
$\g:\Vspace \mapsto \Reals^3$.
The derivative of $\f \times \g$ is:
\begin{eqnarray}
\Dc{(\f \times \g)}{\v_0}{\v}
& =
& \Db{\times}{(\f(\v_0),\g(\v_0))} \circ (\Dc{\f}{\v_0}{\v}, \Dc{\g}{\v_0}{\v})
\\
& =
& \f(\v_0) \times \Dc{\g}{\v_0}{\v} + \Dc{\f}{\v_0}{\v} \times \g(\v_0) \nonumber
\end{eqnarray}

%------------------------------------------------------------------

\subsubsection{Scalar products}
\label{sec:Derivatives-of-scalar-products}

Suppose
$f:\Vspace \mapsto \Reals$, and
$\g:\Vspace \mapsto \Wspace$.
It follows from the chain rule that the derivative of $\h = f\g$ is:
\begin{equation}
\label{eq:scalar_product_derivative}
\Db{(f\g)}{\v} =  f(\v) \Db{\g}{\v} + \g(\v) \otimes \Gb{f}{\v}
\end{equation}

%------------------------------------------------------------------

\subsubsection{Normalized maps}
\label{sec:Normalized-maps}

Let $\tilde{\f}$ be the normalized version of $\f$:
$\tilde{\f}  =  \frac{\f}{\| \f \|}$.
Then, from equations \ref{eq:scalar_product_derivative}
and \ref{eq:norm_derivative}:
\begin{eqnarray}
\Dc{\tilde{\f}}{\v}{\u}
& = &
\Dc{\left( \frac{\f}{\| \f \|}\right)}{\v}{\u}
\\
& = &
\frac{\Dc{\f}{\v}{\u}}{ \| \f(\v) \|}
 +
\f(\v)  \Dc{ \left( \frac{1}{\| \f \|} \right) }{\v}{\u} \nonumber \\
& = &
\frac{\Dc{\f}{\v}{\u}}
{\| \f(\v) \|}
 -
\f(\v)
\frac{\Dc{\| \f \|}{\v}{\u}}
{\|\f(\v)\|^2} \nonumber \\
& = &
\frac{\Dc{\f}{\v}{\u}}{ \| \f(\v) \| }
 -
\f(\v) \left( \frac{\f(\v)^\dagger}{\| \f(\v) \|^3}  \Dc{\f}{\v}{\u} \right) \nonumber \\
& = &
\frac{
\| \f(\v) \|^2 \Dc{\f}{\v}{\u}
 -
\f(\v)\left( \f(\v) \bullet \Dc{\f}{\v}{\u} \right)
}
{\| \f(\v) \|^3}  \nonumber \\
& = &
\frac{\| \f(\v) \|^2 \Identity_{\Wspace} - \left( \f(\v) \otimes \f(\v) \right)  }
{ \| \f(\v) \|^3 }
\Dc{\f}{\v}{\u} \nonumber \\
& = &
\frac{\Identity_{\Wspace} - \left( \tilde{\f}(\v) \otimes \tilde{\f}(\v) \right)  }
{\| \f(\v) \|}
\Dc{\f}{\v}{\u} \nonumber
\end{eqnarray}

We can write the derivative above without reference to the argument $\u$:
\begin{equation}
\label{eq:normalized_function_derivative}
\Db{\tilde{\f}}{\v}
 =
\Db{\left( \frac{\f}{\| \f \|} \right)}{\v}
 =
\frac{\Identity_{\Wspace} - \left( \tilde{\f}(\v) \otimes \tilde{\f}(\v) \right) }
{ \| \f(\v) \| }
\Db{\f}{\v}
\end{equation}

A common, trivial, normalized function is the normalized version of
a vector: $\tilde{\v} =  \frac{\v}{ \| \v \| }$.

From equation \ref{eq:normalized_function_derivative}
it follows that:
\begin{equation}
\label{eq:normalized_vector_derivative}
\Db{\tilde{\v}}{\u}
 =
\Db{ \left( \frac{\v}{ \| \v \| } \right) }{\u}
 =
\frac{\Identity_{\Vspace} - \left( \tilde{\u} \otimes \tilde{\u} \right) }
{ \| \u \| }
 =
\frac{\| \u \|^2 \Identity_{\Vspace} - \left( \u \otimes \u \right) }
{\| \u \|^3}
\end{equation}

%------------------------------------------------------------------

\subsection{Real-valued functions}
\label{sec:derivatives-of-real-valued-functions}

%------------------------------------------------------------------

\subsubsection{Inner products}
\label{sec:derivatives-of-inner-products}

We can view the inner product on $\Vspace$, $\v \bullet \u$,
as a bilinear function $\bullet(\v,\u) : \Vspace \oplus \Vspace \mapsto \Reals$.
Thus
\begin{equation}
\Dc{\bullet}{(\v_0,\u_0)}{\v,\u} = \v_0 \bullet \u + \v \bullet \u_0.
\end{equation}

Suppose
$\f:\Vspace \mapsto \Vspace$, and
$\g:\Vspace \mapsto \Vspace$.
The derivative of $\f \bullet \g$ is:
\begin{eqnarray}
\label{eq:dot_derivative}
\Dc{(\f \bullet \g)}{\v_0}{\v}
& =
& \Db{\bullet}{(\f(\v_0),\g(\v_0))} \circ (\Dc{\f}{\v_0}{\v}, \Dc{\g}{\v_0}{\v})
\\
& =
& \f(\v_0) \bullet \Dc{\g}{\v_0}{\v}  +  \g(\v_0) \bullet \Dc{\f}{\v_0}{\v} \nonumber
\end{eqnarray}

See Spivak \cite[ex.~2-13]{spivak-1965}.

%------------------------------------------------------------------

\subsubsection{Angles}
\label{sec:derivatives-of-angles}

The angle between 2 vectors $\v_0, \v_1 \in \Vspace$,
is the inverse cosine of their normalized inner product:
$\theta(\v_0,\v_1)
=
\cos^{-1} \left( \frac{ \v_0 \bullet \v_1 } {\|\v_0\| \|\v_1\|} \right)$.
Recall that the derivative of the $\cos^{-1}$ is
$\frac{\mathrm d}{\mathrm dx} \cos^{-1}(x) = \frac{-1}{\sqrt{1 - x^2} }$.
It follows that:
\begin{eqnarray*}
\Gc{\v_0}{\theta(\v_0,\v_1)}{\u}
& = &
\frac{-1}
{ \sqrt{1 - \left( \frac{\u_0 \bullet \u_1}{\| \u_0 \| \| \u_1 \|} \right)^2 }}
\Gc{\v_0}{\left( \frac{\u_0 \bullet \u_1}{\| \u_0 \| \| \u_1 \|} \right)}{\u}
\\
& = &
\frac{-\|\u_0\|\|\u_1\|}
{ \sqrt{\|\u_0\|^2\|\u_1\|^2 - \left( \u_0 \bullet \u_1 \right)^2 }}
\left[
\frac{\u_1}{\|\u_0\|\|\u_1\|}
+
\frac{\left( \u_0 \bullet \u_1 \right)}{\| \u1 \|}
\Gc{\v_0}{\left( \frac{1}{\| \v_0 \|} \right)} {\u}
\right]
\nonumber
\\
& = &
\frac{-\|\u_0\|\|\u_1\|}
{ \sqrt{\|\u_0\|^2\|\u_1\|^2 - \left( \u_0 \bullet \u_1 \right)^2 }}
\left[
\frac{\u_1}{\|\u_0\|\|\u_1\|}
-
\frac{\left( \u_0 \bullet \u_1 \right) \u0}{\| \u1 \| \|\u_0\|^3}
\right]
\nonumber
\\
& = &
\frac{-1}
{ \sqrt{\|\u_0\|^2\|\u_1\|^2 - \left( \u_0 \bullet \u_1 \right)^2 }}
\left[
\u_1
-
\frac{\left( \u_0 \bullet \u_1 \right) \u0}{\|\u_0\|^2}
\right]
\nonumber
\end{eqnarray*}
which results in
\begin{eqnarray}
\label{eq:angle_gradient}
\Gc{\v_0}{\theta(\v_0,\v_1)}{\u}
& = &
\frac{- \u_1 \perp \u_0}
{ \sqrt{\|\u_0\|^2\|\u_1\|^2 - \left( \u_0 \bullet \u_1 \right)^2 }}
\\
\Gc{\v_1}{\theta(\v_0,\v_1)}{\u}
& = &
\frac{- \u_0 \perp \u_1}
{ \sqrt{\|\u_0\|^2\|\u_1\|^2 - \left( \u_0 \bullet \u_1 \right)^2 }}
\nonumber
\end{eqnarray}

%------------------------------------------------------------------

\subsubsection{Euclidean norm}
\label{sec:derivatives-of-euclidean-norm}

Let $l_2(\v) = \| \v  \|: \Vspace \mapsto \Reals$
be the usual euclidean norm on $\Vspace$.
Let $l_2^2(\v) = \| \v  \|^2 $
be its square and $ \| \v  \|^3$ the cube.
\begin{eqnarray}
\label{eq:l2-gradient}
\Gb{l_2}{\v} = \frac{ \v }{ \| \v  \|} &
\Gb{l_2^2}{\v} =  2\v &
\Gb{l_2^3}{\v} = 3 \| \v  \| \v \\
\Db{l_2}{\v} = \frac{ \v^\dagger }{ \| \v  \|} &
\Db{l_2^2}{\v} = 2\v{^\dagger} &
\Db{l_2^3}{\v} = 3 \| \v  \| \v^\dagger \nonumber
\end{eqnarray}

Let $\f(\v) : \Vspace \mapsto \Wspace$.
By the chain rule:
$\Db{\| \f \|^2}{\v}  =  2 {\f(\v)}^{\dagger} \Db{\f}{\v} $
and
$\Gb{\| \f \|^2}{\v}  =  2 \Db{\f}{\v}^\dagger \circ \f(\v)$.
\begin{eqnarray}
\label{eq:norm_derivative}
\Db{\| \f \|}{\v}
& = &
\frac{\f(\v)^\dagger}{\| \f(\v) \|} \Db{\f}{\v}  \\
\Gb{\| \f \|}{\v}
& = &
\left(\Db{\f}{\v}\right)^\dagger \circ  \frac{\f(\v)}{ \| \f(\v)  \|}
\label{eq:norm_gradient}
\end{eqnarray}

%------------------------------------------------------------------

\subsection{Linear-map-valued maps}
\label{sec:Linear-map-valued-maps}

The set of linear maps between two inner product spaces
$\{ \Lmap : \Vspace \mapsto \Wspace \}$
is itself a inner product space $\Lspace(\Vspace,\Wspace)$,
with the inner product defined by
$\Lmap \bullet \Mmap = \sum_{i=0}^{m-1} \sum_{j=0}^{n-1} \Lmap_{ij} \Mmap_{ij}$.
The set of linear maps
$\Emap_{ij}^{\Lspace(\Vspace,\Wspace)}  = \e_i^{\Wspace} \otimes \e_j^{\Vspace}$
are the canonical basis vectors for $\Lspace(\Vspace,\Wspace)$.

If $\f$ is a map between spaces of linear maps,
$\f : \Lspace(\Vspace_0,\Wspace_0) \mapsto \Lspace(\Vspace_1,\Wspace_1)$,
its derivative, $\Da{\f}$,
is a map from a space of linear maps
to a space of linear maps between two
spaces of linear maps:
$\Da{\f} : \Lspace(\Vspace_0,\Wspace_0) \mapsto
\Lspace(\Lspace(\Vspace_0,\Wspace_0), \Lspace(\Vspace_1,\Wspace_1))$.
This can get a little confusing,
and it often helps to consider both the partial derivatives of $\f$
and the gradients of the coordinates of $\f$,
which can make it easier to apply the chain rule to
compositions of maps of maps via equation \ref{eq:chain-rule_partials}.

$\da{ij}{\f}$ is the partial derivative with respect to its $ij$-th matrix coordinate,
that is, the directional derivative of $\f$ in the direction
of the $ij$-th canonical basis vector, $\Emap_{ij}^{\Lspace(\Vspace_0,\Wspace_0)}$.
As usual the value of the partial derivative at a specific
$\Lmap_0 \in  \Lspace(\Vspace_0,\Wspace_0)$,
$\db{ij}{\f}{\Lmap_0}$ is an element of the co-domain of $\f$,
a linear map in  $\Lspace(\Vspace_1,\Wspace_1)$.

$\Ga{\f_{kl}}$ is the gradient of the $kl$-th matrix coordinate of the value of $\f$.
As usual, the value of the gradient at a specific $\Lmap_0$,
$\Gb{\f_{kl}}{\Lmap_0}$ is an element of the domain of $\f$,
a linear map in $\Lspace(\Vspace_0,\Wspace_0)$.

Note that nether of these are elements of the Jacobian of $\f$,
which needs 4 indexes: $\da{ij}{\f_{kl}}$.

I am particularly interested in computing the derivative of the
pseudo-inverse: $\Pseudoinverse(\Lmap) \equiv \Lmap^{-}$.
The set of full rank linear maps is an open set,
and we can define the derivative of $\Pseudoinverse(\Lmap)$ there.
For full rank map,
we can use the chain rule and the identity
$\Lmap^{-} = \left( \Lmap^{\dagger} \Lmap \right)^{-1} \Lmap^{\dagger}$
(equation \ref{eq:full-rank-pseudo-inverse})
to compute the derivative of the pseudo-inverse
(\autoref{sec:Derivative-of-pseudo-inverse}).

To do this I will first establish partial derivatives and gradients of:
\begin{equation}
\begin{aligned}
\label{eq:transpose-derivative}
&\Transpose(\Lmap) \equiv \Lmap^{\dagger}
&&\db{ij}{\Transpose}{\Lmap} =  \e_j^{\Vspace} \otimes \e_i^{\Wspace}
\forall \Lmap
\\
&\h( \Lmap ) = \f ( \Lmap ) \g ( \Lmap )
&&\text{Section \ref{sec:Derivatives-of-function-products} }
\\
&\LTL(\Lmap) \equiv \Lmap^{\dagger} \Lmap
&&\text{Section \ref{sec:Derivatives-of-LTL} }
\\
&\Inverse(\Lmap) \equiv \Lmap^{-1}
&&\text{Section \ref{sec:Derivative-of-inverse} }
\end{aligned}
\end{equation}

%------------------------------------------------------------------

\subsubsection{Map product}
\label{sec:Derivatives-of-function-products}

Let
$\f : \Lspace(\Vspace_0,\Wspace_0) \mapsto \Lspace(\Vspace_1,\Wspace_1)$,
$\g : \Lspace(\Vspace_0,\Wspace_0) \mapsto \Lspace(\Uspace_1,\Vspace_1)$,
and
$\h = \f\g : \Lspace(\Vspace_0,\Wspace_0) \mapsto \Lspace(\Uspace_1,\Wspace_1)$.
Note that
$\db{ij}{\f}{\Lmap} \in  \Lspace(\Vspace_1,\Wspace_1)$,
$\db{ij}{\g}{\Lmap} \in  \Lspace(\Uspace_1,\Vspace_1)$,
and
$\db{ij}{\h}{\Lmap} \in  \Lspace(\Uspace_1,\Wspace_1)$.
Consider the matrix representation of $\db{ij}{\h}{\Lmap}$:
\begin{eqnarray}
\left( \db{ij}{\h}{\Lmap} \right)_{kl}
& = &
\db{ij}{\h_{kl}}{\Lmap}
\\
& = &
\db{ij}{\left( \sum_{m} \f_{km} \g_{ml} \right)}{\Lmap}
\nonumber
\\
& = &
\sum_{m}  \left[
\left( \db{ij}{\f_{km}}{\Lmap} \right) \g_{ml}(\Lmap)
+
\f_{km}(\Lmap) \left( \db{ij}{\g_{ml}}{\Lmap} \right)
\right]
\nonumber
\\
& = &
\left[
\left( \db{ij}{\f}{\Lmap} \right) \g(\Lmap)
+
\f(\Lmap) \left( \db{ij}{\g}{\Lmap} \right)
\right]_{kl}
\nonumber
\end{eqnarray}
Therefore
\begin{equation}
\label{eq:map-product-derivative}
\db{ij}{\h}{\Lmap}
 =
\left( \db{ij}{\f}{\Lmap} \right) \g(\Lmap)
+
\f(\Lmap) \left( \db{ij}{\g}{\Lmap} \right)
\end{equation}

%------------------------------------------------------------------

\subsubsection{$\Lmap^{\dagger} \Lmap$}
\label{sec:Derivatives-of-LTL}

A common simple map transformation
is $\LTL(\Lmap) \equiv \Lmap^{\dagger} \Lmap
: \Lspace(\Vspace,\Wspace) \mapsto \Lspace(\Vspace,\Vspace)$.

The partial derivative is computed using equations
\ref{eq:transpose-derivative}
and
\ref{eq:map-product-derivative}:

\begin{equation}
\db{ij}{\LTL}{\Lmap}
=
\left( \e_j^{\Vspace} \otimes \e_i^{\Wspace} \right) \Lmap
+
\Lmap^{\dagger} \left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
=
\left( \e_j^{\Vspace} \otimes \r_i^{\Lmap} \right)
+
\left( \r_i^{\Lmap} \otimes \e_j^{\Vspace} \right)
\end{equation}
where $\r_i^{\Lmap} \in \Vspace$ is the $i$th 'row' of $\Lmap$
in the representation $\Lmap = \sum_{i=0}^{m-1} \e_i^{\Wspace} \otimes \r_i^{\Lmap}$.

The Jacobian, which has 4 indexes here, is given by:
\begin{equation}
\db{ij}{\LTL_{kl}}{\Lmap}
 =
\left( \db{ij}{\LTL}{\Lmap} \right)_{kl}
=
\delta_{jl} \Lmap_{ik}
+
\delta_{jk} \Lmap_{il}
\end{equation}
where, as usual, $\delta_{ij} = 1$ if $i=j$ and  $0$ if $i \neq j$.
From the Jacobian, we can compute the gradients of $\LTL_{kl}$
using equation \ref{eq:gradient-from-partials}
and the fact that
$\Emap_{ij}^{\Lspace(\Vspace,\Wspace)}  = \e_i^{\Wspace} \otimes \e_j^{\Vspace}$
are the canonical basis vectors for $\Lspace(\Vspace,\Wspace)$:
\begin{eqnarray}
\Gb{\LTL_{kl}}{\Lmap}
& = &
\sum_{ij}
\left( \db{ij}{\LTL_{kl}}{\Lmap} \right)
\left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
\\
& = &
\sum_{ij}
\left( \delta_{jl} \Lmap_{ik} + \delta_{jk} \Lmap_{il} \right)
\left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
\nonumber
\\
& = &
\sum_{i}
\left(
\Lmap_{ik}  \e_i^{\Wspace} \otimes \e_l^{\Vspace}
\right)
+
\sum_{i}
\left(
\Lmap_{il}  \e_i^{\Wspace} \otimes \e_k^{\Vspace}
\right)
\nonumber
\\
& = &
\left(
\c_k^{\Lmap} \otimes \e_l^{\Vspace}
\right)
+
\left(
\c_l^{\Lmap} \otimes \e_k^{\Vspace}
\right)
\nonumber
\end{eqnarray}
where $\c_j^{\Lmap} \in \Wspace$ is the $j$th 'column' of $\Lmap$
in the representation
$\Lmap = \sum_{j=0}^{n-1} \c_j^{\Lmap} \otimes \e_j^{\Vspace}$.

%------------------------------------------------------------------

\subsubsection{Inverse}
\label{sec:Derivative-of-inverse}

$\Inverse()$ here is interpreted in the traditional sense:
$\Lmap^{-1}(\w) = \v$ if there exists a unique $\v$ such that $\w = \Lmap(\v)$,
and is either considered undefined, or assigned an arbitrary
value, such as $\0$, otherwise.
A map $\Lmap : \Vspace \mapsto \Wspace$ is {\it invertible}
if, for all $\w \in \Wspace$, there exists a $\v$ such that
$\w = \Lmap \v$.
In any reasonable topology,
the set of invertible linear maps $\Vspace \mapsto \Wspace$
is an open subset of the set of all linear maps,
and $\Inverse()$ is continuous and differentiable there.

The partial derivative is the value of the following, when the limit exists:
\begin{displaymath}
\db{ij}{\Inverse()}{\Lmap}
 =
\lim_{ h \mapsto 0}
\frac{ \left( \Lmap + h (\e_i^{\Wspace} \otimes \e_j^{\Vspace}) \right)^{-1} - \Lmap^{-1} }{h}
\end{displaymath}
Note that
\begin{displaymath}
\Lmap + h (\e_i^{\Wspace} \otimes \e_j^{\Vspace})
 =
\left( \Identity^{\Wspace} - ( -h ( \e_i^{\Wspace} \otimes \e_j^{\Vspace} )) \Lmap^{-1} \right) \Lmap
\end{displaymath}
and
\begin{eqnarray*}
\left( \Lmap + h (\e_i^{\Wspace} \otimes \e_j^{\Vspace}) \right)^{-1}
& = &
\Lmap^{-1} \left( \Identity^{\Wspace} - ( -h )( \e_i^{\Wspace} \otimes \e_j^{\Vspace} ) \Lmap^{-1} \right)^{-1}
\\
& = &
\Lmap^{-1} \sum_{k=0}^{\infty} \left( -h ( \e_i^{\Wspace} \otimes \e_j^{\Vspace} ) \Lmap^{-1} \right)^{k}
\nonumber
\end{eqnarray*}
Therefore
\begin{displaymath}
\frac{ \left( \Lmap + h (\e_i^{\Wspace} \otimes \e_j^{\Vspace}) \right)^{-1} - \Lmap^{-1} }{h}
 =
- \Lmap^{-1} ( \e_i^{\Wspace} \otimes \e_j^{\Vspace} )  \Lmap^{-1} + O(h)
\end{displaymath}
which implies
\begin{equation}
\da{ij}{\Lmap^{-1}}
 =
- \left[
\Lmap^{-1}
\left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
\Lmap^{-1}
\right]
\end{equation}

\subsubsection{Pseudo-inverse}
\label{sec:Derivative-of-pseudo-inverse}

$\Pseudoinverse(\Lmap) \equiv \Lmap^{-}$

If $\kernel(\Lmap) = \0$, $\Lmap$ is said to have {\it full rank}.
The set of full rank linear maps is an open set,
and we can define the derivative of $\Pseudoinverse(\Lmap)$ there.
For a full rank map,
$\Lmap^{-} = \left( \Lmap^{\dagger} \Lmap \right)^{-1} \Lmap^{\dagger}$
(see equation \ref{eq:full-rank-pseudo-inverse}).
It follows from equation \ref{eq:map-product-derivative} that
\begin{eqnarray}
\db{ij}{\Pseudoinverse}{\Lmap}
& = &
\db{ij}{\Inverse(\LTL())\Transpose()}{\Lmap}
\\
& = &
\left[
\left( \db{ij}{\Inverse(\LTL())}{\Lmap} \right)
\Lmap^{\dagger}
\right]
+
\left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\db{ij}{\Transpose()}{\Lmap}
\right]
\nonumber
\\
& = &
\left[
\left( \db{ij}{\Inverse(\LTL())}{\Lmap} \right)
\Lmap^{\dagger}
\right]
+
\left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left( \e_j^{\Vspace} \otimes \e_i^{\Wspace} \right)
\right]
\nonumber
\end{eqnarray}

By the chain rule
\begin{eqnarray}
\Db{\Inverse(\LTL())}{\Lmap}
& = &
\sum_{kl}
\db{kl}{\Inverse}{\Lmap^{\dagger}\Lmap}
\otimes
\Gb{\LTL_{kl}}{\Lmap}
\\
& = &
\sum_{kl}
- \left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left( \e_k^{\Vspace} \otimes \e_l^{\Vspace} \right)
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\right]
\otimes
\left[
\left( \c_k^{\Lmap} \otimes \e_l^{\Vspace} \right)
+
\left( \c_l^{\Lmap} \otimes \e_k^{\Vspace} \right)
\right]
\nonumber
\end{eqnarray}

To minimize confusion,
recall that $\Db{\Inverse(\LTL())}{\Lmap}$ is
a linear map from $\Lspace(\Vspace,\Wspace) \mapsto \Lspace(\Vspace,\Vspace)$.
Note that the central tensor product ($\otimes$) above
is a product of
$
- \left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left( \e_k^{\Vspace} \otimes \e_l^{\Vspace} \right)
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\right]
$,
an element of $\Lspace(\Vspace,\Vspace)$
and
$
\left[
\left( \c_k^{\Lmap} \otimes \e_l^{\Vspace} \right)
+
\left( \c_l^{\Lmap} \otimes \e_k^{\Vspace} \right)
\right]
$,
an element of $\Lspace(\Vspace,\Wspace)$.

It follows from equation \ref{eq:partial-full-dervatives} that
\begin{eqnarray}
\db{ij}{\Inverse(\LTL())}{\Lmap}
& = &
\Db{\Inverse(\LTL())}{\Lmap}
\left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
\\
& = &
\sum_{kl}
- \left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left( \e_k^{\Vspace} \otimes \e_l^{\Vspace} \right)
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\right]
\otimes
\left[
\left( \c_k^{\Lmap} \otimes \e_l^{\Vspace} \right)
+
\left( \c_l^{\Lmap} \otimes \e_k^{\Vspace} \right)
\right]
\left( \e_i^{\Wspace} \otimes \e_j^{\Vspace} \right)
\nonumber
\\
& = &
\sum_{kl}
- \left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left( \e_k^{\Vspace} \otimes \e_l^{\Vspace} \right)
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\right]
\left[
\delta_{jl}
\Lmap_{ik}
+
\delta_{jk}
\Lmap_{il}
\right]
\nonumber
\\
& = &
-
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left[
\sum_{k}
\Lmap_{ik}
\left(
\left( \e_k^{\Vspace} \otimes \e_j^{\Vspace} \right)
+
\left( \e_j^{\Vspace} \otimes \e_k^{\Vspace} \right)
\right)
\right]
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\nonumber
\\
& = &
-
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left[
\left( \r_i^{\Lmap} \otimes \e_j^{\Vspace} \right)
+
\left( \e_j^{\Vspace} \otimes \r_i^{\Lmap} \right)
\right]
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\nonumber
\end{eqnarray}

Putting it all together:
\begin{eqnarray}
\db{ij}{\Pseudoinverse}{\Lmap}
& = &
\left[
-
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left[
\left( \r_i^{\Lmap} \otimes \e_j^{\Vspace} \right)
+
\left( \e_j^{\Vspace} \otimes \r_i^{\Lmap} \right)
\right]
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\Lmap^{\dagger}
\right]
+
\left[
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left( \e_j^{\Vspace} \otimes \e_i^{\Wspace} \right)
\right]
\nonumber
\\
& = &
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left[
\left( \e_j^{\Vspace} \otimes \e_i^{\Wspace} \right)
-
\left(
\left[
\left( \r_i^{\Lmap} \otimes \e_j^{\Vspace} \right)
+
\left( \e_j^{\Vspace} \otimes \r_i^{\Lmap} \right)
\right]
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\Lmap^{\dagger}
\right)
\right]
\nonumber
\\
& = &
\left( \Lmap^{\dagger} \Lmap \right)^{-1}
\left[
\left( \e_j^{\Vspace} \otimes \e_i^{\Wspace} \right)
-
\left(
\left( \r_i^{\Lmap} \otimes \e_j^{\Vspace} \right)
+
\left( \e_j^{\Vspace} \otimes \r_i^{\Lmap} \right)
\right)
\Lmap^{-}
\right]
\end{eqnarray}


\newpage
\subsection{Algorithms in Graph}

\begin{minipage}{.5\linewidth}
    \den{Cut}{
        A cut is a partition of the vertices of a graph into two disjoint subsets.
        Any cut determines a cut-set, the set of edges that have one endpoint in
        each subset of the partition. These edges are said to cross the cut. In a
        connected graph, each cut-set determines a unique cut, and in some cases
        cuts are identified with their cut-sets rather than with their vertex
        partitions.
    }\label{definition:cut_graph_theory}
\end{minipage}\hfill%
\begin{minipage}{.49\linewidth}
    \begin{figure}[H]
        \begin{center}
            \subfloat[Minimum Cut]{\includegraphics[width=.4\textwidth]{Min-cut.pdf}}
            \hspace{1em}
            \subfloat[Maximum Cut]{\includegraphics[width=.47\textwidth]{Max-cut.pdf}}
        \end{center}
    \end{figure}
\end{minipage}

\begin{minipage}{.55\linewidth}
    \theo{https://en.wikipedia.org/wiki/Prufer_sequence}
    {Prufer sequence}{
        Consider a labeled tree $ T $ with vertices's $ \{1, 2, ..., n\} $. At
        step $ i $, remove the leaf with the smallest label and set the $ i $th
        element of the \textit{Prüfer sequence} to be the label of this leaf's
        neighbour. Prove that a Prüfer sequence of length $ n-2 $ defines a Tree
        with length $ n $.

    }
\end{minipage}\hfill%
\begin{minipage}{.45\linewidth}
    \figdf{.4}{prufer_code_example}{${4,4,4,5}$}
\end{minipage}

\prob{https://artofproblemsolving.com/community/c6h5976p20088}
{German TST 2004 E7P3}{M}{
    We consider graphs with vertices colored black or white. ``Switching" a
    vertex means: coloring it black if it was formerly white, and coloring it
    white if it was formerly black.

    Consider a finite graph with all vertices colored white. Now, we can do the
    following operation: Switch a vertex and simultaneously switch all of its
    neighbours (i.e. all vertices connected to this vertex by an edge). Can we,
    just by performing this operation several times, obtain a graph with all
    vertices colored black?

    \index[strat]{Induction!German TST 2004 P3}
    \index[strat]{Constructive Algorithm!Compound moves!German TST 2004 P3}
}\label{problem:induction_type1_30}

\solu{A classical example of creating complex moves from counter cases.}

\prob{https://artofproblemsolving.com/community/c6h589936p3493453}
{ARO 2014 P9.8}{H}{
    In a country of $n$ cities, an express train runs both ways between any
    two cities. For any train, ticket prices either direction are equal, but
    for any different routes these prices are different. Prove that the
    traveler can select the starting city, leave it and go on, successively,
    $n-1$ trains, such that each fare is smaller than that of the previous
    fare. (A traveler can enter the same city several times.)

    \index[strat]{Global!Pigeonhole!ARO 2014 P9.8}
}

\prob{https://artofproblemsolving.com/community/c6h364267}
{Generalization of ARO 2014 P9.8}{H}{
    Let $ A $ be a set of $ n $ points in the space. From the family of all
    segments with endpoints in $ A $ , $ q $ segments have been selected and
    colored yellow. Suppose that all yellow segments are of different length.
    Prove that there exists a polygonal line composed of $ m $ yellow
    segments, where $ m\geq\frac{2q}{n}$, arranged in order of increasing
    length.

    \index[strat]{Global!Pigeonhole!ARO 2014 P9.8 Gene}
    \index[strat]{Constructive Algorithm!Deletetion!ARO 2014 P9.8 Gene}
}

\begin{solution}
    There are no local information given that we can use to consturct a way,
    so our only bet is to try some global approach. We want at least one path
    of length more than $n-1$, and there are a total of $\frac{n(n-1)}{2}$
    edges. So either we want to partition the edges in $\frac{n}{2}$ paths, or
    we count each edge twice and then partition then in $n$ paths, giving us
    our desired result.\\

    We figure out the second approach works. So we want to find $n$ paths that
    begin at each of the $n$ vertices and cover all the edges twice. This idea
    soon lead us to the magical solution:\\

    \textit{\color{solC}Let one traveller go to each of the $n$ cities. Then we select the
        costliest train and swap the two travellers on its two ends. We keep doing
    this until all the trains have been used.\\}

    This works because every traveller follows a path of gradually decreasing
    train cost, and every edge is used exactly twice.
\end{solution}

\begin{solution}[ninjaturtle]
    Consider the direct graph where each edge has two directions ($2q$
    edges). A directed edge $e$ is called \emph{terminal} if there isn't an edge $f$
    with larger value such that the end vertex of $e$ is the same as the start
    vertex of $f$.\\

    At step $i$, we remove all terminal edges in the remaining
    graph. If we can show that each step removes at most $n$ direct edges,
    then $2q/n$ steps are required to remove all edges, implying there exists
    a polygonal line of increasing length of length at least $2q/n$.\\

    Let $I_i(a), O_i(a)$ be the in-degree and out-degree of $a$ before step
    $i$. Assume we are at the time before step $k$. Put $m = O_k(a)$, and let
    $e$ be the outgoing edge of $a$ with the largest value $v$. Then $v \geq
    m$. After step $k$, only incoming edges of $a$ with value $ \geq m$ will
    have possibly been removed. Thus $I_{k+1}(a) \geq m-1 = O_k(a)-1$. Sum it
    over all $a$
    \[\#\text{edges before step k+1} = \sum_a I_{k+1}(a) \geq \sum_a O_k(a) -n
    = \#\text{edges before step k}\]
    and we have shown the number of edges
    after each step decreases by at most $n$.
\end{solution}

\prob{}
{}{E}{
    Given a bipartite graph, prove that the minimum number of colors required
    to color the edges of the graph such that no node is adjacent to $ 2 $
    edges of same color is the maximum degree of the graph.
}\label{problem:bipartite_graph_3}

\prob{}
{}{E}{
    For every bipartite graph prove that it's edges can be bicolored so that each
    node is adjacent to atmost $ \ceil{\dfrac{deg}{2}} $ edges of  any color.
}\label{problem:bipartite_graph_4}

\solu{Using the main property of a bipartite graph.}

\solu{After finding the cycle solution, to optimize it, we recall that we can find a Eulerian Path (if it exists) in $ O(V+E) $. Now we want to make the graph have a Eulerian path, so we add a vertice to both sides of the graph, and join them with odd vertices from the other side.}

\prob{https://artofproblemsolving.com/community/c6h446932}
{Turkey National MO 2002 P3}{HM}{
    Graph Airlines $(GA)$ operates flights between some of the cities
    of the Republic of Graphia. There are at least three $GA$ flights from each
    city, and it is possible to travel from any city in Graphia to any city in
    Graphia using $GA$ flights. $GA$ decides to discontinue some of its flights.
    Show that this can be done in such a way that it is still possible to travel
    between any two cities using $GA$ flights, yet at least $2/9$ of the cities
    have only one flight.

    \textbf{\Share\color{probC}Simplified:} In a connected graph, every
    vertex has degree at least $3$. Prove that some edges can be deleted to
    turn that graph into a tree with at least $\frac{2}{9}$ leaves.

    \textbf{\Share\color{probC}Better Approximation:} We can actually achieve
    $\frac{1}{4}$ with careful construction.

    \index[strat]{Constructive Algorithm!Inclusion!Turkey NMO 2002 P3}
    \index[strat]{Bounding!Cost function!Turkey NMO 2002 P3}
}

\begin{solution}[dgrozev]
    First we construct a spanning tree $T$ that maximizes the number of leaves,
    then we bound the number. We define $G(V, E), n = \left|V\right| $ with
    the usual notations.\\

    Let $f: V \to V$. We initialize the tree by selecting a vertex $v$ by
    random, and adding it to $T$. We inductively add the vertices according to
    the following priority checks:

    \begin{enumerate}[label=\textbf{\boxed{\arabic*.}}, itemsep=5pt]
        \item If there is a vertex $v\not \in T$ that is connected to $u\in T$
            such that $u$ is not a leaf, then add $v, uv$ to $T$.
        \item If $u\in T$ is a leaf and there are two $v_1, v_2$ not in $T$
            that are connected to $u$, add $v_1, v_2$ and $uv_1, uv_2$ to $T$.
        \item If $u\in T$ is a leaf, and there is a $v$ which has two
            neighbors outside of $T$, then add $v, uv$ to $T$, and let $f(u)=v$.
        \item If $u\in T$ is a leaf, there is a $v \not \in T$ which is
            connected to at most one vertex outside $T$, and connected to
            $u'\in T$, then add $v, uv$ to $T$ and let $f(u) = u'$.
    \end{enumerate}
    This algorithm will add all the vertices to the tree. We now need to bound
    the number of leaves.\\

    Let $n_1, n_2, n_3$ be the set of vertices that have $1, 2$ and more than
    $3$ neighbors respectively. Since $f$ is a injection from the set $n_2$ to
    either $n_1$ or $n_3$, we have since $n = n_1+n_2+n_3$,
    \[n_2 \le n_1 + n_3,\quad n_2 \le \frac{n}{2}\]
    Bounding the number of edges gives us:
    \[\begin{aligned}
        2n-2 &\ge n_1 + 2n_2 + 3n_3\\
             &= n_1 + 3(n-n_1) - n_2\\
             &\ge 3n - 2n_1 - \frac{n}{2}\\
        \implies n_1 &\ge \frac{n}{4}+1
    \end{aligned}\]
\end{solution}

\begin{solution}[\href{http://wwwmayr.in.tum.de/konferenzen/Jass08/courses/1/gravin/Gravin_Slides.pdf}{Paper}]
    The construction is the same as before. But we define a different cost
    fuction $f$ to bound our leaves count. Let $D(T)$ be the number of leaves in
    $T$ which doesn't have a neighbor outside of $T$. Let $L(T)$ be the number of
    all leaves, and $V(T)$ is the number of vertices of $T$. Then consider
    \[\boxed{f(T) = 3L(T) + D(T) - V(T)}\]
    We show that $f(T)$ is non decreasing in our construction. If it is, we
    will get by setting $f(T_0)$ for a one vertex and its neighbor tree $T_0$,
    \[f(T) \ge f(T_0) \ge 3\times 3 +0 -4 = 5 \]
    And since $D(T') = L(T')$ for a spanning tree $T'$, \[L(T') \ge \frac{N+5}{4}\]
    We now check that for all of your steps in construction, $f(T)$ is non
    decreasing.
\end{solution}

\prob{https://artofproblemsolving.com/community/c6h100733p568964}{ISL 2005 C1}{E}{A house has an even number of lamps distributed among its rooms in such a way that there are at least three lamps in every room. Each lamp shares a switch with exactly one other lamp, not necessarily from the same room. Each change in the switch shared by two lamps changes their states simultaneously. Prove that for every initial state of the lamps there exists a sequence of changes in some of the switches at the end of which each room contains lamps which are on as well as lamps which are off.}\label{problem:divide_and_conquer_4}\label{problem:induction_type1_10}

\prob{https://artofproblemsolving.com/community/c6h597130p3543398}{ISL 2013 C3}{M}{A crazy physicist discovered a new kind of particle which he called an $ i $ -mon, after some of them mysteriously appeared in his lab. Some pairs of $ i $ -mons in the lab can be entangled, and each $ i $ -mon can participate in many entanglement relations. The physicist has found a way to perform the following two kinds of operations with these particles, one operation at a time.

    \begin{enumerate}

        \item If some $ i $ -mon is entangled with an odd number of other $ i $ -mons in the lab, then the physicist can destroy it.

        \item At any moment, he may double the whole family of $ i $ -mons in the lab by creating a copy $ I' $ of each $ i $ -mon $ I $. During this procedure, the two copies $ I' $ and $ J' $ become entangled if and only if the original $ i $ -mons $ I $ and $ J $ are entangled, and each copy $ I' $ becomes entangled with its original $ i $ -mon $ I $ ; no other entanglements occur or disappear at this moment.

    \end{enumerate}

    Prove that the physicist may apply a sequence of much operations resulting in a family of $ i $ -mons, no two of which are entangled.
}\label{problem:induction_type1_9}

\solu{As there are an integer number of $ i $ -mons, it is quite natural to use induction. We try to find an algorithm to reduce the number of particles.

Another way to do this is to consider the chromatic number of the graph. If we can show that this number reduces after some move, then we are done by induction.}

\prob{https://artofproblemsolving.com/community/c6h104152p586762}{ISL 2005 C2}{E}{A forest consists of rooted (i. e. oriented) trees. Each vertex of the forest is either a leaf or has two successors. A vertex $ v $ is called an extended successor of a vertex $ u $ if there is a chain of vertices's $ u_{0}=u , u_{1}, u_{2} \dots u_{t-1} , u_{t}=v $ with $ t>0 $ such that the vertex $ u_{i+1} $ is a successor of the vertex $ u_{i} $ for every integer $ i $ with $ 0\leq i\leq t-1 $.\\

    Let $ k $ be a nonnegative integer. A vertex is called dynastic if it has two successors and each of these successors has at least $ k $ extended successors.\\

Prove that if the forest has $ n $ vertices, then there are at most $ \frac{n}{k+2} $ dynastic vertices.}\label{problem:induction_type1_8}

\solu{Trying to apply induction, we realize the bound is very loosy. That's why when we try to add in the inductive step, the value becomes larger than the bound. To stop that overflow, we tighten the bound.}

\solu{The second and dummy approach is to first doing some smaller cases, finding small infos, taking the root, seeing that the bound doesnt work, but it would work if one of the successors of the root would have exactly or less than $ 2k+3 $ successors. As we can't always guarantee that, we look for such a vertex with $ 2k+3 $ successors. We do some work with it and by induction its done.}

\prob{https://artofproblemsolving.com/community/c6h1441121p8200413}{All Russia 2017 9.1}{E}{In a country some cities are connected by oneway flights (There are no more then one flight between two cities). City $ A $ called "available" for city $ B $ , if there is flight from $ B $ to $ A $ , maybe with some transfers. It is known, that for every 2 cities $ P $ and $ Q $ exist city $ R $ , such that $ P $ and $ Q $ are available from $ R $. Prove, that exist city $ A $ , such that every city is available for $ A $.}\label{problem:induction_type1_17}

\prob{www.google.com}{Jacob Tsimerman Induction}{E}{There are $ 2010 $ ninjas in the village of Konoha (what? Ninjas are cool.) Certain ninjas are friends, but it is known that there do not exist $ 3 $ ninjas such that they are all pairwise friends. Find the maximum possible number of pairs of friends.(If ninja $ A $ is friends with ninja $ B $ , then ninja $ B $ is also friends with ninja $ A $.)}\label{problem:induction_type1_16}

\prob{https://artofproblemsolving.com/community/c6h420430p2374818}{USA TST 2011 D3P2}{M}{Let $n \geq 1$ be an integer, and let $S$ be a set of integer pairs $(a,b)$ with $1 \leq a < b \leq 2^n$. Assume $|S| > n \cdot 2^{n+1}$. Prove that there exists four integers $a < b < c < d$ such that $S$ contains all three pairs $(a,c)$, $(b,d)$ and $(a,d)$.}\label{problem:induction_type1_19}

\solu{Using Induction to the first and last half of the set $ S $ shows us the \hrf{finding_the_tough_nut}{hardest part} of the problem. Then ordering the left and right elements with some sort of hierarchy is all the work left to do.}

\prob{https://artofproblemsolving.com/community/c6h1480703p8639274}{ISL 2016 C6}{H}{There are $ n \geq 3 $ islands in a city. Initially, the ferry company offers some routes between some pairs of islands so that it is impossible to divide the islands into two groups such that no two islands in different groups are connected by a ferry route.\\

    After each year, the ferry company will close a ferry route between some two islands $ X $ and $ Y $. At the same time, in order to maintain its service, the company will open new routes according to the following rule: for any island which is connected to a ferry route to exactly one of $ X $ and $ Y $, a new route between this island and the other of $ X $ and $ Y $ is added.\\

Suppose at any moment, if we partition all islands into two nonempty groups in any way, then it is known that the ferry company will close a certain route connecting two islands from the two groups after some years. Prove that after some years there will be an island which is connected to all other islands by ferry routes.}\label{problem:induction_type1_11}

\solu{It is only natural to use induction on this kinda problems. After some trying, we see that if we remove $ 1 $ node, We get to nowhere, but if we remove $ 2 $ nodes, we get something interesting. So now focus on those two nodes and the rest of the nodes separately. Its not hard from there.}

\solu{As it seems, the separation of the graph was the main observation. We can call this trick \hl{Bringing Order in the Chaos}.}

\prob{https://artofproblemsolving.com/community/c6h535003p3067563}{ARO 2013 P9.5}{M (8/10)}{$ 2n $ real numbers with a positive sum are aligned in a circle. For each of the numbers, we can see there are two sets of $ n $ numbers such that this number is on the end. Prove that at least one of the numbers has a positive sum for both of these two sets.}\label{problem:graph_representation_4}\label{problem:minus_constant_2}

\solu{Since there is nothing specfic about the sum, we may safely assume that it is $ 0 $, because (1) probably it works, and (2) it makes things more convenient. How we do that? we decrease every number by the average.\\

    Now, Consider every block of $ n $ consecutive blockes of numbers. When are two blocks connected? When they share the same end. What if we consider them as vertices, and this ``connectivity'' as edges? We see that cycles pop out.\\

And we make use of the fact that our sum is $ 0 $. So signs are sure to bet flipped at the opposite side, and there are odd and even -ness in cycles that we can use.}

\prob{https://artofproblemsolving.com/community/c6h420424p2374799}{USA TST 2011 P2}{HM (9/10)}{In the nation of Onewaynia, certain pairs of cities are connected by roads. Every road connects exactly two cities (roads are allowed to cross each other, e.g., via bridges). Some roads have a traffic capacity of 1 unit and other roads have a traffic capacity of $ 2 $ units. However, on every road, traffic is only allowed to travel in one direction. It is known that for every city, the sum of the capacities of the roads connected to it is always odd. The transportation minister needs to assign a direction to every road. Prove that he can do it in such a way that for every city, the difference between the sum of the capacities of roads entering the city and the sum of the capacities of roads leaving the city is always exactly one.}\label{problem:divide_and_conquer_1}\label{problem:induction_type2_3}

\solu{As there are two types of subgraph, $ 1 $ -type and $ 2 $ -type. By some work-arounds, we see that we have to work distinctly in both types of graphs. Firstly, if we work in type- $ 1 $ , we see after making a path from node $ x, y $ , the degrees of $ x, y $ will be $ \{1, -1\} $ and the degrees of other nodes on the path will be the same. After that, we make every nodes have degree either $ \{1, -1\} $. So after this operation we remove the $ 1 $ -edges. Now, when dealing with the type- $ 2 $ sub-graph. Start over from zero, we see that when making a path between nodes $ x, y $ the degree of those two changes parity, and other nodes on the path stays the same. So select two odd nodes.... }

\solu{Dealing with two different kind of edges simultaneously is messy, so we work with graph $ 1 $ and graph $ 2 $ differently. Now on both graphs, we can remove cycles. And in graph $ 2 $ , we see that we can remove any big paths if there is a edge $ 1 $ joining the two endpoints. Since if the new graph works then the previous graph works too. [Several cases to show here] And if there is no edge joining the two endpoints, replace the path by joining the two endpoints by a edge $ 2 $.\\

Now there are only edge $ 1 $ s, and lone edge $ 2 $ s. Now dividing the graph $ 1 $ into paths of edge $ 1 $ , and dealing with several small cases, we are done.}

\prob{https://artofproblemsolving.com/community/c6h276187p1494557}
{Iran TST 2009 P6}{E-M (9/10)}{
    We have a closed path that goes from one vertex to another neighboring
    vertex, on the vertices of a $ n\times n$ square which pass throgugh each
    vertex exactly once. Prove that we have two adjacent vertices such that if
    we cut the path at these two points then the length of each open paths is
    at least $ n^2/4 $.

    \index[strat]{Different representation!Graph!Iran TST 2009 P6}
}

\begin{solution}[grobber]
    After drawing the closed path we notice that it divides the grid into a
    tree like structure, which we definitely need to explore!\\

    After drawing the tree with the unit squares as vertices, we try to
    reformulate our problem in our new tree. We want to find an edge of
    this tree that will divide the tree into two parts, and those two part
    should have perimeter more than $\frac{n^2}{4}$. \\

    We know of \hrf{theorem:Pick's Theorem}{Pick's Theorem} which lets us
    relate area with perimiter of such polygons. Which we use to do some
    bounding. We also need to show that if every vertex in a tree has degree
    at most $4$, then there is an edge that divides the tree into two ``big''
    portions, which we will use.
\end{solution}

\prob{https://artofproblemsolving.com/community/c6h85771p499536}
{Iran TST 2006}{E}{
    Suppose we have a simple polygon (that is it does not intersect itself,
    but not necessarily convex). Show that this polygon has a diagonal which
    is completely inside the polygon and the two arcs it creates on the
    polygon perimeter (the two arcs have 2 vertices in common) both have at
    least one third of the vertices of the polygon.

    \index[strat]{Different representation!Graph!Iran TST 2006}
    \index[strat]{Extremal!Iran TST 2006}
    \index[strat]{Induction!Iran TST 2006}
}

\begin{solution}[grobber]
    First we triangulate the polygon. Now we take the diagonal that divides
    the polygon into two arcs whose difference in length is the least. We show
    that it satisfies the requirement.
\end{solution}

\begin{solution}[induction]
    After the triangulation, we can also do induction on the number of
    triangles, by removing a ``outer'' triangle.
\end{solution}

\begin{solution}[graph transformation]
    We can convert the problem into a graph by considering the triangles as
    vertices and joining two vertices if they share a common side. Then this
    graph is a tree of which all vertices have degree at most $3$. And we know
    that in any graph with maximum degree $3$, there is way to remove an edge
    to divide the graph into two subgraphs with at least $\frac{n}{3}$
    vertices.
\end{solution}

\prob{https://math.stackexchange.com/questions/1439430/algorithm-to-uniquely-determine-a-number-using-two-adjacent-digits}
{OC Chap2 P2}{M (6/10)}{\label{problem:bijection_2}\label{problem:hall_marriage_1}
    Arutyun and Amayak perform a magic trick as follows. A spectator writes
    down on a board a sequence of $ N $ (decimal) digits. Amayak covers two
    adjacent digits by a black disc. Then Arutyun comes and says both closed
    digits (and their order). For which minimal $ N $ can this trick always
    work? NOTE: Arutyun and Amayak have a strategy determined beforehand.

    \index[strat]{Graph!Matching!OC Chap2 P2}
    \index[strat]{Construction!OC Chap2 P2}
}

\solu{
    We have to actually find a bijection between all of the combinations the
    spectator can create, and all of the combinations that Arutyun might see
    when he comes back. Which tells us to use ``Perfect Matching" tricks.
}

\solu{[Existence]
    For this trick to always work, they have to make a bijection from a set of
    $N$ digits with two covered, to an unique set of $N$ digits. Consider a
    bijection from the set of $0-9$ strings with length $N$ to the set of
    $0-9$ strings with length $N$ with $2$ adjacent digits unknown.  There
    exist a bijection iff the two sets satisfy Hall's Marriage Theorem.  By
    double counting we get the value of $N$ from here.
}

\prob{}
{Simurgh 2019 P3}{E}{
    Call a graph \textit{symmetric}, if one can put its vertices on the plane
    such that it becomes symmetric wrt a line (which doesn't pass through any
    vertex). Find the minimum value of $ k $ such that (the edges of) every
    graph on $ 100 $ vertices, can be decomposed into $ k $ symmetric
    subgraph.

    \index[strat]{Construction!Simurgh 2019 P3}
}

\prob{https://artofproblemsolving.com/community/c6h2019175p14186360}
{RMM 2020 P3}{MH}{
    Let $n\ge 3$ be an integer. In a country there are $n$ airports and $n$
    airlines operating two-way flights. For each airline, there is an odd
    integer $m\ge 3$, and $m$ distinct airports $c_1, \dots, c_m$, where the
    flights offered by the airline are exactly those between the following
    pairs of airports: $c_1$ and $c_2$; $c_2$ and $c_3$; $\dots$ ; $c_{m-1}$
    and $c_m$; $c_m$ and $c_1$.

    Prove that there is a closed route consisting of an odd number of flights
    where no two flights are operated by the same airline.

    \index[strat]{Induction!RMM 2020 P3}
    \index[strat]{Construction!Greedy!RMM 2020 P3}
    \index[strat]{Graph!Hall Marriage!RMM 2020 P3}
    \index[strat]{Graph!Bipartite!RMM 2020 P3}
}

\solu{[Weird Induction]
    Fix one vertice, merge all neighbors with it that has a unique airline between them.
}

\solu{[Element of Time]
    Add one edge from each cycle one at a time, without creating a cycle. Our
    objective is to show that when we reach the maximum stage where one edge
    creates a cycle, that cycle is of odd length.
}


\section{Higher Order Heterogeneous Equations}
\noindent
If we modify our equation for free vibrations to have a function as the net force, then out equations becomes
\begin{equation*}
	my'' + by' + ky = b(x).
\end{equation*}
Depending on the form of $b(x)$, like a $\sin$ or $\cos$ curve or an exponential, we might be able to guess the form of the solution.
However, there is an important thing to keep in mind.

\begin{theorem}
	If $f(x)$ is a solution to the above equation, and $g(x)$ is a solution to the homogeneous form of the equation $b(x) = 0$, then $f(x) + g(x)$ is also a solution to the above equation.
\end{theorem}
\begin{proof}
	If $f(x) + g(x)$ is a solution, then
	\begin{equation*}
		m\left(f(x) + g(x)\right)'' + b\left(f(x) + g(x)\right)' + k\left(f(x) + g(x)\right) = b(x).
	\end{equation*}
	Rearranging,
	\begin{equation*}
		\left(mf''(x) + bf'(x) + kf(x)\right) + \left(mg''(x) + bg'(x) + kg(x)\right) = 0.
	\end{equation*}
	Using the definitions of $f(x)$ and $g(x)$,
	\begin{equation*}
		b(x) + 0 = b(x).
	\end{equation*}
\end{proof}

\noindent
$f(x)$ and $g(x)$ actually have special meanings in terms of solving these higher-order equations.
\begin{definition}
	$f(x)$ is called the particular solution to the heterogeneous equation, and $g(x)$ is called a homogeneous solution.
\end{definition}

\input{./higherOrder/nonHomeg/undeterminedCoeffs.tex}
\input{./higherOrder/nonHomeg/variationParameters.tex}