\documentclass[12pt,a4paper]{amsart}
\usepackage{amsmath,amsxtra,amsthm,amssymb,eurosym,xr}
\externaldocument{Naive}
\newcommand{\var}{\operatorname{var}}
\newcommand{\lcm}{\operatorname{lcm}}
\renewcommand{\qedsymbol}{$\blacksquare$}
\renewcommand{\emptyset}{\varnothing}
\setcounter{MaxMatrixCols}{20}
\begin{document}
\vspace{12\baselineskip}
\begin{center}
\begin{LARGE} 
{\bf Partial Solutions for Exercises in\\
Naive Decision Making}

\vspace{2\baselineskip}
{\bf T. W. K\"{o}rner}
\end{LARGE}
\end{center}
\newpage\section*{Introduction} 
Here is a miscellaneous collection of
hints, answers, partial answers and remarks on some of the exercises in
the book. I have written in haste in the hope that
others will help me correct at leisure.
I am sure that they are stuffed with errors ranging
from the \TeX tual through to the arithmetical
and not excluding serious mathematical mistakes.
I would appreciate the opportunity to correct at least some
of these problems.
Please tell me of any errors, unbridgeable gaps,
misnumberings
etc. I welcome suggestions for additions.
\begin{center}
ALL COMMENTS GRATEFULLY RECEIVED.
\end{center}

If you can,
please use $\LaTeXe$ or its relatives for mathematics.
If not, please use plain text. My e-mail is
{\bf twk@dpmms.cam.ac.uk}. You may safely assume that
I am both lazy and stupid so that a message saying
`Presumably you have already realised the mistake in
Exercise~$Z$' is less useful than one which says
`I think you have made a mistake in Exercise $Z$
because you have have assumed that the sum is necessarily
larger than the integral. 
One way round this problem is to assume that $f$ is decreasing.'

When I was young, I used to be surprised when the answer
in the back of the book was wrong. I could not believe that
the wise and gifted people who wrote textbooks could possibly
make mistakes. I am no longer surprised. 


To avoid disappointment note that Exercise~$Z^{*}$ means
that there is no comment. Exercise~$Z?$ means that
I still need to work on the remarks.
Note also that what is given is \emph{at most} a sketch
and often very much less.

It may be easiest to navigate this document by using
the table of contents which follow on the next few pages.

\newpage
\tableofcontents
\setlength{\parskip}{.5\baselineskip}
\newpage\section*{Exercise~\ref{E;up down}}
\[\frac{y(cb)}{ca}=\frac{c(yb)}{ca}=\frac{yb}{a}.\]

\newpage\section*{Exercise~\ref{E;up down A}}
Under the new arrangement you end up with $y(v+1)-y=yv$
in your pocket if the horse wins and you lose $y$ if
the horse loses. This is the same as before.
\newpage\section*{Exercise~\ref{E;up down B}}
You should get an upside down $V$ shape.

\newpage\section*{Exercise~\ref{E;up down C}}
If $u_{1}s<u_{2}(Y-s)$, then
\[\min\big(u_{1}(s),u_{2}(Y-s)\big)
=u_{1}s.\]

If $t$ is small and strictly positive,
we have \[u_{1}(s+t)<u_{2}(Y-(s+t))\] and
\begin{align*}
\min\big(u_{1}(s+t),u_{2}(Y-(s+t))\big)
&=u_{1}(s+t)\\
&>u_{1}t\\
&=\min\big(u_{1}s,u_{2}(Y-s)\big).
\end{align*}

If $u_{1}s>u_{2}(Y-s)$, then
\[\min\big(u_{1}(s),u_{2}(Y-s)\big)
=u_{2}(Y-s).\]

If $t$ is small and strictly positive
(and $u_{1}s>u_{2}(Y-s)$), then
\[u_{1}(s+t)>u_{2}(Y-(s+t))\] and
\begin{align*}
\min\big(u_{1}(s+t),u_{2}(Y-(s+t))\big)
&=u_{1}(Y-(s+t))\\
&<u_{1}(Y-t)\\
&=\min\big(u_{1}s,u_{2}(Y-s)\big).
\end{align*}

\newpage\section*{Exercise~\ref{E;up down D}}
(i) If $s\leq s^{*}$, then
\[ \min\big(u_{1}s^{*},u_{2}(Y-s^{*})\big)=u_{1}s^{*}
\geq u_{1}s\geq \min\big(u_{1}s,u_{2}(Y-s)\big).\]

(ii) If $s\neq s^{*}$ then either $s>s^{*}$ or $s^{*}>s$.

If $s>s^{*}$, then $Y-s^{*}> Y-s$
so 
\[\min\big(u_{1}s^{*},u_{2}(Y-s^{*})\big)=u_{2}(Y-s^{*})
> u_{2}(Y-s)\geq \min\big(u_{1}s,u_{2}(Y-s)\big).\]

If $s<s^{*}$, then 
\[ \min\big(u_{1}s^{*},u_{2}(Y-s^{*})\big)=u_{1}s^{*}
>u_{1}s\geq \min\big(u_{1}s,u_{2}(Y-s)\big).\]

\newpage\section*{Exercise~\ref{E;n horses unique}}
If
\[u_{1}y_{1}^{*}=u_{1}y_{2}^{*}=\dots=u_{n}y_{n}^{*}
\ \text{and}\ y_{1}^{*}+y_{2}^{*}+\dots+y_{n}^{*}=Y,\]
then, writing $L=u_{1}y_{1}^{*}$, we have
\[y_{j}^{*}=Lu_{j}^{-1}\]
so
\[L(u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1})
=y_{1}+y_{2}+\dots+y_{n}=Y\]
and
\[L=\frac{Y}{u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}}\]
so
\[y_{j}^{*}=\frac{Yu_{j}^{-1}}{u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}}\]
and the solution, if it exists, is unique.

If we set 
\[w_{j}^{*}=\frac{Yu_{j}^{-1}}{u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}},\]
then
\[u_{1}w_{1}^{*}=u_{1}w_{2}^{*}=\dots=u_{n}w_{n}^{*}
\ \text{and}\ w_{1}^{*}+w_{2}^{*}+\dots+w_{n}^{*}=Y\]
so we do indeed have a solution.

\newpage\section*{Exercise~\ref{E;n horses work}}
(i) If $y_{j}>y_{j}^{*}$ for all $j$, then
\[Y=y_{1}+y_{2}+\dots+y_{n}>y_{1}^{*}+y_{2}^{*}+\dots+y_{n}^{*}=Y\]
which is impossible. Thus we can find a $k$ with
\[y_{k}\leq y_{k}^{*}\]
so
\[\min_{j}u_{j}y_{j}^{*}=u_{k}y_{k}^{*}\geq u_{k}y_{k}\geq 
\min_{j}u_{j}y_{j}.\]

(ii) If there exists a $k$ with
\[y_{k}<y_{k}^{*}\]
then
\[\min_{j}u_{j}y_{j}^{*}=u_{k}y_{k}^{*}>u_{k}y_{k}\geq 
\min_{j}u_{j}y_{j}.\]
Thus, under the conditions stated, $y_{j}\geq y_{j}^{*}$.

If there exists a $k$ with
\[y_{k}>y_{k}^{*}\]
then
\[Y=y_{1}+y_{2}+\dots+y_{n}>y_{1}^{*}+y_{2}^{*}+\dots+y_{n}^{*}=Y\]
which is impossible. Thus $y_{j}=y_{j}^{*}$ for all $j$.

\newpage\section*{Exercise~\ref{E;equivalent bets}}

(1) You gain $y$ if the horse loses, and lose $vy$ if it wins.

(2) You gain $y$ if the horse loses, and lose $uy-y=(v+1)y-y=vy$
if it it wins.

(3) You gain $-yv+(y+1)v=y$ if the horse loses, and
lose $vy$ if it wins.
 
\newpage\section*{Exercise~\ref{E;n horses against}}
(i)  Since
\[y_{1}^{*}+y_{2}^{*}+\dots+y_{n}^{*}=Y
\ \text{and}
\ y_{1}+y_{2}+\dots+y_{n}=Y,\]
there must be a $k$ such that
\[y_{k}\geq y_{k}^{*}\]
and so
\[\max_{j}u_{j}y_{j}^{*}=u_{k}y_{k}^{*}\leq u_{k}y_{k}
\leq \max_{j}u_{j}y_{j}.\]

(ii) If
\[\max_{j}u_{j}y_{j}^{*}=\max_{j}u_{j}y_{j}\]
then the argument of~(i) shows that
\[y_{j}\geq y_{j}^{*}\]
for all $j$. But
\[y_{1}^{*}+y_{2}^{*}+\dots+y_{n}^{*}=Y
\ \text{and}
\ y_{1}+y_{2}+\dots+y_{n}=Y,\]
so, if $y_{k}> y_{k}^{*}$ for some $k$,
\[y_{1}^{*}+y_{2}^{*}+\dots+y_{n}^{*}<
\ y_{1}+y_{2}+\dots+y_{n},\]
which is impossible, so $y_{j}=y_{j}^{*}$ for all $j$.

(iii) We minimise our maximum loss by taking
\[y_{j}=_{j}^{*}=\frac{Yu_{j}^{-1}}{u_{1}^{-1}+u_{2}^{-1}+
\dots+u_{n}^{-1}}\]
and our loss, whatever the outcome, is
\begin{align*}
L&=Y-u_{j}\frac{Yu_{j}^{-1}}{u_{1}^{-1}+u_{2}^{-1}+
\dots+u_{n}^{-1}}\\
&=Y\left(1-\frac{1}{u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}}\right).
\end{align*}

We lose if $L<0$, that is to say, if
\[1-\frac{1}{u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}}<0\]
ie if
\[\frac{1}{u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}}<1\]
ie if
\[u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}>1.\]

The remaining statements follow similarly.

\newpage\section*{Exercise~\ref{E;two bookies}}
If $a_{k}\neq b_{k}$, then there is no loss in generality
in supposing $a_{k}< b_{k}$
Thus
\begin{align*}
\frac{1}{c_{1}}+\frac{1}{c_{2}}+\dots+\frac{1}{c_{n}}
&=\frac{1}{c_{1}}+\frac{1}{c_{2}}+\dots+\frac{1}{c_{k-1}}
+\frac{1}{c_{k}}+\frac{1}{c_{k+1}}+\dots+\frac{1}{c_{n}}\\
&=\frac{1}{c_{1}}+\frac{1}{c_{2}}+\dots+\frac{1}{c_{k-1}}
+\frac{1}{b_{k}}+\frac{1}{c_{k+1}}+\dots+\frac{1}{c_{n}}\\
&\leq\frac{1}{a_{1}}+\frac{1}{a_{2}}+\dots+\frac{1}{a_{k-1}}
+\frac{1}{b_{k}}+\frac{1}{a_{k+1}}+\dots+\frac{1}{a_{n}}\\
&<\frac{1}{a_{1}}+\frac{1}{a_{2}}+\dots+\frac{1}{a_{k-1}}
+\frac{1}{a_{k}}+\frac{1}{a_{k+1}}+\dots+\frac{1}{a_{n}}\\
&=1
\end{align*}
Thus betting with the first bookmaker when $a_{j}>b_{j}$
and with the second when $a_{j}\leq b_{j}$ is equivalent
to betting with a bookmaker who allows a certain profit
(unless $a_{j}=b_{j}$ for all $j$).

\newpage\section*{Exercise~\ref{E;friction}}
(i) The effective pay out multiplier is $\alpha u_{j}$
so you can only make a certain profit if
\[\frac{1}{\alpha u_{1}}+\frac{1}{\alpha u_{2}}
+\dots+\frac{1}{\alpha u_{n}}<1\]
ie
\[\frac{1}{u_{1}}+\frac{1}{u_{2}}
+\dots+\frac{1}{u_{n}}<\alpha.\]

If you \emph{take} then the effective pay out multiplier is 
$u_{j}/\alpha$
so you can only make a certain profit if
\[\frac{1}{\alpha^{-1} u_{1}}+\frac{1}{\alpha^{-1} u_{2}}
+\dots+\frac{1}{\alpha^{-1} u_{n}}>1\]
ie
\[\frac{1}{u_{1}}+\frac{1}{u_{2}}
+\dots+\frac{1}{u_{n}}>\frac{1}{\alpha}.\]

(ii) If you make bets you will bet on horse $j$ with the bookmaker
with higher payout multiplier on that horse.
By (i) you can only make a certain profit if
\[\frac{1}{\max(a_{1},b_{1})}+\frac{1}{\max(a_{2},b_{2})}+\dots+
\frac{1}{\max(a_{n},b_{n})}<\alpha.\]

If you take bets you will bet on horse $j$ with the bookmaker
with lowest payout multiplier on that horse.
By (i) you can only make a certain profit if
\[\frac{1}{\min(a_{1},b_{1})}+\frac{1}{\min(a_{2},b_{2})}+
\dots+\frac{1}{\min(a_{n},b_{n})}>\frac{1}{\alpha}.\]

(iii) If $a\geq b$.
\[\frac{1}{\min(a,b)}-\frac{1}{\max(a,b)}
=\frac{1}{b}-\frac{1}{a}
=\left|\frac{1}{a}-\frac{1}{b}\right|.\]
If $a<b$.
\[\frac{1}{\min(a,b)}-\frac{1}{\max(a,b)}
=\frac{1}{a}-\frac{1}{b}
=\left|\frac{1}{a}-\frac{1}{b}\right|.\]
Thus, by (ii), if we can make a certain profit both making a
bet and taking it
\begin{align*}
\left|\frac{1}{a_{1}}-\frac{1}{b_{1}}\right|&
+\left|\frac{1}{a_{2}}-\frac{1}{b_{2}}\right|
+\dots
+\left|\frac{1}{a_{n}}-\frac{1}{b_{n}}\right|\\
&=\left(\frac{1}{\min(a_{1},b_{1})}+\frac{1}{\min(a_{2},b_{2})}+
\dots+\frac{1}{\min(a_{n},b_{n})}\right)\\
&\qquad -\left(\frac{1}{\max(a_{1},b_{1})}+\frac{1}{\max(a_{2},b_{2})}+\dots+
\frac{1}{\max(a_{n},b_{n})}\right)\\
&>\frac{1}{\alpha}-\alpha=\frac{(1-\alpha^{2})}{\alpha}.
\end{align*}

(iv) Suppose $a_{j}/b_{j}\geq 1/\alpha^{2}$. If we bet $1$
with the second bookmaker that horse $j$ will lose
and 
\[\frac{\alpha b_{j}^{-1}+1}{\alpha a_{j}+1}\]
with the first bookmaker that horse $j$ will win, then
if horse $j$ wins we win
\[\alpha a_{j}\frac{\alpha b_{j}^{-1}+1}{\alpha a_{j}+1}-1
=\frac{\alpha^{2} a_{j}b_{j}^{-1}-1}{\alpha a_{j}+1}\]
and if horse $j$ loses we win
\[\alpha b_{j}^{-1}-\frac{\alpha b_{j}^{-1}+1}{\alpha a_{j}+1}
=\frac{\alpha^{2} a_{j}b_{j}^{-1}-1}{\alpha a_{j}+1}.\]
In either case, since $\alpha^{2} a_{j}b_{j}^{-1}-1>0$
so we  can guarantee to make money.



\newpage\section*{Exercise~\ref{E;crown}}
(i)  Our expected gain is
\[125\times\frac{1}{216}\times 0
+75\times\frac{1}{216}\times \frac{9}{4}
+15\times\frac{1}{216}\times 3
+1\times\frac{1}{216}\times 4 -1=\frac{871}{864}-1=\frac{5}{864}\]
so the game is now favourable to us.

(ii) Our expected gain is
\[125\times\frac{1}{216}\times 0
+75\times\frac{1}{216}\times \frac{9}{4}
+15\times\frac{1}{216}\times 3
+1\times\frac{1}{216}\times 10 -1=\frac{205}{216}\]
so the game remains favourable to the banker.

(iii) The players will all play hearts (since the dice are
symmetric but the rewards are not) but there expected gain is
\[125\times\frac{1}{216}\times 0
+75\times\frac{1}{216}\times \frac{9}{4}
+15\times\frac{1}{216}\times 3
+1\times\frac{1}{216}\times 20 -1=\frac{215}{216}\]
so the game remains favourable to the banker.

\newpage\section*{Exercise~\ref{E;graph horses}}
A straight line sloping up if $a_{1}>a_{2}$
and down if $a_{2}>a_{1}$.

\newpage\section*{Exercise~\ref{E;negative expectation horse}}
Observe that
\begin{align*}
a_{n}Y-(a_{1}y_{1}+a_{2}y_{2}&+\dots+a_{n}y_{n})\\
&=(a_{n}-a_{1})y_{1}+(a_{n}-a_{2})y_{2}+\dots+(a_{n}-a_{n})y_{n}\\
&\leq 0
\end{align*}
with equality if and only if $y_{j}=0$ whenever $a_{j}>a_{n}$.
\newpage\section*{Exercise~\ref{E;expectation bet}}
(i) By our earlier discussion, I should bet on the horses
for which $p_{j}u_{j}=p_{j}/q_{j}$ is a maximum.

(ii) I wish to maximise
\[Y-\sum_{j=1}^{n}y_{j}p_{j}/q_{j}\]
subject to
\[Y=\sum_{j=1}^{n}y_{j}p_{j}/q_{j}\]
and this is equivalent to minimising $\sum_{j=1}^{n}y_{j}/q_{j}$
subject to the condition
$Y=\sum_{j=1}^{n}y_{j}/q_{j}$. By much the same arguments
as before, I should I should take bets on the horses
for which $p_{j}/q_{j}$ is a minimum and so
$q_{j}/p_{j}$ is a maximum.
\newpage\section*{Exercise~\ref{E;two bookmakers}}
If $A$ make a bet with $B$ on the $j$ th horse and $B$
can take it if and only if
\[\alpha p_{j}\leq\alpha^{-1}q_{j}^{-1}\]
ie
\[\frac{p_{j}}{q_{j}}\geq \frac{1}{\alpha^{2}}.\]
Thus $A$ can bet on some horse with $B$ if and only if
\[\max_{j}\frac{p_{j}}{q_{j}}\geq \frac{1}{\alpha^{2}}.\]

Similarly
$B$ can bet on some horse with $A$ if and only if
\[\max_{j}\frac{q_{j}}{p_{j}}\geq \frac{1}{\alpha^{2}}.\]
\newpage\section*{Exercise~\ref{E;high dice 1}}
(i) The expected score with one die is
\[\sum_{j=1}^{6}j\Pr(\text{throw $j$})
=\frac{1}{6}\sum_{j=1}^{6}j=\frac{21}{6}=\frac{7}{2}.\]

(ii) If the die shows $1$, $2$ or $3$ our expected score 
of $7/2$ with a new throw is
better than our expected score if we stick so we should throw.
If the die shows $4$, $5$ or $6$ our expected score 
of $7/2$ with a new throw is
less than our expected score if we stick so we should stick.

(iii) We can consider throwing a pair of dice to get $X$ and $Y$.
Our score $Z$ is given by $Z=X$ if $X\geq 4$
and $Z=Y$ if $X<4$. Our expected score in 
\emph{High Dice with Free Turn}
is
\begin{align*} 
{\mathbb E}Z&=
\sum_{j=4}^{6}j\Pr(X=j)+\sum_{j=1}^{3}\sum_{i=1}^{6}\Pr(X=j,\,Y=i)\\
&=\frac{15}{6}+\Pr(X\leq 3)\times\text{expected score with one die}\\
&\frac{5}{2}+\frac{1}{2}\times\frac{7}{2}=\frac{17}{4}.
\end{align*}
\newpage\section*{Exercise~\ref{E;high dice 2}}
Corrected by Nigel White and  Liangpeng Zhang. (Two seperate mistakes
so the reader is warned there may be more)

(i) It is obviously stupid to rethrow a die with higher score than
the other so we need only look at a die with the lowest score. By
Exercise 1.5.7 we should rethrow this dice if and only if it shows three
or less. We can consider throwing three of dice to get $X$, $Y$ and $Z$. 
Our
score $W$ is given by $Z=X+Y$ if $X,Y\geq 4$ and $W=\max\{X,Y\}+ Z$
if $\min\{X,Y \}<4$. Our expected score in High Dice with two dice is
\begin{align*}
W&=
\sum_{i\geq 4,j\geq 4}(i + j)\Pr(X = i, Y = j)
+\sum_{i\geq 4,3\geq j}(i + k)\Pr(X = i, Y = j, Z = k)\\
&\qquad\qquad+
\sum_{3\geq i,j\geq 4}(k + j)\Pr(X = i, Y = j, Z = k)\\
&\qquad\qquad
+\sum_{3\geq i,j\geq 3}(\max\{i, j\} + k)\Pr(X = i, Y = j, Z = k)\\
&=\sum_{i\geq 4}i\Pr(X = i) +\sum_{j\geq 4}j\Pr(y = j)
+\Pr(\min\{X, Y\}\leq 3){\mathbb E}Z\\
&\qquad\qquad+\sum_{i\leq 3,j\leq 3}\max\{i, j\}\Pr(X = i, Y = j)\\
&=2\times\frac{1}{6}(6+5+4)+\frac{3}{4}\times{7}{2}
+\left(\frac{5}{36}\times 3+\frac{3}{36}\times 2
+\frac{1}{36}\times 1\right)=\frac{593}{72}
\end{align*}



(ii) If we play high dice with two dice and free turn the we throw
once and if the total shown exceeds the expected value of high dice
with two dice (in this case a total of $9$ or greater) we do not throw
both dice (otherwise we throw both). If we do not throw both we now
look at the lowest die. If its value shown exceeds the value of high dice
with one die (in this case $4$ or greater) we stop otherwise we throw.

(iii) If we play high dice with three dice we throw once, remove the
die with highest score and follow tactics for high dice with two dice
and free score.
If we play high dice with three dice and free turn the we throw once
and if the total shown exceeds the expected value of high dice with
three dice we do not throw all three dice but remove the highest die
and play high dice with two die. (Otherwise we play high dice with
three dice.)
Continuing we obtain best tactics for any number of dice.



\newpage\section*{Exercise~\ref{E;high dice 3}}
We should fix all dice showing $6$ and throw the rest.
(Clearly we should fix the sixes.) If a large number of dice are thrown
it is very likely that a six will be thrown and (since we are happy 
to fix the six)
we are essentially playing a new game with fewer dice but the maximum
possible additional score.
\newpage\section*{Exercise~\ref{E;high dice 4}}
If the second player's first throw beats the first player's
final score she should stick (since she has won).
If the second player's first is beaten by the first player's
final score she can do no worse by throwing her lowest die
so she should. (If the player has final score
$12$ and she has, say, $(5,5)$ the second player could chose to 
do nothing; we have just given the simplest rule.)

If second player's first score equals the first player's
final score then she should throw the lowest dice
again if and only if the probability of strictly increasing
the number shown (and winning) is greater than
the probability of strictly decreasing
the number shown (and losing) so she should throw 
again if and only if her lowest die shows $1$, $2$
or $3$.
\newpage\section*{Exercise~\ref{E;loads of money}}
Unless $p_{k}=0$
you should place a very small sum of money on the $k$th
horse since you will then scoop the pool if it wins.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;check tote algebra}$^{*}$}
\newpage\section*{Exercise~\ref{E;little tote}}
(i) We have
\begin{align*}
f(y)&=\text{our expected profit}\\
&=-\text{expected profit other bettors}\\
&=\text{cost other bets}-\text{expected value other bets}\\
&=T-\left(\frac{p_{1}t_{1}(T+y)}{t_{1}+y}+p_{2}(T+y)\right)
\end{align*}

(ii) We have
\begin{align*}
f(y)&=(t_{1}+t_{2})-
\left(\frac{p_{1}t_{1}(t_{1}+t_{2}+y)}
{t_{1}+y}+p_{2}(t_{1}+t_{2}+y)\right)\\
&=t_{1}+t_{2}-p_{1}t_{1}-p_{2}t_{1}-p_{2}t_{2}-p_{2}y
-\frac{p_{1}t_{1}t_{2}}{t_{1}+y}\\
&=p_{1}t_{2}-p_{2}y-\frac{p_{1}t_{1}t_{2}}{t_{1}+y}.
\end{align*}
Thus
\begin{gather*}
f'(y)=-p_{2}+\frac{p_{1}t_{1}t_{2}}{(t_{1}+y)^{2}}\\
f''(y)=-\frac{2p_{1}t_{1}t_{2}}{(t_{1}+y)^{3}}<0
\end{gather*}
Thus $f'$ is strictly decreasing and $f'(y)>0$ for $y<Y_{0}$
$f'(y)<0$ for $y>Y_{0}$ where
\[\frac{p_{1}t_{1}}{(t_{1}+Y_{0})^{2}}=\frac{p_{2}t_{2}}{t_{1}^{2}}.\]

Thus $f(y)$ is increasing as $y$ increases from $0$ 
(but at a decreasing rate) to $Y_{0}$
and then decreases.

(iii) Observe that
\[p_{1}t_{2}-\frac{p_{1}t_{1}t_{2}}{t_{1}+y}\rightarrow 0\]
but
\[-p_{2}y\rightarrow-\infty\]
so
$f(y)\rightarrow-\infty$ as $y\rightarrow\infty$.

(iii) As we put more money on the first horse we drive
the odds on the first horse down and on the second horse up.
Eventually we drive the odds on the first horse below 
the correct odds and are now placing worse and worse bets.
The backers of the second horse watch with fascinated pleasure
as we use our money to drive the odds on their favoured horse
to astronomical heights.

\newpage\section*{Exercise~\ref{E;unity is strength}}
(i) Suppose $p_{1}/t_{1}\geq p_{2}/t_{2}$.
People will bet on the first horse until the total $z_{1}$
placed satisfies
\[\frac{p_{1}}{t_{1}+z_{1}}=\frac{p_{2}}{t_{2}}.\]
Thereafter the sums $z_{1}$, $z_{2}$ bet on
on the two horses will satisfy
\[\frac{p_{1}}{t_{1}+z_{1}}=\frac{p_{2}}{t_{2}+z_{2}}\]
so
\[\frac{t_{1}+z_{1}}{t_{2}+z_{1}}=\frac{p_{1}}{p_{2}}.\]
and everybody's expected winnings equal the amount they bet.

(ii) Once $z_{2}>0$ the tote ratios are the probabilities,
ie
\[\frac{t_{j}+z_{j}}{T+Z}=p_{j}\]
where $Z=z_{1}+z_{2}$, $T=t_{1}+t_{2}$

On the other hand if the syndicate bets $y_{1}$, $y_{2}$
the tote ratios are
\[\frac{t_{j}}{T+Y}=
\frac{(p_{j}t_{j})^{1/2}}{(p_{1}t_{1})^{1/2}+(p_{2}t_{2})^{1/2}}.\]

(iv) In the first case the new bettors are (a) knowledgeable
and (b) competing against each other so the move the odds
towards the true odds.

In the second case the new bettors are (a) knowledgeable and
(b) wish to extract the most money from the early bettors
so they move the odds to those which give the early bettors smallest
expected winnings.
\newpage\section*{Exercise~\ref{E;honest profit}}
(i) We have
\begin{align*}
f'(q)&=-\frac{A}{q^{2}}+\frac{B}{(1-q)^{2}}\\
&=\frac{A(1-q)^{2}-Bq^{2}}{q^{2}(1-q)^{2}}
\end{align*}
so $f'(q)<0$ for $0<q<q_{0}$ and $0<f'(q)$ for $q_{0}<q<1$
where $q_{0}$ is the positive solution
of
\[A(1-q)^{2}=Bq^{2}\]
and so
\[A^{1/2}(1-q_{0})=B^{1/2}q_{0}\]
ie
\[q_{0}=\frac{A^{1/2}}{A^{1/2}+B^{1/2}}.\]
(taking positive square roots throughout).

Thus $f$ has a unique minimum at $q_{0}$ with value
\[f(q_{0})=A\frac{A^{1/2}+B^{1/2}}{A^{1/2}}
+B\frac{A^{1/2}+B^{1/2}}{B^{1/2}}=(A^{1/2}+B^{1/2})^{2}.\]

(ii) Let $q=u_{1}^{-1}$ so
\[q+\frac{1}{u_{2}}=1\]
and $u_{2}=(1-q)^{-1}$.

The bookmaker wishes to minimise
\[f(q)=u_{1}p_{1}t_{1}+u_{2}p_{2}t_{2}
=\frac{p_{1}t_{1}}{q}+\frac{p_{2}t_{2}}{1-q}\]
so, by the first part she should take
\[\frac{1}{u_{1}}=\frac{(p_{1}t_{1})^{1/2}}
{(p_{1}t_{1})^{1/2}+(p_{2}t_{2})^{1/2}}  
\ \text{and}\ \frac{1}{u_{2}}=\frac{(p_{2}t_{2})^{1/2}}
{(p_{1}t_{1})^{1/2}+(p_{2}t_{2})^{1/2}}.\]

\newpage\section*{Exercise~\ref{E;tote no profit exact}}
Write
\[a=\frac{t_{1}}{p_{1}}=\frac{t_{2}}{p_{2}}\]
so
\[1=p_{1}+p_{2}=\frac{t_{1}}{a}=\frac{t_{2}}{a}=\frac{T}{a}\]
whence $a=T$.
Set $q=u_{1}^{-1}$ so that $u_{1}=q^{-1}$, $u_{2}=(1-q)^{-1}$.
Then (using Exercise~\ref{E;honest profit}),
\begin{align*}
f(q)&=p_{1}t_{1}u_{1}+p_{2}t_{2}u_{2}\\
&=\frac{ap_{1}^{2}}{q}+\frac{ap_{2}^{2}}{1-q}\\
&\geq {ap_{1}^{2}}{q_{0}}+\frac{ap_{2}^{2}}{1-q_{0}}\\
&=a(p_{1}+p_{2})^{2}=a=T
\end{align*}
with equality if and only if 
\[q=q_{0}=\frac{p_{1}}{p_{1}+p_{2}}=p_{1}\]
ie if and only if $u_{1}=1/p_{1}$ and $u_{2}=1/p_{2}$.

\newpage\section*{Exercise~\ref{E;honesty pays}}
Write $Y=y_{1}+y_{2}$.
Using Exercise~\ref{E;tote no profit exact} with
\[u_{1}=\frac{t_{1}+y_{1}}{T+Y},\ u_{2}=\frac{t_{2}+y_{2}}{T+Y}\]
we see that
our expected profit
\[
p_{1}t_{1}\frac{T+Y}{t_{1}+y_{1}}+p_{2}t_{2}\frac{T+Y}{t_{2}+y_{2}}
\geq T\]
with equality if and only if
\[u_{1}=\frac{1}{p_{1}},\ u_{2}=\frac{1}{p_{2}}\]
ie
\[\frac{t_{1}+y_{1}}{T+Y}=p_{1},
\ \frac{t_{2}+y_{2}}{T+Y}=p_{2}.\]
Now
\begin{align*}
\frac{t_{j}+y_{j}}{T+Y}=p_{j}
&\Leftrightarrow t_{j}+y_{j}=Tp_{j}+Yp_{j}\\
&\Leftrightarrow y_{j}=Yp_{j}
\end{align*}
so the expected value of our bet is strictly greater
than $T$ unless $y_{j}=Yp_{j}$.
\newpage\section*{Exercise~\ref{E;honesty pays 2}}
Observe that if we take the expected value of our bet is
\[u_{1}p_{1}t_{1}+u_{2}p_{2}t_{2}+\dots+u_{n}p_{n}t_{n}\]
and if we take $t_{j}=p_{j}T$
\[u_{1}p_{1}t_{1}+u_{2}p_{2}t_{2}+\dots+u_{n}p_{n}t_{n}\geq T\]
for all choices of $u_{j}$.

If we choose particular $t_{j}$, then we know that we
can find $u_{j}>0$ with 
 \[u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}=1.\]
and
\[u_{1}p_{1}t_{1}+u_{2}p_{2}t_{2}+\dots+u_{n}p_{n}t_{n}
=(p_{1}t_{1})^{1/2}+(p_{2}t_{2})^{1/2}+\dots+(p_{n}t_{n})^{1/2}.\]


Now
\[\frac{d\ }{dt}At^{1/2}+B(t_{0}-t)^{1/2}
=\frac{A(t_{0}-t)^{1/2}-Bt^{1/2}}{2t^{1/2}(t_{0}-t)^{1/2}}\]
and by looking at the sign of the derivative we see that
there is a unique maximum for $t_{0}>t>0$ when
\[A(t_{0}-t)^{1/2}=Bt^{1/2}\]
ie
\[At^{-1/2}=B(t_{0}-t)^{1/2}\]
so by our usual argument
\[u_{1}p_{1}t_{1}+u_{2}p_{2}t_{2}+\dots+u_{n}p_{n}t_{n}\]
is maximised uniquely when
\[p_{j}=at_{j}\]
ie $t_{j}=p_{j}T$.
Thus we should take $t_{j}=p_{j}T$.

Now suppose that
\[u_{1}^{-1}+u_{2}^{-1}+\dots+u_{n}^{-1}=U.\]
If we set $v_{j}=Uu_{j}$ then
\[v_{1}^{-1}+v_{2}^{-1}+\dots+v_{n}^{-1}=1\]
and the expected value of our bet is
\[U(v_{1}p_{1}t_{1}+v_{2}p_{2}t_{2}+\dots+v_{n}p_{n}t_{n})\]
so the maximisation problem is unchanged.

\newpage\section*{Exercise~\ref{E;bookmaker versus bettor}}
(i) This was shown in Exercise~\ref{E;honesty pays 2}.
If $t_{k}=p_{k}T$ the expected value of the bet
is
\[u_{1}p_{1}t_{1}+u_{2}p_{2}t_{2}+\dots+u_{n}p_{n}t_{n}
=u_{1}p_{1}^{2}T+u_{2}p_{2}^{2}T+\dots+p_{n}^{2}T
\geq TK\]
with equality only if $u_{j}=p_{j}^{-1}K$ when the
value of the bet is $TK$.

(ii) This is essentially the same result as (i).
The bookie should choose $u_{j}=p_{j}^{-1}K$
and then the bettor $t_{k}=p_{k}T$. 
The value of the bet is $TK$.

\newpage\section*{Exercise~\ref{E;Oller}}
(i) We are seeking to maximise
\[(1-\alpha)\sum_{j=1}^{n}t_{j}\frac{T+Y}{t_{j}+y_{j}}p_{j}\]
which is the same as seeking to maximise
\[\sum_{j=1}^{n}t_{j}\frac{T+Y}{t_{j}+y_{j}}p_{j}.\]
The recommendations are unaltered.

If we bet a small amount we are essentially offered a 
payout ratio on the $j$th horse given by
\[u_{j}=(1-\alpha)\frac{Y}{y_{j}}.\]
We can only make a profit if
\[\max u_{j}p_{j}>1.\]
Thus, if
\[ (1-\alpha)\frac{Y}{y_{j}}<1\]
for all $j$ there is no way we can make a positive
expected profit.

If we bet a small amount last we are essentially offered a 
payout ratio on the $j$th horse given by
\[u_{j}=\frac{Y-b}{y_{j}}.\]
We should bet on the horse which has largest
value of $(Y-b)p_{j}/y_{j}$
ie the largest value of $p_{j}/y_{j}$ as before.

If we bet first we do not know the final payout ratios so
as before we should bet $p_{j}T$ on the $j$th horse. 


\newpage\section*{Exercise~\ref{E;tote first many horses}}
(i) By Theorem~\ref{T,tote large} observing that $T+Y$ is constant,
\[\frac{p_{1}y_{1}}{t_{1}+y_{1}}+\frac{p_{2}y_{2}}{t_{2}+y_{2}},\]
attains a unique maximum for $y_{1}+y_{2}+Y$ and $y_{1},y_{2}\geq 0$
at $y_{1}=y_{1}^{*}$, $y_{2}=y_{2}^{*}=Y-y_{1}^{*}$ where
\[y_{1}^{*}=Y\ \text{for} 
\ \frac{p_{1}t_{1}}{(t_{1}+Y)^{2}}\geq \frac{p_{2}}{t_{2}}\]
and, otherwise
\[\frac{p_{1}t_{1}}{(t_{1}+y_{1}^{*})^{2}}
=\frac{p_{1}t_{2}}{(t_{2}+y_{2}^{*})^{2}}.\]

(ii) As usual, we assume that a minimum is attained.
By (i) this maximum must be at $y_{j}=y_{j}^{*}$ obeying the conditions
\[\frac{p_{j}t_{j}}{(t_{j}+y_{j}^{*})^{2}}\geq \frac{p_{k}}{t_{k}}
\ \text{and}
\ y_{k}^{*}=0,\]
or
\[\frac{p_{j}t_{j}}{(t_{j}+y_{j}^{*}+y_{k}^{*})^{2}}<\frac{p_{k}}{t_{k}}
\ \text{and}
\ \frac{p_{j}t_{j}}{(t_{j}+y_{j}^{*})^{2}}
=\frac{p_{k}t_{k}}{(t_{k}+y_{k}^{*})^{2}}.\]

(iii) Since 
\[\frac{p_{1}}{t_{1}}\geq\frac{p_{2}}{t_{2}}\geq
\dots\geq\frac{p_{n}}{t_{n}}\]
we can find an $r$
with $1\leq r\leq n$ such that
\[\frac{p_{1}t_{1}}{(t_{1}+y_{1}^{*})^{2}}
=\frac{p_{2}t_{2}}{(t_{2}+y_{2}^{*})^{2}}
=\dots=\frac{p_{r}t_{r}}{(t_{r}+y_{r}^{*})^{2}}\]
and, if $r\leq n-1$,
\[y_{r+1}^{*}=y_{r+2}^{*}=\dots=y^{*}_{n}=0,
\ \text{and}
\ \frac{p_{r}t_{r}}{(t_{r}+y_{r}^{*})^{2}}\geq \frac{p_{r+1}}{t_{r+1}}.\]

(iv) Suppose 
\[\frac{p_{1}}{t_{1}}\geq\frac{p_{2}}{t_{2}}\geq
\dots\geq\frac{p_{n}}{t_{n}}\]
Starting from zero slowly increase your bet $y_{1}$
on the first horse until
\[\frac{p_{1}t_{1}}{(t_{1}+y_{1})^{2}}=\frac{p_{2}}{t_{2}}\]
Now slowly increase your bets
$y_{1}$ and $y_{2}$ on the first two horses in such a way that
\[\frac{p_{1}t_{1}}{(t_{1}+y_{1})^{2}}
=\frac{p_{2}t_{2}}{(t_{2}+y_{2})^{2}}\]
until
\[\frac{p_{1}t_{1}}{(t_{1}+y_{1})^{2}}
=\frac{p_{2}t_{2}}{(t_{2}+y_{2})^{2}}=\frac{p_{3}}{t_{3}}.\]
Now slowly increase your bets
$y_{1}$, $y_{2}$, $y_{3}$ on the first three horses in such a way that
\[\frac{p_{1}t_{1}}{(t_{1}+y_{1})^{2}}
=\frac{p_{2}t_{2}}{(t_{2}+y_{2})^{2}}
=\frac{p_{3}t_{3}}{(t_{3}+y_{3})^{2}}.\]

Once we are betting on all the horses we have
\[t_{j}+y_{j}=(p_{j}t_{j})^{1/2}\]
so the expected value (to the other bettors) of their bet
is 
\begin{align*}
E&=\sum_{j=1}^{n}\frac{p_{j}t_{j}}{t_{j}+y_{j}}(T+Y)
&=(T+Y)\sum_{j=1}^{n}(p_{j}t_{j})^{1/2}\\
&\left(\sum_{j=1}^{n}(p_{j}t_{j})^{1/2}\right)^{2}
\end{align*}
so our expected winnings are
\[\sum_{j=1}^{n}t_{j}-\left(\sum_{j=1}^{n}(p_{j}t_{j})^{1/2}\right)^{2}\]
independent of how much more we bet. There is no reason to
bet more.
\newpage\section*{Exercise~\ref{E;trivial probability}}
(i) $\Pr(\{\omega\})=\sum_{\rho\in\omega}p(\rho)=p(\omega)$.

(ii) $\Pr(A)=\sum_{\omega\in A\setminus B}p(\omega)
+\sum_{\omega\in B}p(\omega)\geq \sum_{\omega\in B}p(\omega)=\Pr(B).$

(iii) $\Omega\supseteq A\supseteq \emptyset$ so, by~(ii),
\[1=\Pr(\Omega)\geq \Pr(A)\geq\Pr(\emptyset)=0.\]

(iv) We have
\[\Pr(A\cup B)=\sum_{\omega\in A\cup B}p(\omega)
=\sum_{\omega\in A}p(\omega)+\sum_{\omega\in B}p(\omega)
=\Pr(A)+\Pr(B).\]

\newpage\section*{Exercise~\ref{E;where does it break?}}
Since $[(r-1)2^{-n},r2^{-n})$ is a translate of $[0,2^{-n})$
it should have the same probability for each $1\leq r\leq 2^{-n}$.
Now
\begin{align*}
1&=\Pr([0,1))=\Pr\left(\bigcup_{r=1}^{2^{n}}
[(r-1)2^{-n},r2^{-n})\right)\\
&=\sum_{r=1}^{2^{n}}\Pr\big([(r-1)2^{-n},r2^{-n})\big)
=2^{n}\Pr\big([0,2^{-n})\big)
\end{align*}
so
\[\Pr\big([(r-1)2^{-n},r2^{-n})\big)=\Pr\big([0,2^{-n})\big)=2^{-n}.\]

Since $\{\omega\}\subset[(r-1)2^{-n},r2^{-n})$ for some $r$,
$0\leq\Pr(\{\omega\})\leq 2^{-n}$ for all $n$ and so
$\Pr(\{\omega\})=0$ for all $\omega\in[0,1)$.

\newpage\section*{Exercise~\ref{E;table dice}}

\begin{table}
\begin{center}
\begin{footnotesize}
\tabcolsep=3pt
\begin{tabular}{cccccc}
A&A&B&B&C&C\\
B&C&C&A&A&B\\
C&B&A&C&B&A\\
D&C&D&C&B&B
\end{tabular}
\tabcolsep=6pt
\end{footnotesize}
\end{center}
\caption{Possible deals with $3$ cards}
\end{table}
\begin{table}
\begin{center}
\begin{footnotesize}
\tabcolsep=3pt
\begin{tabular}{cccccccccccccccccccccccc}
A&A&A&A&A&A&B&B&C&D&C&D&B&B&C&D&C&D&B&B&C&D&C&D\\
B&B&C&D&C&D&A&A&A&A&A&A&C&D&B&B&D&C&C&D&B&B&D&C\\
C&D&B&B&D&C&C&D&B&B&D&C&A&A&A&A&A&A&D&C&D&C&B&B\\
D&C&D&C&B&B&D&C&D&C&B&B&D&C&D&C&B&B&A&A&A&A&A&A\\
D&C&D&C&B&B&D&C&D&C&B&B&D&C&D&C&B&B&A&A&A&A&A&A\\
E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E&E
\end{tabular}
\tabcolsep=6pt
\end{footnotesize}
\end{center}
\caption{Possible deals with $5$ cards, $E$ last}
\end{table} 
There are $24$ deals with $E$ last so there must be $24$
deals with $E$ in $r$th place
with $r$ taking one of the $4$ values $1,\,2,\,3,\,4,\,5$
so $120=24\times 5$
deals in all.

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;picture binomial two four}$^{*}$}

\newpage\section*{Exercise~\ref{E;trinomial}}
(i) Let $B(n,r,b,g)$ be the number of ways
that we can arrange the cards if cards of the
same colour are indistinguishable. Now suppose we
number the $n$ cards so that they are all distinguishable.
The red cards can now be arranged in $r!$
ways,
the blue cards can be arranged in $b!$ ways
and the green cards in $g!$. 
Thus the total number of ways of arranging our cards
without exchanging colours  is $r!b!g!$
and the total number of ways of arranging our cards
in any way we wish is $B(n,r,b,g)r!b!g!$. But we already
know that the total number of ways of arranging our cards
in any way we wish is $n!$ so
\[B(n,r,b,g)=\frac{n!}{r!b!g!}\]
as required.

(ii) Suppose we have $m_{j}$ cards of colour $j$
and $\sum_{j=1}^{k}m_{j}=n$.
Let $B(n,{\mathbf m})$ be the number of ways
that we can arrange the cards if cards of the
same colour are indistinguishable. Now suppose we
number the $n$ cards so that they are all distinguishable.
The $j$ colour cards can now be arranged in $n_{j}!$
ways.
Thus the total number of ways of arranging our cards
without exchanging colours  is $m_{1}!m_{2}!\dots m_{k}!$
and the total number of ways of arranging our cards
in any way we wish is $B(n,{\mathbf m})m_{1}!m_{2}!\dots m_{k}!$. But we already
know that the total number of ways of arranging our cards
in any way we wish is $n!$ so
\[B(n,{\mathbf m})=\frac{n!}{m_{1}!m_{2}!\dots m_{k}!}.\]
\newpage\section*{Exercise~\ref{E;binomial theorem}}
(i) We have
\[(x+y)^{n}=(x+y)(x+y)(x+y)\dots(x+y)\]
so the coefficient of $x^{n-r}y^{r}$ is the number of ways we can select
$x$ from $r$ distinct terms $(x+y)$ ie ${\displaystyle\binom{n}{r}}$.

(ii) If $r+b+g\neq n$ the coefficient is $0$. 

If $r+b+g=n$ we have
\[(x+y+z)^{n}=(x+y+z)(x+y+z)(x+y+z)\dots(x+y+z)\]
so the coefficient of $x^{r}y^{b}z^{g}$ is the number of ways we can select
$x$ from $r$ distinct terms $(x+y)$, $y$ from $b$ distinct remaining terms
and $z$ from the $g$ remaining so the coefficient is
\[\frac{n!}{r!b!g!}.\]
\newpage\section*{Exercise~\ref{E;many sided dice}}
\begin{table}
\begin{center}
\begin{footnotesize}
\tabcolsep=3pt
\begin{tabular}{cccccccccccccccccc}
H&H&H&H&H&H&H&H&T&T&T&T&T&T&T&T\\
H&H&H&H&T&T&T&T&H&H&H&H&T&T&T&T\\
H&H&T&T&H&H&T&T&H&H&T&T&H&H&T&T\\
H&T&H&T&H&T&H&T&H&T&H&T&H&T&H&T\\
\end{tabular}
\tabcolsep=6pt
\end{footnotesize}
\end{center}
\caption*{Two-sided die thrown four times}
\end{table}
\begin{table}
\begin{center}
\begin{footnotesize}
\tabcolsep=3pt
\begin{tabular}{cccccccccccccccccc}
A&A&A&A&B&B&B&B&C&C&C&C&D&D&D&D\\
A&B&C&D&A&B&C&D&A&B&C&D&A&B&C&D
\end{tabular}
\tabcolsep=6pt
\end{footnotesize}
\end{center}
\caption*{four-sided die thrown twice}
\end{table}

To get a four-sided die thrown thrice we need a first row
consisting of $16$ $A$'s followed by $16$ $B$'s and so on
with the table just given repeated four times underneath.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;flattery}$^{*}$}
\section*{Exercise~\ref{E;one snap}$^{*}$ 
(see Exercise~\ref{E;Nicholas})}
\newpage\section*{Exercise~\ref{E;algebra of bets}}
A bet $a$ times as large as another should be
$a$ times as valuable.

The sum of the values of two separate bets should be the same
as the value of the bets made together.

If every outcome of one bet is no worse than the
outcome
of the other bet the value of the first bet cannot be 
less than the value of the second.
\newpage\section*{Exercise~\ref{E;indicators}}
\[
{\mathbb I}_{A^{c}}(\omega)=
\begin{cases}
0&\text{if $\omega\in A$,}\\
1&\text{if $\omega\notin A$,}
\end{cases}
\]
and
\[
1-{\mathbb I}_{A}(\omega)=
\begin{cases}
1-1=0&\text{if $\omega\in A$,}\\
1-0=1&\text{if $\omega\notin A$,}
\end{cases}
\] 
so 
\[{\mathbb I}_{A^{c}}(\omega)=1-{\mathbb I}_{A}(\omega)\]
for all $\omega$ and so
\[{\mathbb I}_{A^{c}}=1-{\mathbb I}_{A}.\]

(1) Thus
\begin{align*}
{\mathbb I}_{(A\cup B)^{c}}&=1-{\mathbb I}_{A\cup B}
=1-({\mathbb I}_{A}+{\mathbb I}_{B}-{\mathbb I}_{A}{\mathbb I}_{B})\\
&=1-{\mathbb I}_{A}-{\mathbb I}_{B}+{\mathbb I}_{A}{\mathbb I}_{B})
=(1-{\mathbb I}_{A})(1-{\mathbb I}_{B})\\
&={\mathbb I}_{A^{c}}{\mathbb I}_{B^{c}}={\mathbb I}_{A^{c}\cap B^{c}}
\end{align*}
and so $(A\cup B)^{c}=A^{c}\cap B^{c}$.

(2) Similarly 
\begin{align*}
{\mathbb I}_{(A\cap B)^{c}}&=1-{\mathbb I}_{A\cap B}
=1-{\mathbb I}_{A}{\mathbb I}_{B}\\
&=(1-{\mathbb I}_{A})+(1-{\mathbb I}_{B})
-(1-{\mathbb I}_{A})(1-{\mathbb I}_{B})\\
&={\mathbb I}_{A^{c}}+{\mathbb I}_{B^{c}}
-{\mathbb I}_{A^{c}}{\mathbb I}_{B^{c}}
={\mathbb I}_{A^{c}\cup B^{c}}
\end{align*}
and so $(A\cap B)^{c}=A^{c}\cup B^{c}$.

(3) Finally
\[{\mathbb I}_{(A^{c})^{c}}=1-{\mathbb I}_{A^{c}}
=1-(1-{\mathbb I}_{A})={\mathbb I}_{A}\]
so $(A^{c})^{c}=A$.

We could have obtained (2) from the (1) and (3)
by the argument
\[A\cap B=(A^{c})^{c}\cap (B^{c})^{c}= A^{c}\cup B^{c}.\]

We have
\begin{align*}
{\mathbb I}_{A\setminus B}&={\mathbb I}_{A\cap B^{c}}
={\mathbb I}_{A}{\mathbb I}_{B^{c}}\\
&={\mathbb I}_{A}(1-{\mathbb I}_{B})
={\mathbb I}_{A}-{\mathbb I}_{A}{\mathbb I}_{B}
\end{align*}
and, noting that ${\mathbb I}_{C}^{2}={\mathbb I}_{C}$,
\begin{align*}
{\mathbb I}_{A \bigtriangleup B}
&={\mathbb I}_{(A\setminus B)\cup(A\setminus B)}
={\mathbb I}_{A\setminus B}+{\mathbb I}_{B\setminus A}
-{\mathbb I}_{A\setminus B}{\mathbb I}_{B\setminus A}\\
&={\mathbb I}_{A}-{\mathbb I}_{A}{\mathbb I}_{B}
+{\mathbb I}_{B}-{\mathbb I}_{A}{\mathbb I}_{B}
-({\mathbb I}_{A}-{\mathbb I}_{A}{\mathbb I}_{B})
({\mathbb I}_{B}-{\mathbb I}_{A}{\mathbb I}_{B})\\
&={\mathbb I}_{A}+{\mathbb I}_{B}-2{\mathbb I}_{A}{\mathbb I}_{B}+0
={\mathbb I}_{A}+{\mathbb I}_{B}-2{\mathbb I}_{A}{\mathbb I}_{B}
\end{align*}
(Or think what the answer should be and then verify.)

By inspection,
${\mathbb I}_{\Omega}=1$ and ${\mathbb I}_{\emptyset}=0$.

\newpage\section*{Exercise~\ref{E;musical glasses}}
(i) $\sum_{\omega\in\Omega}{\mathbb I}_{D}(\omega)
=\sum_{\omega\in D}1=|D|.$

(ii) We have 
\begin{align*}
|A\cup B\cup C|
&=\sum_{\omega\in\Omega}{\mathbb I}_{A\cup B\cup C}(\omega)\\
&=\sum_{\omega\in\Omega}\big(
{\mathbb I}_{A}(\omega)+{\mathbb I}_{B}(\omega)+{\mathbb I}_{C}(\omega)\\
&\qquad -{\mathbb I}_{A\cap B}(\omega)-{\mathbb I}_{B\cap C}(\omega)
-{\mathbb I}_{C\cap A}(\omega)+{\mathbb I}_{A\cap B\cap C}(\omega)\big)\\
&=|A|+|B|+|C|\\
&\qquad-|A\cap B|-|B\cap C|-|C\cap A|
+|A\cap B\cap C|.
\end{align*}

(iii) The number of students who are mathematicians
or wear glasses or are musical (or any combination)
is the number of mathematicians plus the number
of glasses wearers plus the number of musicians
correcting for counting those with two of those properties
twice by subtracting the number of musical mathematicians
plus the number of mathematical glasses wearers
plus the the number of goggled musicians
correcting for the fact that those who have all three
properties have been counted three times and then
subtracted three times by adding them in again.

(iv) If $n$ has a factor $r$ then $n=rs$ with $r\leq n^{1/2}$
and/or  $s\leq n^{1/2}$. Thus if $n$ is composite it has a prime factor 
no greater than $n^{1/2}$. If $p<49$ and $p$ is not divisible by
$2$, $3$ or $5$ it must be prime.
Let $A_{q}$ be the set of strictly positive integers less than $49$
divisible by $q$. Then
\begin{gather*}
|A_{2}|=24,\ |A_{3}|=16,\ |A_{5}|=9,\\ 
|A_{2}\cap A_{3}|=|A_{6}|=8,
\ |A_{3}\cap A_{5}|=|A_{15}|=3,
|A_{2}\cap A_{5}|=|A_{10}|=4,\\
|A_{2}\cap A_{3}\cap A_{5}|=|A_{30}|=1.
\end{gather*}
Thus
\[|A_{2}\cup A_{3}\cup A_{5}|=24+16+9-8-3-4+1\]
and there are $35$ integers between $1$ and $48$ divisible
by at least one of $2$, $3$ or $5$. Thus $48-35-1=12$
integers between $2$ and $48$ are not divisible
by $2$, $3$ or $5$. Since $2$, $3$ and $5$ are prime
it follows that there are $15$ primes less than $49$.

(v) We have
\begin{align*}
{\mathbb I}_{\bigcup_{i=1}^{4}A_{i}}
&=1-{\mathbb I}_{(\bigcap_{i=1}^{4}A_{i})^{c}}\\
&=1-\prod_{i=1}^{4}{\mathbb I}_{A_{i}^{c}}\\
&=1-\prod_{i=1}^{4}(1-{\mathbb I}_{A_{i}})\\
&=\sum_{i=1}^{4}{\mathbb I}_{A_{i}}
-\sum_{i<j}{\mathbb I}_{A_{i}}{\mathbb I}_{A_{j}}\\
&\qquad\qquad
+\sum_{i<j<k}{\mathbb I}_{A_{i}}{\mathbb I}_{A_{j}}{\mathbb I}_{A_{k}}
+{\mathbb I}_{A_{1}}{\mathbb I}_{A_{2}}
{\mathbb I}_{A_{3}}{\mathbb I}_{A_{4}}\\
&=\sum_{i=1}^{4}{\mathbb I}_{A_{i}}
-\sum_{i<j}{\mathbb I}_{A_{i}\cap A_{j}}\\
&\qquad\qquad+\sum_{i<j<k}{\mathbb I}_{A_{i}\cap A_{j}\cap A_{k}}
-{\mathbb I}_{A_{1}\cap A_{2}\cap A_{3}\cap A_{4}}.
\end{align*}
Thus
\begin{align*}
\left|\bigcup_{i=1}^{4}A_{i}\right|&=
{\mathbb E}{\mathbb I}_{\bigcup_{i=1}^{4}A_{i}}\\
&=\sum_{i=1}^{4}{\mathbb E}{\mathbb I}_{A_{i}}
-\sum_{i<j}{\mathbb E}{\mathbb I}_{A_{i}\cap A_{j}}\\
&\qquad\qquad+\sum_{i<j<k}
{\mathbb E}{\mathbb I}_{A_{i}\cap A_{j}\cap A_{k}}
-{\mathbb E}{\mathbb I}_{A_{1}\cap A_{2}\cap A_{3}\cap A_{4}}\\
&=\sum_{i=1}^{4}|A_{i}|
-\sum_{i<j}|A_{i}\cap A_{j}|\\
&\qquad\qquad+\sum_{i<j<k}
|A_{i}\cap A_{j}\cap A_{k}|
-|A_{2}\cap A_{2}\cap A_{3}\cap A_{4}|
\end{align*}

(vi) If $n$ has a factor $r$ then $n=rs$ with $r\leq n^{1/2}$
and/or  $s\leq n^{1/2}$. Thus if $n$ is composite it has a prime factor 
no greater than $n^{1/2}$. If $p\leq100$ and $p$ is not divisible by
$2$, $3$, $4$ or $7$ it must be prime.
Let $A_{q}$ be the set of strictly positive no greater than than $100$
divisible by $q$. Then
\begin{gather*}
|A_{2}|=50,\ |A_{3}|=33,\ |A_{5}|=20,\ |A_{7}|=14\\ 
|A_{2}\cap A_{3}|=|A_{6}|=16,
\ |A_{2}\cap A_{5}|=|A_{10}|=10
\ |A_{2}\cap A_{7}|=|A_{14}|=7,\\
|A_{3}\cap A_{5}|=|A_{15}|=6,
\ |A_{3}\cap A_{7}|=|A_{21}|=4,
\ |A_{5}\cap A_{7}|=|A_{35}|=2,\\
|A_{2}\cap A_{3}\cap A_{5}|=|A_{30}|=3,
\ |A_{2}\cap A_{3}\cap A_{7}|=|A_{42}|=2,\\
|A_{2}\cap A_{5}\cap A_{7}|=|A_{70}|=1,
\ |A_{3}\cap A_{5}\cap A_{7}|=|A_{105}|=0\\
|A_{2}\cap A_{3}\cap A_{5}\cap A_{7}|=0
\end{gather*}
Thus
\[|A_{2}\cup A_{3}\cup A_{5}\cup A_{7}|=50+33+20+14-16-10-7-6-4-2+3+2+1=78\]
and there are $78$ integers between $1$ and $100$ divisible
by at least one of $2$, $3$, $5$ or $7$. Thus $100-78-1=21$
integers between $2$ and $100$ are not divisible
by $2$, $3$, $5$ or $7$. Since $2$, $3$, $5$ and $7$ are prime
it follows that there are $25$ primes less than $100$.

\newpage\section*{Exercise~\ref{E;Nicholas}}
(i) Paint the cards numbered $i$, $j$ and $k$ blue
and the rest red.

(ii) $A_{1}\cap A_{2}\cap A_{3}$ is the event that the first
card dealt is $1$, the second $2$and the third $3$.
\[\Pr(A_{1}\cap A_{2}\cap A_{3})=
\frac{1}{n}\times\frac{1}{n-1}\times\frac{1}{n-2}.\]

(iii) There are $n\times (n-1)\times (n-2)$ of
choosing three distinct  integers in some order
and
\[\binom{n}{3}=\frac{n\times (n-1)\times (n-2)}{3!}\]
of obtaining  three distinct  integers in a particular order
so
\[\sum_{i<j<k}\Pr(A_{i}\cap A_{j}\cap A_{k})
=\sum_{i<j<k}\frac{1}{n}\times\frac{1}{n-1}\times\frac{1}{n-2}
=\frac{1}{3!}.\]

(iv) The number of ways of choosing
integers $i_{1},\,i_{2},\,\dots,\, i_{r}$ with 
$1\leq i_{1}<i_{2}<\dots<i_{r}\leq n$
is $\binom{n}{r}$.

If $1\leq i_{1}<i_{2}<\dots<i_{r}\leq n$
\[\Pr(A_{i_{1}}\cap A_{i_{2}}\cap \dots\cap A_{i_{r}})
=\frac{1}{n}\times\frac{1}{n-1}\times\dots
\times \frac{1}{n-r+1}.\]

Thus
\[\sum_{i_{1}<i_{2}<\dots<i_{r}}
\Pr(A_{i_{1}}\cap A_{i_{2}}\cap \dots\cap A_{i_{r}})
=\binom{n}{r}\frac{1}{n}\times\frac{1}{n-1}\times\dots
\times \frac{1}{n-r+1}=\frac{1}{r!}\]

Using the inclusion-exclusion formula
\begin{align*}
\Pr&\left(\bigcup_{i}A_{i}\right)\\
&=\sum_{i}\Pr(A_{i})-\sum_{i<j}\Pr(A_{i}\cap A_{j})
+\sum_{i<j<k}\Pr(A_{i}\cap A_{j}\cap A_{k})-\dots\\
&=\frac{1}{1!}-\frac{1}{2!}+\frac{1}{3!}-\dots+(-1)^{n-1}\frac{1}{n!}.
\end{align*}

(v) $\bigcup_{i}A_{i}$ is the event that at least one card is
dealt in the same place as the number it bears. Thus
the probability that no card is dealt in the
same place as the number it bears is
\[1-\frac{1}{1!}+\frac{1}{2!}-\frac{1}{3!}
+\dots+(-1)^{n}\frac{1}{n!}.\]

(vi) Let $p_{n}$ be the probability that no card 
from a pack of $n$ is dealt in the
same place as the number it bears. Then
(to the number of places shown)
\begin{align*}
p_{1}&=0\\
p_{2}&=.50000\\
p_{3}&=.33333\\
p_{4}&=.37500\\
p_{5}&=.36667\\
p_{6}&=.36806
\end{align*}
Setting $x=-1$ in Exercise~\ref{E;Taylor exponential}~(iv)
we obtain
\[1-\frac{1}{1!}+\frac{1}{2!}-\frac{1}{3!}
+\dots+(-1)^{n}\frac{1}{n!}\approx e^{-1}\]
for large $n$.
We observe that
\[e^{-1}=0.36788\]
to the number of places shown.

(vii) To a very good level of approximation 
the probability that no pair will consist of identical cards
is $e^{-1}$ and the probability that 
at least one pair will consist of identical cards
is
\[1-e^{-1}\approx.63212\]

(viii) The probability that the first $k$ cards
will be dealt in their correct place and the remainder
will all be misplaced is
\begin{align*}
\frac{1}{n}&\times\frac{1}{n-1}\times\dots\times\frac{1}{n-k-1}\\
&\qquad\qquad\times\Pr(\text{a pack of $n-k$ cards will be dealt out of order})\\
 &\approx\frac{1}{n}\times\frac{1}{n-1}\times\dots
\times\frac{1}{n-k-1}e^{-1}.
\end{align*}
By symmetry
the probability that a particular $k$ cards
will be dealt in their correct place and the remainder
will all be misplaced is approximately
\[\frac{1}{n}\times\frac{1}{n-1}\times\dots\times\frac{1}{n-k-1}e^{-1}.\]
There are $\binom{n}{k}$ ways of choosing $k$ cards
so the probability that some set of $k$ cards
will be dealt in their correct place and the remainder
will all be misplaced is approximately
\[\binom{n}{k}\times
\frac{1}{n}\times\frac{1}{n-1}\times\dots\times\frac{1}{n-k-1}e^{-1}
=\frac{e^{-1}}{k!}.\]
\newpage\section*{Exercise~\ref{E;procrastination}}
(i) Let $A_{i}$ be the event that the committee can meet on the $i$th
date.
\begin{small}
\begin{align*}
\Pr&(\text{committee can meet})
=\Pr\left(\bigcup_{i=1}^{n}A_{i}\right)\\
&\sum_{1\leq i\leq n}\Pr(A_{i})
-\sum_{1\leq i<j\leq n}\Pr(A_{i}\cap A_{j})
+\sum_{1\leq i<j<k\leq n}\Pr(A_{i}\cap A_{j}\cap A_{k})
-\dots\\
&=\binom{n}{1}\Pr(A_{1})-\binom{n}{2}\Pr(A_{1}\cap A_{2})
+\binom{n}{2}\Pr(A_{1}\cap A_{2}\cap A_{3})-\dots\\
&+\binom{n}{1}p^{m}-\binom{n}{2}p^{2m}+\ldots+(-1)^{n-1}\binom{n}{n}p^{nm}
\end{align*}
\end{small}

We have
\[P(1/2,8,30)=\sum_{r=1}^{30}(-1)^{r-1}a_{r}\]
with
\[a_{r}=\binom{30}{r}2^{8r}=\binom{30}{r}(256)^{-1}\]
so $a_{r}>0$ and $a_{r+1}/a_{r}\leq 30/256<1$.
Thus
\[P(1/2,8,30)\approx\sum_{r=1}^{k}(-1)^{r-1}a_{r}\]
 with error less in magnitude less than $a_{r+1}$.
(Truncating an alternating decreasing sum
produces an error less than the first term neglected.

Now $a_{1}\approx 0.117$ and $a_{2}\approx 0.006$
so $P(1/2,8,30)\approx .12$.

(ii) As before
\begin{align*}
\Pr&(\text{committee can meet})
=\Pr\left(\bigcup_{i=1}^{n}A_{i}\right)\\
&=\binom{n}{1}\Pr(A_{1})-\binom{n}{2}\Pr(A_{1}\cap A_{2})
+\binom{n}{2}\Pr(A_{1}\cap A_{2}\cap A_{3})-\dots\\
&=\binom{n}{1}\left(\frac{k}{n}\right)^{m}
-\binom{n}{2}\left(\frac{k(k-1)}{n(n-1)}\right)^{m}
+\binom{n}{3}\left(\frac{k(k-1)(k-2)}{n(n-1)(n-2)}\right)^{m}\\
&\ \ -\dots+
(-1)^{k-1}\binom{n}{k}\left(\frac{k(k-1)(k-2)\dots 1}
{n(n-1)(n-2)\dots (n-k+1)}\right)^{m}.
\end{align*}


Observe that if $m(n-k)<n$ then there must be a possible meeting
so $Q(k,m,n)=1$, but if $p<1$ then there is always a strictly
positive probability that the y cannot meet so $P(p,m,n)<1$.
Thus
$P(k/n,m,n)\neq Q(k,m,n)$
whenever $m(n-k)<n$. (Of course even if  $m(n-k)>n$
the inequality will usually hold but this is harder to prove.)
[Thanks to Nigel White for a correction.]

If $k=15$, $m=8$, $n=30$ then it is still true that
the terms are decreasing
in size and alternating in sign so the first term
(which is the same) dominates. Essentially
the terms which are affected by non-independence are very small.
\newpage\section*{Exercise~\ref{E;not product 1}}
\begin{align*}
\Pr(A)&=\Pr(B)=\Pr(\text{two heads or two tails in succession})\\
&=1/4+1/4=1/2.
\end{align*}
We have
\begin{align*}
\Pr(A\cap B)&=\Pr(\text{three heads or three tails})\\
&=1/8+1/8=1/4=\Pr(A)\Pr(B)
\end{align*}
so $A$ and $B$ are independent.
\newpage\section*{Exercise~\ref{E;not product 2}}
(i) Since $(A^{c}\cap B)\cap(A\cap B)=\emptyset$
and $(A^{c}\cap B)\cup(A\cap B)=B$,
\[\Pr(A^{c}\cap B)+\Pr(A\cap B)=\Pr(B)\]
Thus if $A$ and $B$ are independent
\begin{align*}
\Pr(A^{c}\cap B)&=\Pr(B)-\Pr(A\cap B)=\Pr(A)-\Pr(A)\Pr(B)\\
&=(1-\Pr(A))\Pr(B)=\Pr(A^{c})\Pr(B)
\end{align*}
so $A^{c}$ and $B$ are independent.

Since $B$ and $A^{c}$ are independent so are $B^{c}$ and $A^{c}$.

(ii) If $A$ and $B$ are independent then, by~(i), so are $A^{c}$
and $B^{c}$.
If further $A\cup B=\Omega$ then $A^{c}\cap B^{c}=\emptyset$
so
\[0=\Pr(A^{c}\cap B^{c})=\Pr(A^{c})\Pr(B^{c})\]
and at least one of $A^{c}$ and $B^{c}$
has probability $0$ and so  at least one of $A$ and $B$
has probability $1$.

(iii) Let $p_{j}=\Pr(\{\omega_{j}\})$. If $A$ and $B$ have the properties
stated
\[p_{3}=\Pr(A\cap B)=pq\]
so
\[p_{4}=Pr(B)-p_{3}=(1-p)q\]
and, by independence of complements
\[p_{5}=\Pr(A^{c}\cap B^{c})=\Pr(A^{c})\Pr(B^{c})
=(1-p)(1-q).\]

Reversing our arguments we see that if we set 
$p_{1}=p_{2}=p(1-q)/2$, $p_{3}=pq$, $p_{4}=(1-p)q$
and $p_{5}=(1-p)(1-q)$ they satisfy the stated conditions.
(And indeed we could have guessed the solution if we had been awake.)

In  Lemma~\ref{L;product spaces}, 
writing $|X|$ for the number of elements in $X$,
\[|\Omega|=|U|\times|V|\geq |A|\times |B|.\]
and this is not true here.
\newpage\section*{Exercise~\ref{E;three coins}}
(i) Just as in Exercise~\ref {E;not product 1},
\begin{gather*}
\Pr(A)=\Pr(B)=\Pr(C)=1/2\\
\Pr(A\cap B)=1/4=\Pr(A)\Pr(B),\ \ \Pr(B\cap C)=1/4=\Pr(B)\Pr(C),\\
\Pr(C\cap A)=1/4\Pr(C)\Pr(A).
\end{gather*}
However, if $A$ and $B$ occur, then all the throws are heads
or all the throws are tails so $C$ occurs. Thus
\[A\cap B\cap C=A\cap B\]
and
\[\Pr(A\cap B\cap C)=1/4\neq 1/8=\Pr(A)\Pr(B)\Pr(C).\]

(ii) Let $p_{r}=\Pr(\{\omega_{r}\})$. Then
\[p_{4}=\Pr(A\cap B\cap C)=\Pr(A)\Pr(B)\Pr(C)=1/27\]
and
\begin{gather*}
p_{2}+p_{4}=\Pr(A\cap B)=\Pr(A)\Pr(B)=1/9,\\
p_{3}+p_{4}=\Pr(A\cap C)=\Pr(A)\Pr(C)=1/9
\end{gather*}
so
\[p_{2}=p_{3}=2/27.\]
Now
\begin{gather*}
p_{1}+p_{2}+p_{3}+p_{4}=\Pr(A)=1/3\\
p_{2}+p_{4}+p_{5}=\Pr(B)=1/3\\
p_{3}+p_{4}+p_{6}=\Pr(C)=1/3
\end{gather*}
so
\[p_{1}=5/27,\ p_{5}=p_{6}=2/9\]
whilst since
\[p_{1}+p_{2}+p_{3}+p_{4}+p_{5}+p_{6}+p_{7}=1\]
we have $p_{7}=5/27$.

Since all the $p_{j}$ are positive and the working is reversible
we have found an appropriate set of probability $\Pr$
(and it is unique). We observe that
\[\Pr(B\cap C)=p_{4}=2/27\neq 1/9=\Pr(B)\Pr(C).\]
\newpage\section*{Exercise~\ref{E;independent complement}}
If $A$, $B$ and $C$ are independent then
we know that they are independent in pairs
so (see eg Exercise~\ref{E;not product 2})
$A$, $B$ and $C^{c}$ are independent in pairs.
Further
\begin{align*}
\Pr(A\cap B\cap C^{c})&=\Pr(A\cap B)-\Pr(A\cap B\cap C)\\
&=\Pr(A)\Pr(B)-\Pr(A)\Pr(B)\Pr(C)\\
&=\Pr(A)\Pr(B)\big(1-\Pr(C)\big)\\
&=\Pr(A)\Pr(B)\Pr(C^{c})
\end{align*}
\newpage\section*{Exercise~\ref{E;product three}}
We seek to prove that if $U$, $V$ and $W$ are probability spaces
with associated probabilities ${\Pr}_{U}$, ${\Pr}_{V}$
and ${\Pr}_{V}$ then we can define a 
probability $\Pr$ on $\Omega=U\times V\times W$ in such a way that
\[\Pr(\{(u,v,w)\})={\Pr}_{U}(\{u\}){\Pr}_{V}(\{v\}){\Pr}_{W}(\{w\})\]
for all $(u,v,w)\in\Omega$. Further, with
this choice of $\Pr$, if
$E\subseteq U$, $F\subseteq V$ and $G\subseteq W$
the events 
\[E\times V\times W,\ U\times F\times W,
\ U\times V\times G\]
are independent.

To this end observe that
\begin{align*}
\sum_{(u,v,w)\in\Omega}&{\Pr}_{U}(\{u\}){\Pr}_{V}(\{v\}){\Pr}_{W}(\{w\})\\
&=\sum_{u\in U}{\Pr}_{U}(\{u\})\sum_{v\in V}{\Pr}_{V}(\{v\})
\sum_{w\in W}{\Pr}_{W}(\{w\})
\end{align*}
and ${\Pr}_{U}(\{u\}){\Pr}_{V}(\{v\}){\Pr}_{W}(\{w\})\geq 0$
for all $(u,v,w)\in\Omega$ so $\Pr$ is indeed a probability.

Further
\begin{align*}
\Pr(E\times V&\times W\cap U\times F\times W
\cap U\times V\times G)
=\Pr(E\times F\times G)\\
&=\sum_{(u,v,w)\in E\times F\times G}
{\Pr}_{U}(\{u\}){\Pr}_{V}(\{v\}){\Pr}_{W}(\{w\})\\
&=\sum_{u\in E}{\Pr}_{U}(\{u\})\sum_{v\in F}{\Pr}_{V}(\{v\})
\sum_{w\in G}{\Pr}_{W}(\{w\})\\
&=\Pr(E\times V\times W)\Pr(U\times F\times W)
\Pr(U\times V\times G)
\end{align*}
and independence in pairs can be proved similarly.
Thus the events 
\[E\times V\times W,\ U\times F\times W,
\ U\times V\times G\]
are indeed independent.

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;little different expectation}$^{*}$}
\newpage\section*{Exercise~\ref{E;accumulator}}
The argument is not very different to that of
Lemma~\ref{L;product spaces}.

Observe that $\Pr(\{\omega_{(j,k)}\})=p_{j}q_{k}\geq 0$
and
\[\sum_{\omega\in\Omega}\Pr(\{\omega\})
=\sum_{j=1}^{J}\sum_{k=1}^{K}p_{j}q_{k}
=\sum_{j=1}^{J}p_{j}\sum_{k=1}^{K}q_{k}=1^{2}=1\]

\begin{align*}
\Pr(X=c,\,Y=d)&=\sum_{c_{j}=c,\,d_{k}=d}
\Pr(\{\omega_{(j,k)}\})\\
&=\sum_{c_{j}=c,\,d_{k}=d}p_{j}q_{k}
=\sum_{c_{j}=c}p_{j}\sum_{d_{k}=d}q_{k}\\
&=\Pr(X=c)\Pr(Y=d)
\end{align*}
so $X$ and $Y$ are independent and
${\mathbb E}X{\mathbb E}Y={\mathbb E}XY$.

${\mathbb E}X$ is the value the bet on the first race if we place 
$1$ unit. ${\mathbb E}Y$ is the value the bet on the second race if we place 
$1$ unit. ${\mathbb E}XY$ is the value of our bet if we place 
$1$ unit on it and the bet our winnings on the second race.

\newpage\section*{Exercise~\ref{E;expectations do not multiply}}
\[{\mathbb E}X={\mathbb E}Y=\tfrac{1}{2}\times 1+\tfrac{1}{2}\times 0\]
Now
\[X(\omega_{1})Y(\omega_{1})=X(\omega_{2})Y(\omega_{2})=0\]
so $XY=0$ and 
\[{\mathbb E}XY=0\neq\tfrac{1}{4}={\mathbb E}X{\mathbb E}Y\]
On the other hand $X^{2}=X$ so
\[{\mathbb E}X^{2}=\tfrac{1}{2}\neq\tfrac{1}{4}=({\mathbb E}X)^{2}.\]
\newpage\section*{Exercise~\ref{E;expectation multiply oddly}}
\begin{align*}
\Pr(X=0,\ Y=0)&=\Pr(\{\omega_{5}\})=\frac{1}{5}\\
&\neq \frac{1}{25}=\Pr(\{\omega_{5}\})^{2}
\Pr(X=0)\Pr(Y=0)
\end{align*}
so $X$ and $Y$ are not independent.
\begin{gather*}
\Pr(XY=1)=\Pr(\{\omega_{1},\,\omega_{4}\})=\frac{2}{5}\\
\Pr(XY=-1)=\Pr(\{\omega_{2},\,\omega_{3}\})=\frac{2}{5}\\
\Pr(XY=0)=\Pr(\{\omega_{5}\})=\frac{1}{5}\\
{\mathbb E}X={\mathbb E}Y={\mathbb E}XY
\frac{2}{5}\times 1+\frac{2}{5}\times (-1)=0
\end{gather*}
so
${\mathbb E}XY={\mathbb E}X{\mathbb E}Y$.
\newpage\section*{Exercise~\ref{E;St Petersburg shell game}}
(iii) Paint the high cards red and the low cards blue.
The probability asked for in~(i) is the probability
that if I deal $3$ cards from a pack of $4$ red
and $4$ blue cards I get all blue or all red ie
\[2\times\Pr(\text{all blue})=
2\times \frac{4}{8}\times\frac{3}{7}\times\frac{2}{6}
=\frac{1}{7}.\]

The probability asked for in~(i) is the probability
that if I deal $6$ cards from a pack of $4$ red
and $4$ blue cards I get $3$ blue and $3$ red.
The probability of any particular hand of this type
(say $RRRBBB$)
is
\[\frac{4}{8}\times\frac{3}{7}\times\frac{2}{6}\times\frac{4}{5}
\times\frac{3}{4}\times\frac{2}{3}
=\frac{1}{14}\times\frac{2}{5}=\frac{1}{35}\]
There are
\[\binom{6}{3}=\frac{6\times 5\times 4}{3\times 2\times 1}=20\]
such hands so the probability that the hand 
will contain three of the four
smallest cards and three of the four
largest cards is $20/35=4/7$.
\newpage\section*{Exercise~\ref{E;independent functions}}
(i) Write
\[A=\{\omega\in\Omega\,:X(\omega)\in U\}
\ \text{and}
\ B=\{\omega\in\Omega\,:Y(\omega)\in V\}.\]
Then
\begin{align*}
\Pr(A \cap B)&=\sum_{X(\omega)\in U,\,Y(\omega)\in V}\Pr(\{\omega\})\\
&=\sum_{u\in U,\,v\in V}\Pr(X(\omega)=u,\ Y(\omega)=v)\\
&=\sum_{u\in U,\,v\in V}\Pr(X(\omega)=u)\Pr(Y(\omega)=v)\\
&=\sum_{u\in U}\Pr(X(\omega)=u)\sum{v\in V}\Pr(Y(\omega)=v)\\
&=\Pr(A)\Pr(B)
\end{align*}

(ii) Suppose $s,\,t\in{\mathbb R}$. Then,
using~(i) and writing
\[f^{-1}(s)=\{x\,:\,f(x)=s\},\ g^{-1}(t)=\{y\,:\,g(y)=t\},\]
we have
\begin{align*}
\Pr(f(X)(\omega)&=s,\ g(Y)(\omega)=t)
=\Pr\big(X(\omega)\in f^{-1}(s),\ Y(\omega)\in g^{-1}(t)\big)\\
&=\Pr\big(X(\omega)\in f^{-1}(s)\big)\Pr\big(Y(\omega)\in g^{-1}(t)\big)\\
&=\Pr(f(X)(\omega)=s)\Pr(g(Y)(\omega)=t)
\end{align*}

(iii) If $X_{1}$, $X_{2}$, \dots, $X_{n}$ are independent
random variables and $U_{1}$, $U_{2}$, \dots, $U_{n}$ 
are subsets  of ${\mathbb R}$
then the events $\{\omega\in\Omega\,:X_{j}(\omega)\in U_{j}\}$
are independent.

We can prove this by induction on $n$. It is certainly true
for $n=1$. If it is true for all $n\leq m-1$ then the result
for $n=m$ follows from the observation that
\begin{align*}
\Pr&\left(\bigcap_{j=1}^{m}X_{j}^{-1}(U_{j})\right)
=\sum_{X_{j}(\omega)\in U_{j}\ \text{for all $j$}}\Pr(\{\omega\})\\
&=\sum_{u_{j}\in U_{j}\ \text{for all $j$}}
\Pr(X_{1}(\omega)=u_{1},\ X_{2}(\omega_{2})=u_{2},\ \dots,
\ X_{m}(\omega)=u_{m} )\\
&=\sum_{u_{j}\in U_{j}\ \text{for all $j$}}
\prod_{j=1}^{m}\Pr(X_{j}(\omega)=u_{j})\\
&=\sum_{u_{1}\in U_{1}}\sum_{u_{2}\in U_{2}}\dots\sum_{u_{m}\in U_{m}}
\prod_{j=1}^{m}\Pr(X_{j}(\omega)=u_{j})\\
&=\prod_{j=1}^{m}\sum_{u_{j}\in U_{j}}\Pr(X_{j}(\omega)=u_{j})\\
&=\prod_{j=1}^{m}\Pr\big(X_{j}^{-1}(U_{j})\big).
\end{align*}

If $X_{1}$, $X_{2}$, \dots, $X_{n}$ are independent
random variables and $f_{j}:{\mathbb R}\rightarrow{\mathbb R}$
then the sets 
\[\{\omega\in\Omega\,:\, f_{j}(X_{j})(\omega)=t_{j}\}
=\{\omega\in\Omega\,:X_{j}(\omega)\in f^{-1}_{j}(t_{j})\}\]
are independent and so the random variables $f_{j}(X_{j})$
are independent.

\newpage\section*{Exercise~\ref{E;fountain}}
\begin{gather*}
\Pr(X=1)=\Pr(\text{initial head})=1/2\\
\Pr(X=-1)=\Pr(\text{initial tail})=1/2\\
\Pr(Y=2)=\Pr(\text{initial head})=1/2\\
\Pr(Y=-2)=\Pr(\text{initial tail})=1/2\\
\Pr(Z=1)=\Pr(\text{second head})=1/2\\
\Pr(Z=-1)=\Pr(\text{second tail})=1/2\\
\Pr(W=1)=\Pr(\text{HH})+\Pr(\text{TT})=1/4+1/4=1/2\\
\Pr(W=-1)=\Pr(\text{TH})+\Pr(\text{HT})=1/4+1/4=1/2\\
\Pr(V=1)=\Pr(\text{HHH})+\Pr(\text{TTT})=1/8+1/8=1/4\\
\Pr(V=-1)=1-\Pr(W=1)=3/4
\end{gather*}
Thus
\begin{gather*}
\Pr(X=1)=\Pr(Z=1)=\Pr(W=1)=1/2;\\
\Pr(X=-1)=\Pr(Z=-1)=\Pr(W=-1)=1/2;\\
\Pr(X=1)=1/2\neq 0=\Pr(Y=1);\\
\Pr(X=1)=1/2\neq 1/4=\Pr(V=1);\\
\Pr(V=1)=1/4\neq 0=\Pr(Y=1)
\end{gather*}
and the results follow.
\newpage\section*{Exercise~\ref{E;non standard dice}}
(i) If $2\leq r\leq 7$
\[\Pr(\text{throw $r$})=\sum_{s=1}^{r-1}
\Pr(\text{first die $s$, second $r-s$})\\
\frac{r-1}{36}.\]
By symmetry, if $7\leq r\leq 12$,
\[\Pr(\text{throw $r$})=\frac{13-r}{36}.\]

(ii) We have
\begin{align*}
(x+x^{2}+x^{3}+x^{4}+x^{5}+x^{6})&\times
(x+x^{2}+x^{3}+x^{4}+x^{5}+x^{6})=\\
x^{2}+x^{3}+x^{4}+x^{5}+x^{6}+x^{7}&\\
+x^{3}+x^{4}+x^{5}+x^{6}+x^{7}&+x^{8}\\
+x^{4}+x^{5}+x^{6}+x^{7}&+x^{8}+x^{9}\\
+x^{5}+x^{6}+x^{7}&+x^{8}+x^{9}+x^{10}\\
+x^{6}+x^{7}&+x^{8}+x^{9}+x^{10}+x^{11}\\
+x^{7}&+x^{8}+x^{9}+x^{10}+x^{11}+x{12}=\\
x^{2}+2x^{3}+3x^{4}+4x^{5}+5x^{6}+6x^{7}&
+5x^{8}+4x^{9}+3x^{10}+2x^{11}+x{12}
\end{align*}

(iii) Let $X=Y+Z$ with $Y$ the throw on the first die,
$Z$ on the second.
\begin{gather*}
\Pr(X=3)=\Pr(Y=2,Z=1)=\Pr(Y=2)\Pr(Z=1)=6/36\\
\Pr(X=4)=\Pr(Y=3,Z=1)=\Pr(Y=3)\Pr(Z=1)=2/36\\
\Pr(X=6)=\Pr(Y=5,Z=1)=\Pr(Y=5)\Pr(Z=1)=2/36\\
\Pr(X=7)=\Pr(Y=2,Z=5)=\Pr(Y=2)\Pr(Z=5)=3/36\\
\Pr(X=14)=\Pr(Y=7,Z=7)=\Pr(Y=7)\Pr(Z=7)=1/36\\
\Pr(X=15)=\Pr(Y=7,Z=8)=\Pr(Y=7)\Pr(Z=8)=1/36
\end{gather*}
and
\begin{small}
\begin{align*}
\Pr(X=8)&=\Pr(Y=2,Z=6)+\Pr(Y=3,Z=5)+\Pr(Y=7,Z=1)\\
&=\Pr(Y=2)\Pr(Z=6)+\Pr(Y=3)\Pr(Z=5)\\
&\qquad\qquad+\Pr(Y=7)\Pr(Z=1)
=6/36\\
\Pr(X=9)&=\Pr(Y=2,Z=7)+\Pr(Y=3,Z=6)\\
&=\Pr(Y=2)\Pr(Z=7)+\Pr(Y=3)\Pr(Z=7)
=4/36\\
\Pr(X=10)&=\Pr(Y=2,Z=8)+\Pr(Y=5,Z=5)+\Pr(Y=7,Z=3)\\
&=\Pr(Y=2)\Pr(Z=8)+\Pr(Y=5)\Pr(Z=5)\\
&\qquad\qquad+\Pr(Y=7)\Pr(Z=3)
=5/36\\
\Pr(X=11)&=\Pr(Y=3,Z=8)+\Pr(Y=5,Z=6)\\
&=\Pr(Y=3)\Pr(Z=8)+\Pr(Y=5)\Pr(Z=6)
=2/36\\
\Pr(X=12)&=\Pr(Y=5,Z=7)+\Pr(Y=7,Z=5)\\
&=\Pr(Y=5)\Pr(Z=7)+\Pr(Y=7)\Pr(Z=5)=2/36\\
\Pr(X=13)&=\Pr(Y=7,Z=6)+\Pr(Y=5,Z=8)\\
&=\Pr(Y=7)\Pr(Z=6)+\Pr(Y=5)\Pr(Z=8)=2/36
\end{align*}
\end{small}
(iv) Exactly the same calculations show that
\begin{align*}
(3x^{2}&+x^{3}+x^{5}+x^{7})(2x+x^{5}+x^{6}+x^{7}+x^{8})\\
&=6x^{3}+2x^{4}+2x^{6}+3x^{7}+6x^{8}+4x^{9}+5x^{10}\\
&\qquad\qquad+2x^{11}+2x^{12}+2x^{13}+x^{14}+x^{15}
\end{align*}

(v) We have
\begin{align*}
(x+x^{2}+x^{3}&+x^{4}+x^{5}+x^{6})^{2}\\
&=x(1+x)(1+x^{2}+x^{4})x(1+x+x^{2})(1+x^{3})\\
&=x(1+x^{3})(1+x^{2}+x^{4})x(1+x)(1+x+x^{2})\\
&=(x+x^{3}+x^{4}+x^{5}+x^{6}+x^{8})(x+2x^{2}+2x^{3}+x^{4})
\end{align*}
so using the parallelism between coefficient and probability
calculations (or just rechecking) we find
that $(1,3,4,5,6,8)$, $(1,2,2,3,3,4)$ are non-standard dice
with the same probabilities for totals as standard dice.

(vi) A non-standard pair of dice correspond to
a pair of polynomials $P$ and $Q$ each of degree $5$
with positive integer coefficients such that
\[P(x)Q(x)=(1+x+x^{2}+x^{3}+x^{4}+x^{5})^{2}\]
Now
\[(x-1)^{2}P(x)Q(x)=(x^{6}-1)^{2}=
\left(\prod_{k=1}^{6}(x-\omega^{k})\right)^{2}\]
so
\[P(x)Q(x)=\left(\prod_{k=1}^{5}(x-\omega^{k})\right)^{2}\]
with $\omega=\exp(\pi i/3)$.

The non-real roots of a real polynomial occur in conjugate pairs
so $P(x)$ and $Q(x)$ must be products of $x+1$, 
$(x-\omega)(x-\bar{\omega})=(x^{2}+x+1)$
and  $(x-\omega^{2})(x-\bar{\omega}^{2})=(x^{2}-x+1)$.
By working through the possibilities, we see that
the only choices for $P$ and $Q$ are those that 
have already been considered in (v).
\newpage\section*{Exercise~\ref{E;Hungarian dice}}
Suppose such a die exists.

We must have
\[11^{-1}=\Pr(\text{total $2$})=\Pr(\text{throw $(1,1)$})=p_{1}^{2}\]
Thus $p_{1}=11^{-1/2}$. Similarly $p_{6}=11^{-1/2}$.
Thus
\begin{align*}
\Pr(\text{total $7$})&\geq \Pr(\text{throw $(1,6)$ or $(6,1)$})\\
&= p_{1}p_{6}+p_{6}p_{1}=2/11
\end{align*}

Thus no such die exists.
\newpage\section*{Exercise~\ref{E;Simplejack}}
My proposed solution was wrong (and I think I underestimated
the work involved). Here with my thanks is a solution from
Matthew Towers.


The player, P, and the banker, B, draw cards uniformly at random with
replacement from the set $\{2, 3, 4\}$.  Each gets one card face up.
P may continue to draw more cards, up to a total of 3.  When they stop,
B must draw if they have 2 or 3 and must not draw if they have a 4.  The
scoring is then
\begin{itemize}
    \item If P has a total of at least 7 they get $-1$, regardless of
        B's score.
    \item If P has $<7$ and B has at least 7, P gets 1.
    \item If both P and B have less then 7 then if the scores are
        equal P gets 0, otherwise P gets 1 if they have the higher score
        and -1 if they have the lower score.
\end{itemize}

We then have the following payoffs and expected values:

\mbox{}

\begin{tabular}{c|ccc|ccc|c|ccc}
     & \multicolumn{6}{c}{B's 1st card} & & & & \\
     & \multicolumn{3}{c}{2} & \multicolumn{3}{c}{3} & 4 &
     \multicolumn{3}{c}{P's EV if B's 1st card is}  \\
     & \multicolumn{6}{c}{B's next card} & & &  &\\
    P stops at & 2 & 3 & 4 & 2 & 3 & 4 & & 2 & 3 & 4 \\
    \hline
    3 & $-1$ & $-1$ & $-1$ & $-1$ & $-1$ & 1 & $-1$ & $-1$ & $-1/3$ &
    $-1$ \\
    4 & 0 & $-1$ & $-1$ & $-1$ & $-1$ & 1 & 0 & $-2/3$ & $-1/3$ &  0\\
    5 & 1 & 0 & $-1$ & 0 & $-1$ & 1 & 1 & 0 & 0 & 1\\
    6 & 1 & 1 & 0 & 1 & 0 & 1 & 1 & $2/3$ & $2/3$ & 1 \\
    $\geqslant 7$ & $-1$ & $-1$ & $-1$ & $-1$ & $-1$ & $-1$ & $-1$ &
    $-1$ & $-1$ & $-1$
\end{tabular}

\mbox{}

P's first card could be 2, 3, or 4.
\begin{itemize}
    \item P's first card is 2.  They should draw again, getting 4, 5, or
        6. Suppose they have 4.
        \begin{itemize}
            \item If B has 4 then stopping gets 0 and
        drawing gets an expected value of $(1/3)\cdot 1 + (2/3)\cdot                            
        (-1) = -1/3$ so P should stop.
            \item If B has 3, stopping has expected value $-1/3$ (from
                the table) and drawing has expected value\\ $(1/3)\cdot    
 \text{(expected score if B has 3 and P stops at 6)} +                           
                (2/3)\cdot (-1) =-4/9$ so P shold hold.
            \item If B has 2, stopping has an expected value of $-2/3$
                from the table and drawing has expected value\\
                $(1/3)\text{(expected score if B has 2 and P stops at                           
                6)} + (2/3)\cdot (-1) = -4/9$ so P should draw.
        \end{itemize}
        Now suppose P has 5 after the second draw. It can't make sense
        to draw again, so their expectation is $1/3$ (conditioning on
        the three possibilities for B's card)
         Finally if $P$ has 6 after the 2nd draw, they should not draw
         again. The expected score is $7/9=(1/3)(2/3)                                           
         + (1/3)(2/3) + (1/3)(3/3)$ from the table.

         Following this strategy, with first card 2 P has an EV of
         $(1/3)((1/3)\cdot 0 + (1/3)(-4/9)+(1/3)(-1)) + (1/3)(1/3) +                            
         (1/3)(7/0) = 23/81$.
     \item P's first card is 3.  If B has 2 or 4 then clearly P must
         draw. If B has 3 then stopping has expectation $(1/3)(-1) +                            
         (1/3)(-1) + (1/3)\cdot 1 = -1/3$ and drawing expects
         $(1/3)\cdot 0 + (1/3)(2/3) + (1/3)(-1) = -1/9$ from the table,
         so P should draw in this case too.  Their expectation is
$(1/3)\text{(expectation if they stop at 5)} +                                         
         (1/3)\text{(expectation if they stop at 6)} +                                          
         (1/3)\text{(expectation if they stop at 7)}$ which from the
         table is $(1/3)(1/3)+(1/3)(7/9) + (1/3)(-1) = 1/27$.
     \item P's first card is 4. Stopping has an expected value of
        $-2/3$ if B has 2, $-1/3$ if B has 3, and 0 if B has 4. If P
        draws, the expectations are as in the first bullet point when P
        had 4 after their second draw. Thus P should stop if B has 3 or
        4, expecting $-1/3$ and 0), and draw if B has 2, expecting
        $-4/9$.  Their expected score is
        $(1/3)(-4/9)+(1/3)(-1/3)+(1/3)\cdot 0 = -7/27$.
\end{itemize}

Overall the expected score for $P$ is
$(1/3)(23/81)+(1/3)(1/27)+(1/3)(-7/27) =5/243$. 



(ii) If the player follows the rule `draw if your hand is $4$
or less', she will usually end up with a $6$ and the banker will usually
end up with a $6$, so the player  
will usually win.



\newpage\section*{Exercise~\ref{E;Quiz}}
(i) You should attack all the questions with $p_{j}=1$
first (since your probability of losing is $0$)
and all the questions with $p_{j}=0$ last.

(ii) Let $X_{r}$ be your expected winnings
from the $r$ th question in oder. Your probability
of actually answering the $r$th question correctly is
\[p_{j(1)}p_{j(2)}\dots p_{j(r)}\]
so
\[{\mathbb E}X_{r}=p_{j(1)}p_{j(2)}\dots p_{j(r)}a_{j(r)}\]
and your total expected winnings is
\begin{align*}
{\mathbb E}\sum_{r=1}^{n}X_{r}
&=\sum_{r=1}^{n}{\mathbb E}X_{r}\\
&=\sum_{r=1}^{n}p_{j(1)}p_{j(2)}\dots p_{j(r)}a_{j(r)}.
\end{align*}

(iii) From~(ii)
\begin{align*}
e_{A}-e_{B}&=qp_{i}a_{i}+qp_{i}p_{j}a_{j}-qp_{j}a_{j}+qp_{j}p_{i}a_{i}\\
&=q\big(p_{i}(1-p_{j})a_{i}-p_{j}(1-p_{i})a_{j}\big)
\end{align*}

We prefer plan $A$ to plan~$B$ if $e_{A}-e_{B}>0$
so if
\[q\big(p_{i}(1-p_{j})a_{i}-p_{j}(1-p_{i})a_{j}\big)>0\]
so if
\[\frac{a_{i}p_{i}}{1-p_{i}}>\frac{a_{j}p_{j}}{1-p_{j}}.\]
The remaining cases follow the same pattern.

(iv) If we do not follow this strategy, part~(iii) shows
there is a better strategy.

(v) If $p_{1}=p_{2}=\dots=p_{n}$
then $p_{j}$ we should choose the
questions in decresing order of the $a_{j}$.
This is reasonable since the probability
of sucessfully answering exactly $r$ questions does not
depend on order so we wish to get the largest rewards first.

If  $a_{1}=a_{2}=\dots=a_{n}$ we should choose the questions in decreasing
order of $p_{j}$. This is reasonable since we
are now trying to make the game last as long as possible.

If the $p_{j}$ are very small then we should choose the
question for which $a_{j}p_{j}$ is largest.
This is reasonable since we are very unlikely to
get the chance to answer more than one question.

\newpage\section*{Exercise~\ref{E;bridge}}
The probability of a hand with three aces in specified
places and the remainder non aces
(for example $AAANNNNNNNNNN$ where $A$ is an ace and $N$
a non-ace) is
\[\frac{4}{52}\times\frac{3}{51}\times\frac{2}{50}
\times\frac{48}{49}\times\frac{47}{48}\times\dots\times\frac{38}{39}
=\frac{24\times 38}{52\times 51\times 50\times 49}\]
and there are
\[\binom{13}{3}=\frac{13\times 12\times 11}{3\times 2}
=13\times 22\]
such hands.
The probability of exactly three aces is thus
\[\frac{13\times 22\times 24\times 37}
{52\times 51\times 50\times 48}
\approx 0.0412.\]

\newpage\section*{Exercise~\ref{E;ball}}
If some one stakes $1$ probability of winning is $1/32$ and
if they win they get $28$ so the expected gain
is
\[28\times\frac{1}{32}-1=\frac{7}{8}-1=-\frac{1}{8}\]
(ie `they lost one eighth part of all the money they played for').

\begin{align*}
\Pr(\text{point}\ &\text{comes up in 22 games})\\
&=1-\Pr(\text{point does not come up up in 22 games})\\
&=1-\big(\Pr(\text{point does not come up up in one game})^{22}\\
&=1-\left(\frac{31}{32}\right)^{22}\\
&\approx 0.5027
\end{align*}
Thus the Master of the Balls is betting at favourable odds.
(But not very favourable, he must much prefer his standard
game.)
\newpage\section*{Exercise~\ref{E;one side Tchebychev}}
Since $f$ is increasing $f(a)\geq f(x)$ for $x\geq a$.
Since $f(x)>0$ and $f(a)$, it follows that $1\leq f(x)/f(a)$ 
for $x\geq a$ and $0\leq f(x)/f(a)$ for all $x<a$. Thus
\[{\mathbb I}_{(a,\infty)}(x)\leq \frac{f(x)}{f(a)}\]
for all $x$.

It follows that
\begin{align*}
\Pr(X\geq a)&={\mathbb E}{\mathbb I}_{(a,\infty)}(X)\\
&\leq{\mathbb E}\left(\frac{f(X)}{f(a)}\right)\\
&=\frac{{\mathbb E}f(X)}{f(a)}.
\end{align*}

\newpage\section*{Exercise~\ref{E;no better Tchebychev}}
Observe that $\Pr(\omega_{j})\geq 0$ and
\[\Pr(\omega_{1})+\Pr(\omega_{2})+\Pr(\omega_{3})=1.\]

\[{\mathbb E}X=0(1-p)+ap/2-ap/2=0\]
and
\[\var X={\mathbb E}X^{2}=0(1-p)+a^{2}p/2-a^{2}p/2=a^{2}.\]
Thus
\[\Pr(|X-{\mathbb E}X|)=\Pr(\omega_{2})+\Pr(\omega_{3})=p
=\frac{\var X}{a^{2}}.\]

\newpage\section*{Exercise~\ref{E;basic variance}}
(i) Observe that
\begin{align*}
{\mathbb E}(X-a)^{2}
&={\mathbb E}\big((X-{\mathbb E}X)+({\mathbb E}X-a)\big)^{2}\\
&={\mathbb E}\big((X-{\mathbb E}X)^{2}+2({\mathbb E}X-a)(X-{\mathbb E}X)
({\mathbb E}X-a)^{2}\big)^{2}\\
&={\mathbb E}\big(X-{\mathbb E}X)^{2}
+2({\mathbb E}X-a){\mathbb E}(X-{\mathbb E}X)
+{\mathbb E}({\mathbb E}X-a)^{2}\\
&={\mathbb E}\big(X-{\mathbb E}X)^{2}
+2({\mathbb E}X-a)0
+{\mathbb E}({\mathbb E}X-a)^{2}\\
&==\var X+({\mathbb E}X-a)^{2}.
\end{align*}

Thus ${\mathbb E}(X-a)^{2}$ is minimised by taking $a={\mathbb E}X$.

(ii) We have
\[\var X+\var Y=\var X+\var (-1)X=\var X+(-1)^{2}\var X=2\var X.\]
and
\[\var(X+Y)=\var 0=0.\]

Since $X$ and $Y$ are not independent Lemma~\ref{L;properties variance}~(iv)
is not relevant.

(iii) We have
\begin{align*}
\var(&X+Y)={\mathbb E}\big(X+Y-{\mathbb E}(X+Y)\big)^{2}
={\mathbb E}(X+Y-{\mathbb E}X-{\mathbb E}Y)^{2}\\
&={\mathbb E}\big(X^{2}+Y^{2}+({\mathbb E}X)^{2}+({\mathbb E}Y)^{2}
+2XY
-2({\mathbb E}X)X-2({\mathbb E}Y)X\\
&\qquad\qquad-2({\mathbb E}X)Y-2({\mathbb E}Y)Y
+2({\mathbb E}X)({\mathbb E}Y)\big)\\
&={\mathbb E}X^{2}+{\mathbb E}Y^{2}+({\mathbb E}X)^{2}+({\mathbb E}Y)^{2}
+2({\mathbb E}X)({\mathbb E}Y)\\
&\qquad\qquad
-2({\mathbb E}X)^{2}-2({\mathbb E}X)({\mathbb E}Y)\\
&\qquad\qquad-2({\mathbb E}X)({\mathbb E}Y)-2({\mathbb E}Y)^{2}
+2({\mathbb E}X)({\mathbb E}Y)\\
&={\mathbb E}X^{2}-{\mathbb E}X^{2}+{\mathbb E}Y^{2}-{\mathbb E}Y^{2}\\
&=\var X+\var Y.
\end{align*}
\newpage\section*{Exercise~\ref{E;other variances}}
Write ${\mathbb A}X={\mathbb E}|X-{\mathbb E}X|$
and ${\mathbb B}X={\mathbb E}(X-{\mathbb E}X)^{4}$

(i) Both carry over since
\[(X+a)-{\mathbb E}(X+a)=X-{\mathbb E}X,\]
so ${\mathbb A}(X+a)={\mathbb A}X$
and ${\mathbb B}(X+a)={\mathbb B}X$.

(ii) Similar formulae.
\[{\mathbb A}aX={\mathbb E}|aX-a{\mathbb E}X|={\mathbb E}|a||X-{\mathbb E}X|
=|a|{\mathbb A}X.\]
\[{\mathbb B}aX={\mathbb E}(aX-a{\mathbb E}X)^{4}
={\mathbb E}a^{4}(X-{\mathbb E}X)^{4}
=|a|{\mathbb B}X.\]

(iii) There do not seem to be appropriate formulae.

(iv) No direct carry over.
If $\Pr(X=2)=1/3$, $\Pr(X=-1)=2/3$, $\Pr(Y=1)=\Pr(Y=-1)=1/2$ 
and $X$ and $Y$ are
independent then 
\begin{gather*}
\Pr(X+Y=3)=1/6,\ \Pr(X+Y=1)=1/6,\ \Pr(X+Y=0)=1/3\\
\Pr(X+Y=-2)=1/3
\end{gather*}

We have ${\mathbb E}X={\mathbb E}Y=0$,
so ${\mathbb E}(X+Y)=0$, and
\begin{gather*}
{\mathbb A}X={\mathbb E}|X|=2\times1/3+1\times2/3=4/3\\
{\mathbb A}Y={\mathbb E}|Y|=2\times1/2=1
\end{gather*}
and
\begin{align*}
{\mathbb A}(X+Y)&={\mathbb E}|X+Y|=
3\times1/6+1\times1/6+0\times1/3+2\times1/3\\
&=4/3\neq {\mathbb A}X+{\mathbb A}Y
\end{align*}
\begin{gather*}
{\mathbb B}X={\mathbb E}X^{4}=16\times1/3+1\times2/3=6\\
{\mathbb B}Y={\mathbb E}Y^{4}=2\times1/2=1
\end{gather*}
and
\begin{align*}
{\mathbb B}(X+Y)&={\mathbb E}(X+Y)^{4}\\
&=81\times1/6+1\times1/6+0\times1/3+4\times1/3\\
&=89/6\neq {\mathbb B}X+{\mathbb B}Y.
\end{align*}
\newpage\section*{Exercise~\ref{E;sum variance}}
Use induction or direct calculation.
Let $a_{j}={\mathbb E}X_{j}$ and set $Y_{j}=X_{j}-a_{j}$.
The $Y_{j}$ are independent and ${\mathbb E}Y_{j}=0$. Thus
\begin{align*}
\var(\sum_{j=1}^{n}X_{j})
&=\var\left(\sum_{j=1}^{n}X_{j}-\sum_{j=1}^{n}a_{j}\right))\\
&=\var\left(\sum_{j=1}^{n}Y_{j}\right)\\
&={\mathbb E}\left(\sum_{j=1}^{n}Y_{j}\right)^{2}\\
&={\mathbb E}\left(\sum_{j=1}^{n}Y_{j}^{2}
+2\sum_{1\leq j<i\leq n}Y_{i}Y_{j}\right)\\
&=\sum_{j=1}^{n}{\mathbb E}Y_{j}^{2}
+2\sum_{1\leq j<i\leq n}{\mathbb E}(Y_{i}Y_{j})\\
&=\sum_{j=1}^{n}{\mathbb E}Y_{j}^{2}
+2\sum_{1\leq j<i\leq n}{\mathbb E}Y_{i}{\mathbb E}Y_{j}\\
&=\sum_{j=1}^{n}{\mathbb E}\var Y_{j}
+2\sum_{1\leq j<i\leq n}0=\sum_{j=1}^{n}{\mathbb E}\var X_{j}
\end{align*}
\newpage\section*{Exercise~\ref{E;general weak}}
Set 
\[Z=(Y_{1}+Y_{2}+\dots+Y_{n})-(\mu_{1}+\mu_{2}+\dots+\mu_{n})\]
Then
\[{\mathbb E}Z=({\mathbb E}Y_{1}-\mu_{1})
+({\mathbb E}Y_{2}-\mu_{2})+\dots+({\mathbb E}Y_{n}-\mu_{n})=0\]
and
\[\var Z=\var(Y_{1}+Y_{2}+\dots+Y_{n})
=\var Y_{1}+\var Y_{2}+\dots+\var Y_{n}\leq n\sigma^{2}.\]
Thus by Tchebychev's inequality
\[\Pr(|Z|\geq n^{1/2}a)\leq \frac{\var Z}{(n^{1/2}a)^{2}}
\leq\frac{\sigma^{2}}{a^{2}}\]
and this is the required inequality.

\newpage\section*{Exercise~\ref{E;Tchebychev bet}}
Set $Z_{j}=Y_{j}-{\mathbb E}Y_{j}$. Then ${\mathbb E}Z_{j}=0$,
$\var Z_{j}=\var Y_{j}\leq \sigma^{2}$
and $Z_{j}\leq Y_{j}-\mu$.
Thus
\begin{align*}
\Pr\big(Y_{1}&+Y_{2}+\dots+Y_{n}>(1-c)n\mu\big)\\
&=\Pr\big((Y_{1}-\mu)+(Y_{2}-\mu)+\dots+(Y_{n}-\mu)> -cn\mu\big)\\
&\geq\Pr\big(Z_{1}+Z_{2}+\dots+Z_{n}> -cn\mu\big)\\
&= 1-\Pr\big(Z_{1}+Z_{2}+\dots+Z_{n})\leq -cn\mu\big)\\
&\geq 1-\Pr\big(|Z_{1}+Z_{2}+\dots+Z_{n}|\geq cn\mu\big)\\
&\geq 1-\frac{n\sigma^{2}}{(cn\mu)^{2}}
=1-\frac{c^{2}\sigma^{2}}{n\mu^{2}}
\geq 1-b
\end{align*}
whenever
\[n\geq \frac{bc^{2}\sigma^{2}}{\mu^{2}}.\]
So take
\[N=1+\text{integer part of}\ \frac{bc^{2}\sigma^{2}}{\mu^{2}}\]

If we take a long series of similar bets with return
greater than a certain proportion of our stake
then with high probability the average return over
a long series of bets will not be much smaller
than that proportion.
\newpage\section*{Exercise~\ref{E;sample wild}}
Let $\Omega=\{0,1\}^{n}$ with
\[\Pr({\boldsymbol a})=\prod_{j=1}^{n}(1-2^{-j})^{1-a_{j}}2^{-ja_{j}}.\]
and
\[X_{j}({\boldsymbol a})=a_{j}2^{j}.\]
\newpage\section*{Exercise~\ref{E;opinion}}
(i) ${\mathbb E}X_{j}=p\times 1+(1-p)\times 0=p$
and ${\mathbb E}X_{j}^{2}={\mathbb E}X_{j}=p$
so
\[\var X_{j}=({\mathbb E}X_{j})^{2}-{\mathbb E}X_{j}^{2}=p-p^{2}=p(1-p).\]
Since the $X_{j}$ are independent
\[\var(X_{1}+X_{2}+\dots+X_{n})=np(1-p).\]


(ii) Completing the square
\[p(1-p)=p-p^{2}=\tfrac{1}{4}-(p-\tfrac{1}{2})^{2}\leq \tfrac{1}{4}\]
with equality if and only if $p=\tfrac{1}{2}$.

(iii) We  thus have, using Tchebychev's inequality,
\begin{align*}
\Pr(&|\bar{X}-p|\geq a)\\
&=\Pr\big(|
X_{1}+X_{2}+\dots+X_{n}\\
&\qquad\qquad-
{\mathbb E}X_{1}-{\mathbb E}X_{2}+\dots+{\mathbb E}X_{n}|\geq na\big)\\
&\leq \frac{np(1-p)}{(na)^{2}}=\frac{p(1-p)}{na^{2}}
\leq \frac{1}{4a^{2}}
\end{align*}

(iv) Set $a=1/10$, $n=1000$ in~(iii).

(v) We must take $n=4000$.
\newpage\section*{Exercise~\ref{E;Hermits}}
(i) Observe that
\begin{align*}
0&\leq \sum_{r=1}^{m}(p_{r}-m^{-1})^{2}  
=\sum_{r=1}^{m}(p_{r}^{2}-2m^{-1}p_{r}+m^{-2})\\
&=\sum_{r=1}^{m}p_{r}^{2}-2\sum_{r=1}^{m}p_{r}+m^{-1}
=\sum_{r=1}^{m}p_{r}^{2}-m^{-1}
\end{align*}
with equality only if $p_{r}=m^{-1}$ for each $r$.

(ii) If you choose the $j$th grotto
\begin{align*}
Z&=\sum_{k=1}^{n}X_{jk}\\
&=\text{number others at $j$th grotto}\\
&=\text{number others at your grotto}
\end{align*}
as required.

Since $Y$ and $X_{jk}$ are independent
\[{\mathbb E} Y_{j}X_{jk}= {\mathbb E} Y{\mathbb E}X_{jk}=p_{j}^{2}\]
and so
\begin{align*}
{\mathbb E}Z&={\mathbb E}\sum_{j=1}^{m}\sum_{k=1}^{n}Y_{j}X_{jk}\\
&=\sum_{j=1}^{m}\sum_{k=1}^{n}{\mathbb E}Y_{j}X_{jk}
=\sum_{j=1}^{m}np_{j}^{2}\\
&=n\sum_{j=1}^{m}p_{j}^{2}.
\end{align*}
By part~(i)
\[{\mathbb E}Z= n\sum_{j=1}^{m}p_{j}^{2}\geq \frac{n}{m}\]
with equality only if $p_{r}=m^{-1}$ for each $r$,
which is the desired result.

If $m>1$ the
expected number of hermits at your grotto including yourself
is
\[1+{\mathbb E}Z\geq 1+\frac{n}{m}>\frac{n+1}{m}\]
the average number of hermits per grotto.
You are more likely to choose a popular grotto and popular
grottos are more likely to have crowds of hermits.

\newpage\section*{Exercise~\ref{E;Ladies}}
(i) Observe that
$X_{j}=1$ if and only if exactly one child at the
$j$th desk has the sniffles at the beginning of the day.
Thus
\[\Pr(X_{j}=1)=2p(1-p),\ \Pr(X_{j}=0)=1-2p(1-p).\]
Thus
\[{\mathbb E}X_{j}={\mathbb E}X_{j}^{2}=2p(1-p)\]
and
\begin{align*}
\var X_{j}&={\mathbb E}X_{j}^{2}-({\mathbb E}X_{j})^{2}\\
&=2p(1-p)\big(1-2p(1-p)\big)=2p(1-p)(1-2p+2p^{2}).
\end{align*}
It follows that
\[{\mathbb E}X=\sum_{j=1}^{n}{\mathbb E}X_{j}=2np(1-p)\]
and, since the $X_{j}$ are independent,
\[\var X=\sum_{j=1}^{n}\var X_{j}=np(1-p)(1-2p+2p^{2}).\]

Since
\[p(1-p)=p-p^{2}=\tfrac{1}{4}-(p-\tfrac{1}{2})^{2}\]
it follows that $\mu_{p,n}$ takes its largest value when $p=1/2$.

(ii) Observe that
so
\begin{align*}
\Pr(Y_{1}=1)&=\Pr(\text{exactly one of the 
two children starts with sniffles})\\
&=2\frac{k}{2n}\times\frac{2n-k}{2n-1}=\frac{k(2n-k)}{n(2n-1)}
\end{align*}
and
\[{\mathbb E}Y_{1}={\mathbb E}Y_{1}^{2}=\Pr(Y_{1}=1)
=\frac{k(2n-k)}{n(2n-1)}\]
Thus using symmetry
\[{\mathbb E}Y=\sum_{j=1}^{n}{\mathbb E}Y_{j}=n{\mathbb E}Y_{1}
=\frac{k(2n-k)}{2n-1}\]

Next observe that $Y_{1}Y_{2}$ takes the values $0$ and $1$
and that $Y_{1}Y_{2}=1$ if and only if exactly one child
at each of the two desks starts with the sniffles.
Thus
\begin{align*}
{\mathbb E}Y_{1}Y_{2}&=\Pr(Y_{1}Y_{2}=1)\\
&=4\times\frac{k(2n-k)}{2n(2n-1)}\times\frac{(k-1)(2n-k-1)}{(2n-2)(2n-3)}\\
&=\frac{k(k-1)(2n-k)(2n-k-1)}{n(n-1)(2n-1)(2n-3)}
\end{align*}

Now, using symmetry,
\begin{align*}
{\mathbb E}Y^{2}&={\mathbb E}\left(\sum_{j=1}^{n}Y_{j}\right)^{2}\\
&={\mathbb E}\left(\sum_{j}Y_{j}^{2}+\sum_{i\neq j}Y_{i}Y_{j}\right)\\
&=\sum_{j}{\mathbb E}Y_{j}^{2}+\sum_{i\neq j}{\mathbb E}Y_{i}Y_{j}\\
&=n{\mathbb E}Y_{1}^{2}+n(n-1){\mathbb E}Y_{i}Y_{j}\\
&=\frac{2k(2n-k)}{2n-1}+\frac{k(k-1)(2n-k)(2n-k-1)}{(2n-1)(2n-3)}
\end{align*}
Thus
\begin{align*}
\var Y&={\mathbb E}Y^{2}-({\mathbb E}Y)^{2}\\
&=\frac{2k(2n-k)}{2n-1}+\frac{k(k-1)(2n-k)(2n-k-1)}{(2n-1)(2n-3)}
-\left(\frac{k(2n-k)}{2n-1}\right)^{2}\\
&=\frac{k(2n-k)}{2n-1}
\left(4+\frac{(k-1)(2n-k-1)}{2n-3}
-\frac{k(2n-k)}{2n-1}\right)
\end{align*}

(iii) Writing $p=k/2n$ we have
\[
{\mathbb E}Y
=n\frac{2p(1-p)}{1-(2n)^{-1}}\neq {\mathbb E}X\]
so that $\tilde{\mu}_{k,n}\neq\mu_{k/2n,n}$
if $2n-1\geq k\geq 1$.

On the other hand, setting $p_{n}=k_{n}/2n$,
we have
\[
\frac{\tilde{\mu}_{k_{n},n}}{n}
=\frac{2p_{n}(1-p_{n})}{1-(2n)^{-1}}
\rightarrow 2p(1-p)
\]
and
\[\frac{\mu_{p,n}}{n}=2p(1-p)\]
so
\[\frac{\tilde{\mu}_{k_{n},n}}{\mu_{p,n}}\rightarrow 1.\]

\newpage\section*{Exercise~\ref{E;not very bright}}
\begin{table}[h]
\begin{center}
\begin{tabular}{rcccc}
$n=$&$5$&$10$&$20$&$30$\\
$2^{-n}\approx$&$3.1\times 10^{-2}$&$9.8\times 10^{-4}$
&$9.5\times 10^{-7}$&$9.3\times 10^{-9}$\\
($11/5)^{n}\approx$&$5.1\times 10$&$2.7\times 10^{2}$
&$7.1\times 10^{6}$&$1.9\times 10^{10}$\\
$(11/10)^{n}\approx$&$1.6$&$2.5$&$6.7$&$1.7\times 10$
\end{tabular}
\end{center}
\end{table}
\vspace{2\baselineskip}
\newpage\section*{Exercise~\ref{E;check Kelly}}
(i) Observe that $Y_{j}$ depends only on the $j$th throw
and the tosses are independent.

(ii) If $Z_{1}$, $Z_{2}$, \dots $Z_{n}$ are independent
so are $f(Z_{1})$, $f(Z_{2})$, \dots $f(Z_{n})$.

(iii) Tchebychev's inequality.

(iv) $\log X_{n}=\sum_{j=1}^{n}\log Y_{j}$.

(v) Take $a=\delta$, $N>\tilde{\sigma}^{2}\delta^{-2}\epsilon^{-1}$.

(vi) If we take $\delta=\log k$, then
\begin{align*}
\left|\frac{\log X_{n}}{n}
-\tilde{\mu}\right|<\delta
&\Leftrightarrow
\tilde{\mu}-\delta<
\frac{\log X_{n}}{n}< \tilde{\mu}+\delta\\
&\Leftrightarrow
\log (k^{-1}L)<\frac{\log X_{n}}{n}<\log (kL)\\
&\Leftrightarrow
(k^{-1}L)^{n}<X_{n}<(kL)^{n}
\end{align*}
and the result follows.

\newpage\section*{Exercise~\ref{E;over bet}}
(i) Since $t_{B}$ is a strict maximum for the function
 \[f(t)=p\log\big(1+(u-1)t)\big)+(1-p)\log (1-t)\] 
Choose $\delta>0$ with 
\[f(t_{B})-3\delta>f(t_{A}),\,f(t_{B}).\]
By Theorem~\ref{T;Kelly}, there exists an $N$
such that
\begin{gather*}
\Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{A})\right|\geq \delta\right)<\epsilon/3\\
\Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{B}))\right|\geq \delta\right)<\epsilon/3\\
\Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{C}))\right|\geq \delta\right)<\epsilon/3
\end{gather*}
for all $n\geq N$.
Thus
\begin{align*}
\Pr(X_{n},&\, Z_{n}<Y_{n})=\Pr(\log X_{n},\,\log Z_{n}<\log Y_{n})\\
&\geq \Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{A})\right|,\,\left|\frac{\log Y_{n}}{n}-f(t_{B}))\right|,\right.\\
&\qquad\qquad
\left.\left|\frac{\log Z_{n}}{n}-f(t_{C})\right|\leq \delta\right)\\
&\leq 1-
\Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{A})\right|\geq \delta\right)\\
&\qquad -\Pr\left(\left|\frac{\log Y_{n}}{n}
-f(t_{B})\right|\geq \delta\right)\\
&\qquad -\Pr\left(\left|\frac{\log Z_{n}}{n}
-f(t_{C})\right|\leq \delta\right)\\
&>1-\epsilon.
\end{align*}
[Thanks to Nigel White for corrections.)

(ii) Since $f$ is strictly increasing
on $[0,t_{B}]$ we can find a $\delta>0$
such that $f(t_{A})>2\delta$.
We can find an $N$ such that, if $n\geq N$ 
\[\Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{B})\right|\geq \delta\right)<\epsilon\]
and so 
\[\Pr(X_{n}>1)\geq 1-\Pr\left(\left|\frac{\log X_{n}}{n}
-f(t_{B})\right|\geq \delta\right)<\epsilon.\]

(iii) Observe that $f$ is strictly decreasing (and continuous)
on $[t_{B},1)$ with $f(t)\rightarrow-\infty$ as $t\rightarrow 1-$.
Since $t_{B}>0$ there is a $t_{D}$ with $1>t_{D}>t_{B}$
such that
\[
f(t)
\begin{cases}
>0&\text{for $t_{B}\leq t<t_{D}$,}\\
=0&\text{if $t=t_{D}$,}\\
<0&\text{for $t_{D}\leq t<1$.}
\end{cases}
\]
The stated result follows using the arguments of~(ii).
\newpage\section*{Exercise~\ref{E;careful Kelly}}
A Kelly bettor never bets with $u\leq 1$  so $u-1>0$
and we have
\[\frac{pu-1}{u-1}\leq \frac{pu-p}{u-1}=p.\]
\newpage\section*{Exercise~\ref{E;calculate Kelly}}
We have
\[t=\frac{(11/10)-1}{(11/5)-1}=\frac{1}{12}.\]
With this choice
\begin{gather*}
\Pr(Y_{j}=.9)=\Pr(Y_{j}=.1.12)=1/2\\
\tilde{\mu}={\mathbb E}\log Y_{j}\approx 0.00419\\
{\tilde{\sigma}}^{2}=\var(\log Y_{j})={\mathbb E}(\log Y_{j})^{2}
({\mathbb E}\log Y_{j})^{2}\approx 0.00831
\end{gather*}
Thus
\[{\mathbb E}\sum_{j=1}^{175}\log Y_{j}\approx \log 2.\]

Rest of calculation needs redoing so continue at your own risk.%REDO

If we take $n=500$ and try our Tchebychev estimate we get
\[\Pr\left(\left|\log Y_{1}+\log Y_{2}+\dots+\log Y_{500}
-1.99\right|\geq 1.3\right)\leq 
\frac{500\times{\tilde{\sigma}}^{2}}{1.3^{2}}\approx 3.5\]
which tells us nothing.

If we take  $n=5000$ and try our Tchebychev estimate we get
\[\Pr\left(\left|\log Y_{1}+\log Y_{2}+\dots+\log Y_{5000}
-19.9\right|\geq 19\right)\leq 
\frac{5000\times{\tilde{\sigma}}^{2}}{19^{2}}\approx 0.16.\]
Thus 
\[\log Y_{1}+\log Y_{2}+\dots+\log Y_{5000}
-19.9>19\]
and
so
\[\log Y_{1}+\log Y_{2}+\dots+\log Y_{5000}>\log 2\]
with probability at least $.74$. In fact the situation
is rather better than this but 
Exercises~\ref{E;not very bright} and~\ref{E;calculate Kelly}
show that it is hard for individuals to make a living
by gambling at only slightly favourable odds.

(ii) We have
\begin{align*}
\tilde{\mu}&={\mathbb E}\log Y_{1}\\
&=\frac{1}{2}\log\big(tu+(1-t)\big)+\frac{1}{2}\log(1-t)\\
&=\frac{1}{2}\left(\log\big(1+(u-1)t\big)+\log(1-t)\right)\\
&=\frac{1}{2}\left(\log\big(1+(u-1)t\big)+\log(1-t)\right)\\
&=\frac{1}{2}\left((u-1)t-\frac{(u-1)^{2}t^{2}}{2}-t-\frac{t^{2}}{2}
+\dots\right)\\
&=\frac{1}{2}\left((u-2)t-\frac{(u-1)^{2}t^{2}}{2}-\frac{t^{2}}{2}
+\dots\right)\\
&=\frac{1}{2}\left(2(u-1)t^{2}-\frac{(u-1)^{2}t^{2}}{2}-\frac{t^{2}}{2}
\right)\\
&=\frac{1}{2}(u-\tfrac{1}{2}(u-2)^{2})t^{2}+\dots
\end{align*}
so $\tilde{\mu}$ behaves like $t^{2}$ for small $t$.

Also
\begin{align*} 
{\mathbb E}Y_{1}^{2}&=\frac{1}{2}\bigg(\log\big(tu+(1-t)\big)\bigg)
+\frac{1}{2}\bigg(\log\big(tu+(1-t)\big)\bigg)\\
&=\frac{1}{2}\bigg(\big((u-1)t\big)^{2}+t^{2}+\dots\bigg)\\
&=\frac{u^{2}-2u+2}{2}t^{2}
\end{align*}
so ${\mathbb E}Y_{1}^{2}$ and thus ${\tilde{\sigma}}^{2}$
behave like $t^{2}$ and when $t$ is small
the the standard deviation is very much bigger
than the difference of the mean from zero. It is going to take a very large
number of throws for the law of large numbers in our form (or indeed
in any form) to give us any certainty. 
\newpage\section*{Exercise~\ref{E;calculate Kelly 1}}
Kelly suggests gambling $4/5$ of your fortune at each go.


\begin{tabular}{l|c|c|c|c|c|c|c}
$n=$&20&19&18&17&16&15&14\\
probability&.122&.270&.285&.095&.045&.015&.004\\
(i) gives&3325.3&1108.4&369.5&123.2&41.1&13.7&4.6\\
(ii) gives&127482.3&14164.7&1573.9&174.9&19.4&2.2&.23\\
(iii) gives&1048576.0&0&0&0&0&0&0
\end{tabular}

\newpage\section*{Exercise~\ref{E;Kelly variable}}
Can write out more or less generally.
The following is on the less general side.


Let $T<1$.
Suppose that we are presented with a series of
independent bets with probability $p_{j}$
of success and our $j$th bet
has payout ratio $u_{j}<U$ with
\[\frac{p_{j}u_{j}-1}{u_{j}-1}<T\]]
Suppose we start with $!$ we bet a proportion $t_{j}$ of
our fortune on each go with $t_{j}<T$. 
Then our fortune satisfies $X_{0}=1$ and
\[X_{j+1}=
\begin{cases}
X_{j}(t_{j}u+(1-t_{j}))&\text{if the $j$th throw is heads,}\\
X_{j}(1-t)&\text{if the $j$th throw is tails.}
\end{cases}
\]
We set
\[Y_{j+1}=\frac{X_{j+1}}{X_{j}}=
\begin{cases}
t_{j}u_{j}+(1-t_{j})&\text{if the $j$th throw is heads,}\\
1-t_{j}&\text{if the $j$th throw is tails.}
\end{cases}
\]

Observe that
\[\var \log Y_{j}\leq (\log(1-T))^{2}+(\log T+\log U)^{2}\]
so we may apply Tchebychev's theorem to tell  us that
when $n$ is very large the probability
that
\[\frac{\log X_{n}}{n}
=\frac{\log Y_{1}+\log Y_{2}+\dots+\log Y_{n}}{n}\]
differs greatly from
\[\frac{{\mathbb E}\log Y_{1}+{\mathbb E}\log Y_{2}+\dots
+{\mathbb E}\log Y_{n}}{n}\]
is small.

Since maximising $n^{-1}\log X_{n}$ is equivalent to maximising
$X_{n}$, I wish to maximise ${\mathbb E}\log Y_{j}$
and so follow the Kelly criterion.


More generally (with much the same proof)
offered the a sequence of bets
which multiply my fortune by $Y_{j}$
or $Z_{j}$ on the $j$th  go, then
provided
\[\var\log Y_{j},\var\log Z_{j}<K\]
and
\[{\mathbb E}\log Y_{j}\geq k {\mathbb E}\log Z_{j}\]
for some fixed $K$ and some fixed $k>1$,
I should choose $Y_{j}$ to maximise my fortune
(in the long run with high probability).
\newpage\section*{Exercise~\ref{E;fixed ammount}}
Write $Z_{j}=1$ if the $j$th throw is heads, $Z_{j}=0$
if tails. Observe that
\[{\mathbb E}Z_{j}=p,\ \var Z_{j}=p(1-p)=\tfrac{1}{4}-(p-\tfrac{1}{2})^{2}
\leq \tfrac{1}{4}.\]

(i) If $pu<1$, then using Tchebychev's inequality,
\begin{align*}
\Pr(X_{n}(t)<X_{n}(0))&=\Pr\left(\sum_{j=1}^{n}tuZ_{j}-tn<0\right)\\
&=\Pr\left(\sum_{j=1}^{n}Z_{j}<0\right)\\
&\geq\Pr\left(\left|\sum_{j=1}^{n}(Z_{j}-{\mathbb E} Z_{j})\right)
<np\right)\\
&\geq 1-\frac{1}{n^{2}p^{2}}\var\left(\sum_{j=1}^{n}Z_{j}\right)\\
&\geq 1-\frac{1}{4n p^{2}}\geq 1-\epsilon
\end{align*}
for $n>4^{-1}\epsilon^{-1}p^{-2}$.

(ii) If $pu>1$, then using Tchebychev's inequality,
\begin{align*}
\Pr(X_{n}(t)<X_{n}(1))&=\Pr\left(\sum_{j=1}^{n}u(1-t)Z_{j}-(1-t)n>0\right)\\
&=\Pr\left(\sum_{j=1}^{n}uZ_{j}-n>0\right)\\
&\geq\Pr\left(\left|\sum_{j=1}^{n}(Z_{j}-{\mathbb E} Z_{j})\right)
\leq n(p-u^{-1})\right)\\
&\geq 1-\frac{1}{n^{2}(p-u^{-1})^{2}}\var\left(\sum_{j=1}^{n}Z_{j}\right)\\
&\geq 1-\frac{1}{n p^{2}}\geq 1-\epsilon
\end{align*}
for $n>4^{-1}\epsilon^{-1}(p-u^{-1})^{-2}$.
\newpage\section*{Exercise~\ref{E;worst Kelly}}
(i) If the first horse wins, she gets back
\[\frac{u_{2}}{u_{1}+u_{2}}\times u_{1}
=\frac{u_{1}u_{2}}{u_{1}+u_{2}}
=\frac{1}{u_{1}^{-1}+u_{2}^{-1}}=K.\]
A similar calculation works for the second horse.

(ii) If the $j$th horse wins $X=p_{j}u_{j}$ for the Kelly bettor.
Thus
\begin{align*}
{\mathbb E}\log X&=p_{1}\log p_{1}u_{1}+p_{2}\log p_{2}u_{2}\\
&=p_{1}\log p_{2}+p_{2}\log p_{2}+p_{1}\log u_{1}+p_{2} \log u_{2}.
\end{align*}

If we set $t=K^{-1}u_{1}^{-1}$, we have $u_{2}^{-1}=K^{-1}(1-t)$
and
\[F(u_{1},u_{2})=f(t)\]
with
\[f(t)=\log K+p_{1}\log p_{2}+p_{2}\log p_{2}-p_{1}\log t
-p_{2} \log(1-t).\]
Since 
\[f'(t)=-\frac{p_{1}}{t}+\frac{p_{2}}{1-t}=\frac{t-p_{1}}{t(1-t)}\]
$f(t)$ attains a strict maximum for $0<t<1$
when $t=p_{1}$.

Thus 
\[{\mathbb E}\log X=F(u_{1},u_{2})\geq F(Kp_{1},Kp_{2})
=\log K\]
with equality only when $u_{j}=Kp_{j}^{-1}$.

(iii) Without loss of generality, suppose $u_{1}p_{1}\geq u_{2}p_{2}$.
For the maximum expectation bettor,
\begin{align*}
{\mathbb E} X&=u_{1}p_{1}\\
&=\frac{u_{1}}{u_{1}+u_{2}}\times u_{1}p_{1}
+\frac{u_{2}}{u_{1}+u_{2}}\times u_{1}p_{1}\\
&\geq \frac{u_{1}}{u_{1}+u_{2}}\times u_{2}p_{2}
+\frac{u_{2}}{u_{1}+u_{2}}\times u_{1}p_{1}\\
&=\frac{u_{1}u_{2}}{u_{1}+u_{2}}=K
\end{align*}
with equality only when $u_{j}=Kp_{j}^{-1}$.
\newpage\section*{Exercise~\ref{E;many horse Kelly}}
(i) We have
\begin{align*}
g'(x)&=\frac{d\ }{dx}\left(
p_{i}\log\big((u_{i}s_{i}+s_{n+1})+u_{i}x\big)
-p_{j}\log\big((u_{j}s_{i}+s_{n+1})+u_{j}x\big)\right)\\
&\frac{p_{i}u_{i}}{(u_{i}s_{i}+s_{n+1})+u_{i}x}
-\frac{p_{j}u_{j}}{(u_{j}s_{j}+s_{n+1})+u_{j}x}
\end{align*}

If $s_{i},s_{j}\neq 0$ we must have $g'(0)=0$
so
\[\frac{p_{i}u_{i}}{u_{i}s_{i}+s_{n+1}}
=\frac{p_{j}u_{j}}{u_{j}s_{j}+s_{n+1}},\]

If $s_{j}=0$ we must have $s_{n+1}\neq 0$ (otherwise
we lose our entire fortune) and $g'(0)\geq 0$
so
\[\frac{p_{i}u_{i}}{u_{i}s_{i}+s_{n+1}}>
\frac{p_{j}u_{j}}{s_{n+1}}.\]

If $s_{i}=0$ and $s_{j}>0$ we must have $g'(0)<0$ which is
impossible. Thus if $s_{i}=0$ we have $s_{j}=0$.

(ii) Let
\[h(x)=f(s_{1}+x,s_{2},\dots,s_{n+1}-x)\]
Then
\begin{small}
\begin{align*}
&h'(x)\\
&=\frac{d\ }{dx}\left(p_{1}\log\big((u_{1}-1)x+u_{1}s_{1}+s_{n+1}\big)
+\sum_{j=2}^{n}p_{j}\log(u_{j}s_{j}+s_{n+1}-x)\right)\\
&=\frac{p_{1}(u_{1}-1)}{(u_{1}-1)x+u_{1}s_{1}+s_{n+1}}
-\sum_{j=2}^{n}\frac{p_{j}}{u_{j}s_{j}+s_{n+1}-x}
\end{align*}
\end{small}
so
\[h'(0)=\frac{p_{1}(u_{1}-1)}{u_{1}s_{1}+s_{n+1}}
-\sum_{j=2}^{n}\frac{p_{j}}{u_{j}s_{j}+s_{n+1}}\]

If $s_{1}\neq 0$ and $s_{n+1}\neq 0$ then $h'(0)=0$
and we have
\begin{equation*}
\tag{C}
\frac{p_{1}}{u_{1}s_{1}+s_{n+1}}
+\frac{p_{2}}{u_{2}s_{2}+s_{n+1}}
+\dots
+\frac{p_{n}}{u_{n}s_{n}+s_{n+1}}
=\frac{p_{1}u_{1}}{u_{1}s_{1}+s_{n+1}}.
\end{equation*}

If $s_{n+1}=0$ we must have $h'(0)\geq 0$ and so
\begin{equation*}
\tag{B} 
\frac{1}{u_{1}}+\frac{1}{u_{2}}+\dots+\frac{1}{u_{n}}\leq 1
\ \text{and $s_{n+1}=0$}.
\end{equation*}

If $s_{1}=0$ (so $s_{j}=0$ for $1\leq j\leq n$
and $s_{n+1}=1$) by our earlier results,
we must have $h'(0)\leq 0$ so
\[\sum_{j=1}^{n}p_{j}
\geq p_{1}u_{1}\]
ie $p_{1}u_{1}\leq 1$ (case A).

(iii) In case (A) we have $s_{j}=0$ for $1\leq j\leq n$
so we do not bet. In case (B) $s_{n+1}$ so we bet everything
and by (i)
\[\frac{p_{j}}{s_{j}}=\frac{p_{i}}{s_{i}}\]
for all $1\leq i,j\leq n$ so $s_{i}=\alpha p_{i}$ for some
$\alpha$. Summing, $\alpha=1$ and so $s_{i}=\alpha p_{i}$

(iv) In case (C) parts~(i) and~(ii) tells us that
 that there is an $m$ with $1\leq m<n$
and a $k>0$ such that
\begin{gather*}
\frac{p_{j}u_{j}}{u_{j}s_{j}+s_{n+1}}=k\ \text{for $1\leq j\leq m$},\\
s_{j}=0,\ \frac{p_{j}u_{j}}{s_{n+1}}\leq k
\ \text{for $m+1\leq j\leq n$}\\
\intertext{and}
\frac{p_{1}}{u_{1}s_{1}+s_{n+1}}
+\frac{p_{2}}{u_{2}s_{2}+s_{n+1}}
+\dots
+\frac{p_{n}}{u_{n}s_{n}+s_{n+1}}
=k.
\end{gather*}

Thus
\[p_{j}u_{j}=ku_{j}s_{j}+ks_{n+1}\]
and
\[s_{j}=k^{-1}p_{j}-s_{n+1}u_{j}^{-1}\]
for $1\leq j\leq m$, $s_{j}=0$.

The equation
\[\frac{p_{1}}{u_{1}s_{1}+s_{n+1}}
+\frac{p_{2}}{u_{2}s_{2}+s_{n+1}}
+\dots
+\frac{p_{n}}{u_{n}s_{n}+s_{n+1}}
=k\]
yields
\[\frac{k}{u_{1}}+\frac{k}{u_{2}}+\dots+\frac{k}{u_{m}}
+\frac{p_{m+1}}{s_{n+1}}+\dots+\frac{p_{n}}{s_{n+1}}=k\]
so
\[s_{n+1}=k^{-1}\frac{1-p}{1-T}\]
where
$p=p_{1}+p_{2}+\dots+p_{m}$ and 
\[T=\frac{1}{u_{1}}+\frac{1}{u_{2}}+\dots+\frac{1}{u_{m}}.\]


But 
\[s_{1}+s_{2}+\dots+s_{n+1}=1\]
so
\[k^{-1}p-Ts_{n+1}+s_{n+1}=1\]
and $k=1$. Hence
\[s_{j}=
\begin{cases}p_{j}-\frac{s_{n+1}}{u_{j}}&\text{for $1\leq j\leq m$},\\
0&\text{for $m+1\leq j\leq n$}
\end{cases}
\]
and
\[s_{n+1}=\frac{1-p}{1-T}.\]

\newpage\section*{Exercise~\ref{E;insurance Jensen one}}
(i) We have
\[{\mathbb E}X=\tfrac{1}{2}\times\tfrac{1}{2}+\tfrac{1}{2}\times 2
=\tfrac{5}{4}\]
and
\[{\mathbb E}\log Y=-\tfrac{1}{2}\log 2+\tfrac{1}{2}\log 2=0.\]
 
(ii) We have
\[{\mathbb E}X=\tfrac{1}{2}\times 0+\tfrac{1}{2}\times\tfrac{11}{4}
=\tfrac{11}{8}>\tfrac{5}{4}\]
and
\[{\mathbb E}\log Y=-\tfrac{1}{2}\log 1+\tfrac{1}{2}\log \tfrac{5}{4}=0
=\tfrac{1}{2}\log \tfrac{5}{4}>0.\]

\newpage\section*{Exercise~\ref{E;geometric sum}}
\begin{align*}
(1-&x)(1+x+x^{2}+\dots+x^{m})\\
&=(1+x+x^{2}+\dots+x^{m})
-(x+x^{2}+x^{3}+\dots+x^{m+1})\\
&=1-x^{m+1}
\end{align*}
so provided $x\neq 1$ we can divide by $x-1$ to get
\[1+x+x^{2}+\dots+x^{m}=\frac{1-x^{m+1}}{1-x}.\]
\newpage\section*{Exercise~\ref{E;live for ever}}
If I start with $x$, I will have $k(x-1)$ just before the second
withdrawal so I need
\[k(x-1)=x\]
ie 
\[x=\frac{k}{k-1}.\]
The working is reversible.
\newpage\section*{Exercise~\ref{E;moment's purchase}} 
\[l=\frac{k}{k-p}\]
so $kl-pl=k$ and
\[p=k\frac{l-1}{l}\]

The figures given suggest
\[p\approx 1.04\times \frac{11}{12}\approx .95.\]
\newpage\section*{Exercise~\ref{E;cost guarantee}}
If you want to draw a fixed income for the
rest of your life and leave your present fortune to your
children you can only enjoy an income $a/(a+b)$ times
as much as if you bought an annuity and left nothing.

(In C.S. Forster's \emph{The African Queen} the heroine's
father leaves her nothing because he has put his little
money into an annuity.)

If $b$ is large, then there is a high chance 
of your dying soon so the annuity company can be generous.
If $b$ is small, the annuity company expects to be paying out 
for many years and will pay close to bank interest.

Perhaps $a=b=1/25$. These figures are plucked out of the air
but it is easy to find bank interest rates and not hard to
find annuity rates.
\newpage\section*{Exercise~\ref{E;certain arithmetic}}
\begin{align*}
{\mathbb E}\,\text{cost}
&=\sum_{j=0}^{N-1}(j+1)\Pr(\text{die in $j$-th year})\\
&=\sum_{j=0}^{N-1}(j+1)/N=N^{-1}\sum_{j=1}^{N}j\\
&=(N+1)/2
\end{align*}
\newpage\section*{Exercise~\ref{E;differentiate geometric}}
(i) We have, by differentiation
\[1+2x+\dots+mx^{m-1}
=\frac{1-x^{m+1}}{(1-x)^{2}}-\frac{(m+1)x^{m}}{1-x}\]
so differentiating again
\begin{align*}
(1\times 2)+&(2\times 3)x+(3\times 4)x^{2}\dots+m(m-1)x^{m-2}\\
&=\frac{d\ }{dx}
\left(\frac{1-x^{m+1}}{(1-x)^{2}}-\frac{(m+1)x^{m}}{1-x}\right)\\
&=2\frac{1-x^{m+1}}{(1-x)^{3}}
-2\frac{(m+1)x^{m}}{(1-x)^{2}}-\frac{m(m+1)x^{m}}{1-x}.
\end{align*}

(ii) (Corrected by Nigel White.)
We have
\begin{align*}
1^{2}&+2^{2}x+3^{2}x^{2}\dots+(m-1)^{2}x^{m-2}\\
&=(1\times 2)+(2\times 3)x+(3\times 4)x^{2}\dots+m(m-1)x^{m-2}\\
&\qquad-1-2x-\dots-(m-1)x^{m-2}\\
&=2\frac{1-x^{m+1}}{(1-x)^{3}}
-2\frac{(m+1)x^{m}}{(1-x)^{2}}-\frac{m(m+1)x^{m}}{1-x}
+\frac{1-x^{m}}{(1-x)^{2}}-\frac{mx^{m-1}}{1-x}\\
&=2\frac{1-x^{m+1}}{(1-x)^{3}}
-\frac{(2m+1)x^{m}+1}{(1-x)^{2}}
-\frac{m(mx-x+1))x^{m-1}-1}{1-x}.
\end{align*}

(iii) The probability that there is a payout at the beginning
of year $j$ is
\begin{align*}
1-\Pr(\text{both dead at beginning of $j$})
&=1-j^{2}/N^{2}\\
&=N^{-2}(N^{2}-j(j-1)-j)
\end{align*}
so the expected value of the annuity is
\begin{align*}
\sum_{j=0}^{N-1}N^{-2}&(N^{2}-j(j-1)-j)\\
&=N+N^{-2}\sum_{j=0}^{N-1}
\big((j+1)j(j-1) -j(j-1)(j-2)\big)/3\\
&\qquad\qquad-\big((j+1)j-j(j-1)\big)/2\\
&=N-N^{-1}(N+1)(N-1)/3-N^{-1}(N+1)/2\\
&=N-\frac{2N^{2}-3N+1}{6N}.
\end{align*}

If $k\neq 1$, the expected value of the annuity
is
\[
\sum_{j=0}^{N-1}N^{-2}(N^{2}-j^{2}k^{-1})
\]
which can be computed by (ii).

\newpage\section*{Exercise~\ref{E;life table}}
(i) We have
\begin{align*}
A_{r}&=1+k^{-1}q_{r,r+1}+k^{-2}q_{r,r+2}+\dots+k^{-N}q_{r,N}\\
&=1+k^{-1}p_{r}+k^{-2}p_{r}q_{r+1,r+2}+\dots+k^{r-N}p_{r}q_{r+1,N}\\
&=1+k^{-1}p_{r}(1+k^{-1}q_{r+1,r+2}+\dots+k^{r+1-N}q_{r+1,N})\\
&=1+p_{r}k^{-1}A_{r+1}
\end{align*}
If I want to pay an annuity of $1$ unit a year
to someone of age $r$,
I can pay them $1$ now and bank
$k^{-1}p_{r}k^{-1}A_{r+1}$. At the end of the year
with probability $p_{r}$ they will still be alive
and I will have $p_{r}A_{r+1}$ to buy an annuity then.

(ii) Since
\[q_{r,s}=p_{r}p_{r+1}\dots p_{r+s-1},
\ \text{and}\ q_{r,s+1}=p_{r+1}\dots p_{r+s}\]
we have
\[p_{r+s}=q_{r,s+1}/q_{r,s}.\]
for all $0\leq s\leq N-1$.
Thus
\[p_{s}=q_{0,s+1}/q_{0,s}.\]
for $0\leq s\leq N-1$.

$q_{0,s}$ is the probability that a newborn will 
live at least $s$ years. No one lives longer than $N$.
\newpage\section*{Exercise~\ref{E;life table 2}}
The probability that at least one of the pair will be alive at
the beginning of the $u$th year
is
\begin{align*} 
1-\Pr(\text{both dead at beginning}&\ \text{of $j$th year})\\
&=1-(1-q_{r,r+u})(1-q_{t,t+u})\\
&=q_{r,r+u}+q_{t,t+u}-q_{r,r+u}q_{t,t+u}
\end{align*}
so the expected present value of the joint annuity is
\[\sum_{u=)}^{N}k^{-j}(q_{r,r+u}+q_{t,t+u}-q_{r,r+u}q_{t,t+u})\]
where $q_{i,j}=0$ if $j\geq N$.
\newpage\section*{Exercise~\ref{E;Bernoulli equation one}}
We have 
\[f'(t)=\frac{r'(t)}{s(t)}-\frac{r(t)s'(t)}{s(t)^{2}}\]
so
\[\frac{f'(t)}{f(t)}=\frac{r'(t)}{r(t)}-\frac{s'(t)}{s(t)}.\]
Since
\[\frac{r'(t)}{r(t)}-\frac{s'(t)}{s(t)}
=p-pq\frac{s(t)}{r(t)},\]
we get
\[\frac{f'(t)}{f(t)}=p-\frac{pq}{f(t)}\]
and
\[f'(t)=pf(t)-pq\]
whence
\[\frac{f'(t)}{f(t)-q}=p.\]
It follows that
\[\frac{d\ }{dt}\big(\log(f(t)-q)-pt\big)
=\frac{f'(t)}{f(t)-q}-p=0\]
and so
\[\log(f(t)-q)-pt=A\]
for some constant $A$.

Sine $r(0)=s(0)$, $f(0)=1$ and, setting $t=0$
in the last equation of the previous paragraph, $A=\log(1-q)$.
Thus
\[\log(f(t)-q)-pt=pt+\log(1-q)\]
and applying $\exp$ to both sides
\[f(t)-q=(1-q)e^{pt}\]
that is to say
\[\frac{r(t)}{s(t)}=f(t)=q+(1-q)e^{pt}\]
whence
\[s(t)=\frac{r(t)}{q+(1-q)e^{pt}}.\]
\newpage\section*{Exercise~\ref{E;simple Bayes}}
One half of the population dies from $A$ and $1/4$
from $B$ so the probability of dying from $A$ is $1/2$
and of dying from $B$ is $1/4$. However, as stated
the probability of dying from an attack of $A$
is $1/2$ and the probability of dying from an attack of $B$
is $1/2$.

The probability
of dying from an attack of smallpox, 
is $1/8$ and that
the probability
of dying from smallpox is $1/13$
because, as may be seen from Bernoulli's table,
many people die young and so may have escaped
attacks of smallpox. The probability of dying from smallpox
cannot be smaller than the probability of dying an attack of
smallpox because in order to die from smallpox
you must first have an attack of smallpox.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;spreadsheet 1}$^{*}$}
\section*{Exercise~\ref{E;spreadsheet 2}$^{*}$}
\newpage\section*{Exercise~\ref{E;gain up down}}
As the age increases the probability that you will have 
had an attack of smallpox in your life up to then increases.
However, if you are inoculated you will eventually
die of something else so the number `saved from smallpox'
must start to decrease.
\newpage\section*{Exercise~\ref{E;pretty theorem}}
If there is no smallpox $p=0$ and $R(t)=r(t)$ so
\[R'(t)=-R(t)u(t)\]
so
\[\frac{R'(t)}{R(t)}=-u(t).\]
Earlier we showed that
\[\frac{r'(t)}{r(t)}=-u(t)-pq\frac{s(t)}{r(t)}\]
so that
\[\frac{R'(t)}{R(t)}-\frac{r'(t)}{r(t)}=pq\frac{s(t)}{r(t)}.\]

But in  Exercise~\ref{E;Bernoulli equation one}
we showed that
\[\frac{s(t)}{r(t)}=\frac{1}{q+(1-q)e^{pt}}\]
so
\[\frac{R'(t)}{R(t)}-\frac{r'(t)}{r(t)}=\frac{pq}{q+(1-q)e^{pt}}.\]

Now
\[\frac{pq}{q+(1-q)e^{pt}}
=p-\frac{p(1-q)e^{pt}}{q+(1-q)e^{pt}}\]
so
\begin{align*}
\frac{d\ }{dt}&\left(\log R(t)-\log r(t)-pt
+\log(q+(1-q)e^{pt})\right)\\
&=\frac{R'(t)}{R(t)}-\frac{r'(t)}{r(t)}
-p+p-\frac{p(1-q)e^{pt}}{q+(1-q)e^{pt}}=0
\end{align*}
and
\[\log R(t)-\log r(t)-pt+\log(q+(1-q)e^{pt})=C\]
where $C$ is a constant.

Now $R(0)=r(0)$ so setting $t=0$ in the last formula of
the previous paragraph we get $C=0$. Thus
\[\log R(t)-\log r(t)=pt-\log(q+(1-q)e^{pt})\]
and applying $\exp$ to both sides we get
\[\frac{R(t)}{r(t)}=\frac{e^{pt}}{q+(1-q)e^{pt}}.\]

As $t\rightarrow\infty$
\[\frac{R(t)}{r(t)}=\frac{1}{qe^{-pt}+(1-q)}\rightarrow\frac{1}{1-q}.\]
Suppose smallpox does not kill but with probability $q$
colours your hair green. When $t$ is large almost everybody
will have had smallpox and only a proportion $1-q$
will not have green hair. The result is what we expect.
\newpage\section*{Exercise~\ref{E;should we 1}}
If we expect that the `unlucky' children would if uninoculated
suffer the same diseases (including smallpox) and die
in the same proportions as other children then
we expect
\[D(n)\approx D(n-1)\times\frac{B(n)}{B(n-1)}.\]
(If we think that the `unlucky' children are more likely
to die of ordinary smallpox then this improves
Bernoulli's figures in the sense of increasing
the expected lifetime with universal inoculation.)

The number of children who would be alive at $n$ if not
inoculated at birth but would die from inoculation
must be subtracted from the size of the population
of age $n$ calculated by assuming that inoculation is riskless.
\newpage\section*{Exercise~\ref{E;Geometric smallpox 1}}
If someone in immune with expected lifetime $u$
then with probability $(1-a)$
they will die one year hence and with probability $a$ they
will survive one year and their expected lifetime
at the beginning of that year will be $u$.
Thus
\[u=(1-a)+a(1+u)=1=au\]
and $u=(1-a)^{-1}$.

If someone who is not immune and will not be inoculated
has expected lifetime $v$ then

(1) With probability $(1-b-c)$ they will die one year hence.

(2)  With probability $b$ they will be alive but not immune
in a year's time and their expected lifetime
at the beginning of that year will be $v$.

(3) With probability $c$ they will be alive and immune
in a year's time and their expected lifetime
at the beginning of that year will be $u$.

Thus
\[v=(1-b-c)+b(1+v)+c(1+u)=1+bv+cu.\]
Thus
\[(1-b)v=1+cu\]
and
\[v=\frac{1}{1-b}\left(1+\frac{c}{1-a}\right).\]
(The same results can be obtained by summing appropriate geometric
series.)


If the individual is inoculated they have a probability of dying of $r$
otherwise their expected life time is $(1-a)^{-1}$.
Thus there expected lifetime is
\[\frac{1-r}{1-a}\]
so the `gain in expected lifetime' is
\[\frac{1-r}{1-a}-\frac{1}{1-b}\left(1+\frac{c}{1-a}\right).\]
They will have strictly positive gain if
\[\frac{1-r}{1-a}>\frac{1}{1-b}\left(1+\frac{c}{1-a}\right).\]

If a child is inoculate late it runs the additional
risk of dying from smallpox until it is inoculated.
\newpage\section*{Exercise~\ref{E;Geometric smallpox 2}}
We have already estimated the probability of dying from
other causes between the  ages of $n-1$ and $n$
as
\[p_{n-1}\approx \frac{C(n)}{B(n-1)}\]
and we have estimates for $p$ the probability of catching
smallpox in a year and $q$ of dying from an attack.

Thus if $u_{n}$ is the probability that a 
uninoculated child of $4$
will survive to age $n$ without catching smallpox
and $v_{n}$ is the probability that a 
uninoculated child of $4$
will survive to age $n$ having caught smallpox at sometime
\begin{gather*}
u_{n}\approx (1-p)(1-p_{n-1})u_{n-1}\\
v_{n}\approx (1-p_{n-1})v_{n-1}+(1-p_{n-1})pqu_{n-1}
\end{gather*}
with $u_{4}=1$, $v_{4}=0$.
The probability that a 
uninoculated child of $4$
will survive to age $n$ is
$u_{n}+v_{n}$ and its expected lifetime is 
approximately $\sum_{n=5}^{80}u_{n}+v_{n}$.

If $w_{n}$ is the probability that a 
inoculated child of $4$
will survive to age $n$ then
\[w_{n}=(1-p_{n-1})w_{n-1}\]
and
its expected lifetime is 
approximately $\sum_{n=5}^{80}w_{n}$.
  
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;figure of merit}$^{*}$}
\newpage\section*{Exercise~\ref{E;Jenner}}
This must be very much a back of an envelope
calculation. Suppose we have a country
with a population of $70$ million an a lifetime
expectancy of $70$ years. This suggests a million
births a year. If the birth figure remained
unaltered but smallpox became endemic and
the risk of dying from other causes remained
the same then, since the death rate for young people
is presently negligible and essentially everyone
would expect to get smallpox, there would be
a million cases of smallpox a year. If the death rate
was one in $14$ this would give $70$ thousand deaths a year.
If we took the overoptimistic assumption that modern medicine
could get this down to $1$ in a hundred we would still
have $10$ thousand deaths a year.
\newpage\section*{Exercise~\ref{E;insurance Jensen}}
(Corrected by Nigel White.)
We have $f'(t)=1/t$ and $f''(t)=-1/t^{2}<0$ so $f$ is 
a smooth concave function.

With probability $1/2$ my fortune will be
\[2a-av=a(2-v)\]
and with probability $1/2$ my fortune will be 
\[\tfrac{1}{2}a+kav-av=a(\tfrac{1}{2}+k-v).\]
Thus
\[{\mathbb E}f(Y)=g(v)
=\frac{1}{2}\log\big(a(2-v)\big)
+\frac{1}{2}\log\big(a(\tfrac{1}{2}+(k-1)v)\big).\]

Now 
\[g'(v)=\frac{1}{2}\left(-\frac{1}{2-v}
+\frac{k-1}{\tfrac{1}{2}+(k-1)v}\right)
=\frac{1}{2}\times\frac{(2k-\tfrac{5}{2})-2(k-1)v}
{(2-v)(\tfrac{1}{2}+(k-1)v)}.\]
Thus, if we take
\[v_{0}=\frac{2k-\tfrac{5}{2}}{2(k-1)}\]
$g$ is strictly increasing for $v<v_{0}$ and 
strictly decreasing for $v>v_{0}$.
Thus I will buy insurance only if
\[v_{0}>0\]
and I will then set $v=v_{0}$.

The insurance companies expected gain
is
\begin{align*}
u(k)&=av_{0}-\tfrac{1}{2}kav_{0}\\
&=\frac{a}{8}\frac{(-4k^{2}+13k-10)}{k-1}\\
\end{align*}
so
\[
u'(k)
=-\frac{a}{8}\frac{2k^{2}-8k+3}{(k-1)^{2}}\]
and the insurance company should take
\[k=3/2.\]
\newpage\section*{Exercise~\ref{E;converse Jensen}}
(i) Let
\[\Pr(X=x)=t,\ \Pr(X=y)=1-t.\]
Then
\[tf(x)+(1-t)f(y)={\mathbb E}f(X)\leq f({\mathbb E}X)
=f\big(tx+(1-t)y\big)\]
for all $0\leq t\leq 1$.

(ii) If $x<v<y$ and we set $t=(y-v)/(y-x)$ then $0<t<1$
and
\begin{align*}
tx+(1-t)y&=\frac{(y-v)x+\big((y-x)-(y-v)\big)y}{y-x}\\
&=\frac{(y-v)x+(v-x)\big)y}{y-x}=v.
\end{align*}
Thus
\[tf(x)+(1-t)f(y)\leq f(v)=tf(v)+(1-t)f(v)\]
so 
\[t\big(f(x)-f(v)\big)\leq (1-t)\big(f(v)-f(y)\big)\]
whence
\[(y-v)\big(f(x)-f(v)\big)\leq (v-x)\big(f(v)-f(y)\big).\]
It follows that
\[(y-v)\big(f(v)-f(x)\big)\geq (v-x)\big(f(y)-f(v)\big)\]
and
\[\frac{f(v)-f(x)}{v-x}\geq \frac{f(y)-f(v)}{y-v}.\]

(iii) By (ii)
\[\frac{f(b)-f(a)}{b-a}\geq\frac{f(c)-f(b)}{c-b}
\geq\frac{f(d)-f(c)}{d-c}.\]
Note that it follows that
\[\frac{f(a)-f(b)}{a-b}\geq\frac{f(c)-f(d)}{c-d}.\]

(iii) If $|k|<(y-x)/2$ we may apply (ii) to get
\[\frac{f(x+k)-f(x)}{k}\leq \frac{f(y+k)-f(y)}{k}.\]
Allowing $k\rightarrow 0$ we get
\[f'(x)\leq f'(y)\]
(remember that we suppose $f$ well behaved).
Since $f'$ is decreasing $f''(t)\leq 0$ for all $t$.
\newpage\section*{Exercise~\ref{E;golf}}
\begin{gather*}
{\mathbb E}X_{1}=74,\ \var X_{1}=1\\
{\mathbb E}X_{2}=75,\ \var X_{2}=25\\
{\mathbb E}X_{3}=80,\ \var X_{3}=\frac{2}{3}10^{2}=\frac{200}{3}
\end{gather*}
The first player never wins, the second player
wins with probability $1/2$ and the third
with probability $1/3$. I should choose the
second player. (Moral, the mean and variance
do not tell you everything.)
\newpage\section*{Exercise~\ref{E;double money}}
If I am in a shop and suddenly the price of everything
is doubled but the amount of money in my purse
is doubled I will make the same choices.
\newpage\section*{Exercise~\ref{E;Jensen}}
(i) We use induction on $n$. The result is trivially true
when $n=1$. Suppose it is true for $n=m$. Then
Using Theorem~\ref{T;Jensen}, we have (if $t_{m+1}\neq 1$)
\begin{align*}
f(t_{1}x_{1}+&t_{2}x_{2}+\dots+t_{m+1}x_{m+1})\\
&=f\left((1-t_{m+1})\sum_{j=1}^{m}\frac{t_{j}}{1-t_{m+1}}x_{j}
+t_{m+1}x_{m+1}\right)\\
&\leq (1-t_{m+1})f\left(\sum_{j=1}^{m}\frac{t_{j}}{1-t_{m+1}}\right)
+t_{m+1}f(x_{m+1}).
\end{align*}
But 
\[\frac{t_{j}}{1-t_{m+1}}\geq 0
\ \text{and}\ \sum_{j=1}^{m}\frac{t_{j}}{1-t_{m+1}}\]
so our inductive hypothesis shows that
\[\sum_{j=1}^{m}\frac{t_{j}}{1-t_{m+1}}f(x_{j})\leq
f\left( \sum_{j=1}^{m}\frac{t_{j}}{1-t_{m+1}}x_{j}\right)\]
and so
\[
f(t_{1}x_{1}+t_{2}x_{2}+\dots+t_{m+1}x_{m+1})
\leq f(t_{1}x_{1}+t_{2}x_{2}+\dots+t_{n}x_{m+1}).\]
The full result now follows by induction.

(ii) Since $f''(t)=-1/t^{2}$ we know that $f$ is concave
so
\[\frac{1}{n}\log x_{1}+\frac{1}{n}\log x_{2}+\dots
+\frac{1}{n}\log x_{n}
\leq \log \left(\frac{1}{n} x_{1}+\frac{1}{n} x_{2}+\dots
+\frac{1}{n} x_{n}\right)\]
that is to say
\[\log (x_{1}x_{2}\dots x_{n})^{1/n}
\leq \log \frac{x_{1}+x_{2}+\dots+x_{n}}{n}\]
so applying $\exp$ to both sides
\[(x_{1}x_{2}\dots x_{n})^{1/n}
\leq  \frac{x_{1}+x_{2}+\dots+x_{n}}{n}.\]

(iii) We have
\[g'(x)=x^{p^{-1}-1}(1+x^{p^{-1}})^{(p-1)}\]
so
\begin{align*}
g''(x)&=(p^{-1}-1)x^{-2+p^{-1}}(1+x^{p^{-1}})^{(p-1)}\\
&\qquad\qquad+(p-1)(p^{-1}-1)x^{-2+2p^{-1}}(1+x^{p^{-1}})^{p-2}\\
&<0
\end{align*}
so $g$ is concave.

Taking
\[x_{k}=\frac{b_{k}^{p}}{a_{k}^{p}}
\ \text{and}
\ t_{k}=a_{k}^{p},\]
Jensen's inequality
\[t_{1}g(x_{1})+t_{2}g(x_{2})+\dots+t_{n}g(x_{n}) 
\leq g(t_{1}x_{1}+t_{2}x_{2}+\dots+t_{n}x_{n})\]
gives 
\[\sum_{k=1}^{n}a_{k}^{p}\left(1+\frac{b_{k}}{a_{k}}\right)^{p}
\leq \left(1+\left(\sum_{k=1}^{n}b_{k}^{p}\right)^{1/p}\right)^{p}\]
which simplifies to
\[\sum_{k=1}^{n}a_{k}^{p}(a_{k}+b_{k})^{p})^{p}
\leq \left(1+\left(\sum_{k=1}^{n}b_{k}^{p}\right)^{1/p}\right)^{p}\]
and taking $p$th roots we obtain the required inequality.

(iv) Take $T=\left(\sum_{j=1}^{n}t_{j}^{p}\right)^{1/p}$ 
and set $a_{j}=t_{j}/T$, $b_{j}=s_{j}/T$. The
inequality of~(iii) the holds and, multiplying through by
$T$, we obtain
\begin{align*}
\big((t_{1}+s_{1})^{p}+&(t_{2}+s_{2})^{p}+\dots
+(t_{n}+s_{n})^{p}\big)^{1/p}\\
&\leq \big(t_{1}^{p}+t_{2}^{p}+\dots
+t_{n}^{p}\big)^{1/p}
+\big(s_{1}^{p}+s_{2}^{p}+\dots
+s_{n}^{p}\big)^{1/p}.
\end{align*}
 Thus
\begin{align*}
\big(|u_{1}&+v_{1}|^{p}+|u_{2}+v_{2}|^{p}+\dots
+|u_{n}+v_{n}|^{p}\big)^{1/p}\\
&\leq\big( (|u_{1}|+|v_{1}|)^{p}+(|u_{2}|+|v_{2}|)^{p}+\dots
+(|u_{n}|+|v_{n}|^{p})\big)^{1/p}\\
&\leq \big(|u_{1}|^{p}+|u_{2}|^{p}+\dots
+|u_{n}|^{p}\big)^{1/p}
+\big(|v_{1}|^{p}+|v_{2}|^{p}+\dots
+|v_{n}^{p}|\big)^{1/p}.
\end{align*}

\begin{align*}
|OU|+|OV|&=(u_{1}^{2}+u_{2}^{2})^{1/2}+(v_{1}^{2}+v_{2}^{2})^{1/2}\\
&=(u_{1}^{2}+u_{2}^{2})^{1/2}+\big((-v_{1})^{2}+(-v_{2})^{2}\big)^{1/2}\\
&\geq \big((u_{1}-v_{1})^{2}+(u_{2}-v_{2})^{2}\big)^{1/2}\\
&=|UV|
\end{align*}

In three dimensions
\begin{align*}
|OU|+|OV|&=(u_{1}^{2}+u_{2}^{2}+u_{3}^{2})^{1/2}
+(v_{1}^{2}+v_{2}^{2}+v_{3}^{2})^{1/2}
\\
&=(u_{1}^{2}+u_{2}^{2}+u_{3}^{2})^{1/2}+
\big((-v_{1})^{2}+(-v_{2})^{2}+(-v_{3})^{2}\big)^{1/2}\\
&\geq \big((u_{1}-v_{1})^{2}+(u_{2}-v_{2})^{2}
+(u_{3}-v_{3})^{2}\big)^{1/2}\\
&=|UV|
\end{align*}

(v) $h'(x)=-(\log x+1)$ so $h''(x)=-1/x$.
Thus
\[h(tu+(1-t)v)\geq th(u)+(1-t)h(v)\]
for $1\geq t\geq 0$, $u,\,v>0$. Taking
\[t=\frac{a}{a+b},\ u=\frac{x}{a},\ v=\frac{y}{b}\]
this gives
\[-\frac{x+y}{a+b}\log\frac{x+y}{a+b}\geq 
-\frac{1}{a+b}x\log \frac{x}{a}
-\frac{1}{a+b}y\log \frac{y}{b}\]
so, multiplying by $-(a+b)$ we obtain
\[(x+y)\log\frac{x+y}{a+b}
\leq x\log\frac{x}{a}+y\log\frac{y}{b}\]
for all $a,\,b,\,x,\,y>0$.



\newpage\section*{Exercise~\ref{E;little finite}}
It is sufficient to deal with the case $a,b\geq 0$. Observe that
\[f(x)=-x^{p}\]
defines a concave function so, by Jensen's inequality,
\[f(\tfrac{1}{2}a+\tfrac{1}{2}b)\geq \tfrac{1}{2}f(a)+\tfrac{1}{2}f(b)\]
so
\[(a+b)^{p}\leq 2^{p-1}(a^{p}+b^{p})\]

But, if $a=b=1$,
\[(a+b)^{p}= 2^{p-1}(a^{p}+b^{p})\neq 0\]
so $c_{p}=2^{p-1}$ is the required constant.

\newpage\section*{Exercise~\ref{E;entropy}}
Observe that $p_{i}q_{j}>0$ and
\[\sum_{i=1}^{n}\sum_{j=1}^{m}p_{i}q_{j}
=\sum_{i=1}^{n}p_{i}sum_{j=1}^{m}q_{j}=1\times 1=1.\]
Thus by Jensen's inequality
\[\sum_{i=1}^{n}\sum_{j=1}^{m}p_{i}q_{j}h(t_{ij})
\geq h\left(\sum_{i=1}^{n}\sum_{j=1}^{m}p_{i}q_{j}t_{ij}\right)\]
for all $t_{ij}>0$. Setting
\[t_{ij}=\frac{\pi_{ij}}{p_{i}q_{j}},\]
we get
\[-\sum_{i=1}^{n}\sum_{j=1}^{m}\pi_{ij}\log \frac{\pi_{ij}}{p_{i}q_{j}}
\geq h(0)=0\]
so $I\leq 0$.

We have equality when $\pi_{ij}=p_{i}q_{j}$.
(And only then, by drawing a diagram we see that we have strict inequality
unless all the $t_{ij}$ are equal.)

Suppose $X$ and $Y$ are random variables
with $X$ taking  distinct values $x_{1}$, $x_{2}$, \dots, $x_{n}$
and $Y$ taking  distinct values $y_{1}$, $y_{2}$, \dots, $y_{m}$.
Suppose $\Pr(X=x_{i},Y=y_{j})>0$ for $1\leq i\leq n$, $1\leq j\leq m$.
Then
\[I=\sum_{i=1}^{n}\sum_{j=1}^{m}\Pr(X=x_{i},Y=y_{j})
\log \frac{\Pr(X=x_{i},Y=y_{j})}{\Pr(X=x_{i})\Pr(Y=y_{j})}\]
is maximised when $X$ and $Y$ are independent.

\section*{Exercise~\ref{E;guess end}$^{*}$}
\newpage\section*{Exercise~\ref{E;recurrence world}}
If $k_{n}=2^{n}-1$, then
\[k_{n+1}=2k_{n}+1=2^{n+1}-2+1=2^{n+1}-1.\]
But $k_{1}=1=2^{1}-1$ so, by induction,
\[k_{n}=2^{n}-1\]
for all $n\geq 1$.
\newpage\section*{Exercise~\ref{E;long Hanoi}}
With $256$ disks at one operation per Planck time
it will take at least
\[(2^{256}-1)\times 5\times 10^{-44}\times \frac{1}{31600000}
\approx 1.8\times 10^{26}\]
years. She should stick to old fashioned ways.
\newpage\section*{Exercise~\ref{E;inductive Hanoi}}
Let $P(n)$ be the statement that, if we follow the
rules we will move a tower of size clockwise one place if $n$ is odd
and anticlockwise one place if $n$ is even taking $2^{n}-1$
moves.

By inspection $P(1)$ is true.

Now suppose $P(n)$ is true.
By the inductive hypothesis the first $2^{n+1}-1$
moves will move the top $n$ pieces one
place clockwise if $n$ is odd, anticlockwise
if $n$ is even. The largest piece is now exposed
and moved to the empty peg anticlockwise if $n$ is odd, 
clockwise if $n$ is even by the $2^{n+1}$th move.
The remaining $2^{n}$ moves take the top $n$ pieces one
place clockwise if $n$ is odd, anticlockwise
if $n$ is even so they form a tower over the largest piece.
Thus $P(n+1)$ is true.

The desired result follows by induction.
\newpage\section*{Exercise~\ref{E;find common 1}}
(i) If $d$ divides $a$ and $b$ then $a=k\times d$,
$b=l\times d$ so $a=k\times d$, $-b=(-l)\times d$.
Thus $d$ is no greater than the s greatest common
divisor $d'$ of $a$ and $-b$. Similarly $d'\leq d$
so $d=d'$.

(ii) $182=2\times 7\times 13$ and
$140=2\times 5\times 7$ so the greatest common divisor is $2\times 7=14$.

(iii) $815\,055=3\times 5 \times 67 \times 811$,
and $208\,427=257\times 811$ all factors being prime. 
(It is not hard for me to multiply
primes together. It is much harder for you to find them.)
The greatest common divisor is $811$.
\newpage\section*{Exercise~\ref{E;Bezout}}
If $c$ divides $a$ and $b$ then $a=kc$, $b=lc$
and using the notation of Lemma~\ref{L;Bezout 1},
\[d=ma+nb=mkc+nlc=(mk+nl)c\]
so $c$
divides $d$.
\newpage\section*{Exercise~\ref{E;Euclid polynomials}}
(i) If $a_{n}\neq 0$
\[\sum_{j=0}^{n}a_{j}x^{j}=a_{n}\left(x^{n}
+\sum_{j=0}^{n-1}\frac{a_{j}}{a_{n}}x^{j}\right).\]

(ii) Long division.

The result is true when $P$ has degree $0$. (If $n=0$ then
$K=P/Q$, $R=0$; if $n\geq 1$ then $K=0$, $R=P$.)

Suppose it is true whenever $P$ has degree $m$ or less.
If $P$ has degree $m+1$ either $m+1<n$
and $K=0$, $R=P$ or
\[P(t)=b_{m+1-n}t^{m+1-n}Q(t)+S(t)\]
where $b_{m+1-n}$ is the value of the leading coefficient of $P$
divided by the value of the leading coefficient of $Q$
and $S$ has degree at most $m$. By the inductive hypothesis,
\[S(t)=L(t)Q(t)+R(t)\]
where $R$ has degree strictly less than $n$
and so
\[P(t)=\big(b_{m+1-n}t^{m+1-n}+L(t)\big)Q(t)+R(t).\]
The required result is thus true when $P$ has degree $m+1$
or less.

The conclusion follows by induction.

(iii) Since $1$ divides $P$ and $Q$ and no
polynomial of degree strictly higher than the degree of $P$
divides $P$ there must be a monic polynomial $S$ of highest
degree dividing $P$ and $Q$.

(iv) Consider the collection of polynomials $U(x)P(x)+V(x)Q(x)$
with $U$ and $V$ not both zero. This must contain a polynomial 
of lowest degree and so a monic polynomial $T$ of the same
degree. Since $S$ is a factor of $P$ and $Q$, $S$ divides $T$.

Now $P=KT+R$ where $R$ has degree less than $T$. Thus
(for appropriate $U$ and $V$)
\[R=P-KT=P-K(UP+VQ)=(1-KU)P+(-KV)Q\]
and so $R=0$. Thus $T$ divides $P$ and similarly $T$ divides $Q$.
Thus The degree of $T$ is less than or equal to the degree of $S$
and $T=S$. (Thus $T$ and $S$ must be unique.) 

(v) We call $S$ the highest common factor of $P$ and $Q$.
Since 
\[S(x)=U(x)P(x)+V(x)Q(x)\]
it follows that if $W=AS$ we have $W=(US)P+(UV)Q$.

If $W=\tilde{U}P+\tilde{V}Q$ then since $S$ divides $P$ and $Q$,
$S$ divides $W$.  
\newpage\section*{Exercise~\ref{E;find Bezout}}
(i) We want
\[1=13u+10v\]
and a little experimentation (or thought about last digits)
suggests $u=7$, $v=-9$.

(ii) Rather you than me.

\newpage\section*{Exercise~\ref{E;Euclid stop}}
\[|a|,\,|b|\leq 10^{300}=1000^{100}< 2^{1000}.\]
Now apply Lemma~\ref{L;Euclid stop}.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;try Bezout}$*$}
\newpage\section*{Exercise~\ref{E;monkey}}
Suppose they start with $n$ coconuts and the captain's initial
share is $n_{1}$, the First Mate's share $n_{2}$
and so on down to the cabin boy who gets $n_{5}$.
Let the the number of remaining coconuts be $5m$.
We have
\begin{align*}
n&=5n_{1}+1\\
4n_{1}&=5n_{2}+1\\
4n_{2}&=5n_{3}+1\\
4n_{3}&=5n_{4}+1\\
4n_{4}&=5n_{5}+1\\
4n_{5}&=5m
\end{align*}
Thus
\begin{align*}
4^{5}n&=5\times 4^{5}n_{1}+4^{5}\\
&=5\times 4^{4}(5n_{2}+1)+4^{5}=5^{2}\times 4^{4}n_{2}+5\times4^{4}+4^{5}\\
&\vdots\\
&=5^{6}m++4\times 5^{4}+\dots+4^{5})\\
&=5^{6}m+\frac{5^{6}-4^{6}}{5-4}-5^{5}=5^{6}m+ 5^{6}-4^{6}-5^{5}
\end{align*}
Thus
\[\tag*{$\bigstar$} 1024 n=15625m+8404 .\]
 
Let us apply Euclid's algorithm to $15625$ and $1024$
We have
\begin{gather*}
15625=15\times 1024+265
1024=4\times 265-36\\
265=7\times 36=13\\
36=3\times 13-3\\
13=4\times 3+1.
\end{gather*}
Thus
\begin{align*}
1&=13-4\times 3=13-4\times(3\times 13-36)=4\times 36-11\times 13\\
&=4\times 36-11\times(265-7\times 36)
=81\times 36-11\times 265\\
&=81\times(4\times 265-1024)-11\times 265
=313\times265-81\times1024\\
&=313\times(15625-15\times 1024)-81\times 1024\\
&=313\times 15625-4776\times 1024.
\end{align*}
Thus one solution of $\bigstar$ is
\[n=-8404\times 4776=-40137504,
\ m=-8404\times 313=-2630452.\]
But since $1024=4^{5}$ and $15625=5^{6}$ are coprime
we know that the solutions of $\bigstar$ are given by
\begin{align*}
n&= -40137504+15625k\\
m&= -2630452+1024k
\end{align*}
with $k$ integer. Since $2630452=2569\times 1024-204$
we see that $m=204$ gives the smallest possible positive value of $m$
corresponding to the smallest positive value of $n$ which is
$3121$.
\newpage\section*{Exercise~\ref{E;quick common factor}}
This is really a repetition of known results.
If $d$ divides $a$ and $b$ then it must divide the
highest common factor. But, by Lemma~\ref{L;Bezout 2}~(ii)
the highest common factor must divide $d$.
Thus $|d|$ is the highest common factor.
\newpage\section*{Exercise~\ref{E;lowest common}}
(i) The set of strictly positive integers divisible by $a$ and $b$
contains $|ab|$ so is non-empty and has a least member.

(ii) Choose the integer $v$ so that
\[0\leq n+ve<e.\]
Now $a$ and $b$ divide $n+ve$ so, by definition of $e$, 
$n+ve=0$. Thus $n=(-v)e$ and $e$ divides $n$.

(iii) Observe that
\[\frac{ab}{d}=a\frac{b}{d}=b\frac{a}{d}\]
so $a$ and $b$ divide $e$. Thus $ab/d\geq e$.

By part~(ii), $e$ divides $ab$ so $ab/e$ is an integer with
\[a=\frac{ab}{e}\frac{e}{b},\ b=\frac{ab}{e}\frac{e}{a}\]
Thus $ab/e\leq d$ so $ab\leq de\leq ab$ and $ab=de$.

If $a$ and $b$ are not necessarily positive repeat the argument
with $|a|$ and $|b|$.

(iv) We have
\begin{align*}
22015&=4\times 5291+851\\
5291&=6\times 851+185\\
851&=5\times 185-74\\
185&=2\times 74+37\\
74&=2\times 37
\end{align*}
Thus $22\,015$ and
$5291$ have highest common divisor $37$
and lowest common multiple
\[\frac{22015\times 5291}{37}=3148145.\]
\newpage\section*{Exercise~\ref{E;Euclid polynomials 2}}
Given polynomials $P_{1}$, $P_{2}$ with
the degree $\partial P_{1}$ no larger than
$\partial P_{2}$ then either
\[P_{1}=Q_{1}P_{2}\]
for some polynomial $Q$ and (after multiplication
by a constant to make it monic) $P_{2}$ is the required polynomial
or
\[P_{1}=Q_{1}P_{2}+P_{3}\]
with $\partial P_{3}<\partial P_{2}$
but $P_{3}\neq 0$. We observe that if $S$  divides
$P_{2}$ and $P_{3}$ then $S$ divides $P_{1}$ and $P_{2}$
and conversely so (if $\gcd(A,B)$ is the monic
polynomial of highest degree dividing $A$ and $B$)
\[\gcd(P_{1},P_{2})=\gcd(P_{2},P_{3}).\]
Further if
\[A_{2}P_{2}+A_{3}P_{3}=B\]
then
\[A_{3}P_{1}+(A_{2}-Q_{1})P_{2}=B.\]


We can repeat the process but since the degree
of at least one of the polynomial pairs decreases
at each step the process must terminate giving us
$S=\gcd(P_{1},P_{2})$. Reversing the process as indicated
computes $U$ and $V$ such that
\[S(x)=U(x)P(x)+V(x)Q(x).\]
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;Sunzi}$^{*}$}
\newpage\section*{Exercise~\ref{E;Jourdain}}
(i) In $279$ months a certain number of years
and $3$ months will have passed. Count $3$ months forward.

(ii) Every breakfast is $2$ hours earlier so the
$200$th breakfast is $400$ hours earlier, that
is to say a certain number of days and $16$ hours earlier
which is to say a certain other number of days and $8$ hours later.
She will breakfast at $4$ am.

(iii) Odd.
\newpage\section*{Exercise~\ref{E;cast nine}}
Observe that
\[10\equiv 1 \mod{9}\]
so
\[10^{r}\equiv 1^{r}\equiv 1 \mod{9}\]
\[a_{n}10^{n}+a_{n-1}10^{n-1}+\dots+a_{0}
\equiv a_{n}+a_{n-1}+\dots+a_{0}\]
and
\begin{align*}
\big(a_{n}10^{n}+a_{n-1}10^{n-1}&+\dots+a_{0}\big)
\times\big(b_{n}10^{n}+b_{n-1}10^{n-1}+\dots+b_{0}\big)\\
&\equiv 
(a_{n}+a_{n-1}+\dots+a_{0})
\times (b_{n}+b_{n-1}+\dots+b_{0}).
\end{align*}

(ii) Casting out nines produces an equation involving smaller
integers
which remains true modulo $9$. After a finite number of steps 
we have integers between $0$ and $8$ which must be equal.

Reverse obviously false
\[18\rightarrow 9\rightarrow 0\]
and
\[3\times 9\rightarrow 3\times 0=0\]
but $18\neq 3\time 9$.

Since
\begin{align*}
\big(a_{n}10^{n}&+a_{n-1}10^{n-1}+\dots+a_{0}\big)
\times\big(b_{n}10^{n}+b_{n-1}10^{n-1}+\dots+b_{0}\big)\\
&\equiv 
(a_{n}+a_{n-1}+\dots+a_{0})
\times (b_{n}+b_{n-1}+\dots+b_{0}).
\end{align*}
and
\begin{align*}
\big(a_{n}10^{n}&+a_{n-1}10^{n-1}+\dots+a_{0}\big)
\times\big(b_{n}10^{n}+b_{n-1}10^{n-1}+\dots+b_{0}\big)\\
&\equiv 
(a_{n}+a_{n-1}+\dots+a_{0})
\times (b_{n}+b_{n-1}+\dots+b_{0}).
\end{align*}
modulo $9$ the method will also work for addition
and subtraction.
\newpage\section*{Exercise~\ref{E;reduce Pascal}}
(i)Observe that if $n\geq 2$
\[0\equiv 0^{n}\equiv (1+1)^{n}\equiv 
\binom{n}{0}+\binom{n}{1}+\binom{n}{2}
+\dots+\binom{n}{n}\]
modulo $2$ thus there must be an even number
of $r$ with
\[\binom{n}{r}\equiv 1\mod{2}\]
and this is what is claimed.

If $n=0$ then $(1+1)^{n}\equiv(1+1)^{0}\equiv 1\not\equiv 0$ modulo $2$.

(ii) We have 
\begin{gather*}
1\\
11\\
101\\
1111\\
10001\\
110011\\
1010101\\
11111111\\
100000001\\
1100000011\\
10100000101
\end{gather*}
\newpage\section*{Exercise~\ref{E;simultaneous 1}}
By observing that $x=-1$ is a solution and
that any other solution must have the form
$-1+K$ with $K$ divisible by $6$ and $10$
whilst everything of this form is a solution
we see that the solutions are
\[-1+30n\]

Now $1000000\equiv 10$ modulo $30$ so the least number of the
required form is $1000019$.
\newpage\section*{Exercise~\ref{E;simultaneous 2}}
We wish to solve
\begin{align*}
x&\equiv 2\mod{3},\\ 
x&\equiv 1\mod{4}.
\end{align*}
If $x$ is a solution so is $x+12k$
and inspection of the table shows that there
is precisely one solution (viz $x=5$) with $0\leq x\leq 11$.

Thus there are $3$ solutions with $0\leq x\leq 35$

(ii)  In the following
table $r_{1}\equiv r\mod{4}$, $0\leq r_{1}\leq 3$ and $r_{2}\equiv r\mod{6}$,
$0\leq r\leq 6$
\begin{center}
\begin{tabular}{lcccccccccccc}
$r=$&0&1&2&3&4&5&6&7&8&9&10&11\\
$r_{1}=$&0&1&2&3&0&1&2&3&0&1&2&3\\
$r_{2}=$&0&1&2&3&4&5&0&1&2&3&4&5
\end{tabular}
\end{center}
We note that
\begin{align*}
x&\equiv x+12n\mod{4},\\ 
x&\equiv x+12n\mod{6}.
\end{align*}
Thus by inspection of the table
\begin{align*}
x&\equiv 2\mod{4},\\ 
x&\equiv 4\mod{6}.
\end{align*}
has $4$ solutions with  $0\leq x\leq 47$ but
\begin{align*}
x&\equiv 3\mod{4},\\ 
x&\equiv 4\mod{6}.
\end{align*}
has none.
\newpage\section*{Exercise~\ref{E;work Chinese}}
We first seek to solve
\begin{align*}
y&\equiv 1\mod{17},\\
y&\equiv 0\mod{19}.
\end{align*}
that is, to find $a,\,b$ such that
\[19a+17b=1\]
Now
\[19-17=2\]
and
\[17=2\times 8+1\]
so
\[1=(19-17)\times(-8)+17=(-8)\times 19+9\times 17\]
Thus $y=(-8)\times 19=-152$ is a possible solution.

If we set $z=9\times 17=153$
then
\begin{align*}
z&\equiv 0\mod{17},\\
z&\equiv 1\mod{19}.
\end{align*}

Thus (since $17$ and $19$ are coprime) the general solution
to our problem is
\[x=3\times(-152)-2\times(153)+n\times17\times 19
=-762+323n=207+323m\]
with $m$ an integer.

The smallest positive solution is $207$.
\newpage\section*{Exercise~\ref{E;for partial Chinese}}
Since $a$ and $b$ have highest common factor $1$,
Euclid's algorithm tells us that there exist
$m$ and $n$ such that
\[am+bn=1.\]
Similarly, there exist
$r$ and $s$ such that
\[ar+cs=1.\]
Thus
\[1=(am+bn)(ar+cs)=a(mar+mcs+bnr)+bc(ns).\]
Setting $N=mar+mcs+bnr$ and $M=bc$, we have
\[1=Na+Mbc\]
so $a$ and $bc$ have highest common factor $1$.
\newpage\section*{Exercise~\ref{E;Chinese partial}}
By Exercise~\ref{E;for partial Chinese},
$a_{1}$ and $a_{2}a_{3}$ are coprime so
we can find a $z_{1}$
such that
\begin{align*}
z_{1}&\equiv 1\mod{a_{1}},\\ 
z_{1}&\equiv 0\mod{a_{2}a_{3}}.
\end{align*}
Thus
\begin{align*}
z_{1}&\equiv 1\mod{a_{1}},\\ 
z_{1}&\equiv 0\mod{a_{2}},\\
z_{1}&\equiv 0\mod{a_{3}}
\end{align*}
More generally we can find $z_{j}$
with $z_{j}\equiv 1\mod{a_{j}$ and
$z_{k}\equiv 1\mod{a_{k}}$ for $k\neq j$.
Now $x=u_{1}z_{1}+u_{2}z_{2}+u_{3}z_{3}$
satisfies $\bigstar\bigstar$.

If $x_{0}$ and $x_{1}$ are solutions of $\bigstar\bigstar$
then $x_[0}-x_{1}$ is divisible by $a_{1}$, $a_{2}$
and $a_{3}$ so $x_{0}-x_{1}$ is divisible by 
the lowest common multiple of $a_{1}$, $a_{2}$
and $a_{3}$ ie by $|a_{1}a_{2}a_{3}|$.
Thus
\[x_{0}\equiv x_{1}\mod a_{1}a_{2}a_{3}.\]
The converse is immediate.

The same arguments show that if we have non zero
integers $a_{k}$ $[1\leq k\leq n]$
such that each pair $(a_{i},a_{j})$
with $i\neq j$ has highest common divisor $1$
then given integers $u_{k}$
we can find an $x$ such that
\[x\equiv u_{k}\mod{a_{k}}.\]
If $x_{0}$ is a solution then the solutions are given
by 
\[x_{0}\equiv x_{1}\mod a_{1}a_{2}\dots a_{n}.\]
\newpage\section*{Exercise~\ref{E;do Sunzi}}
Note that $3$, $5$, $7$ are coprime.
By rapid search (or we could use Euclid's algorithm).
\begin{align*}
-35&\equiv 1\mod{3},\\ 
-35&\equiv 0\mod{5},\\
-35&\equiv 0\mod{7}.
\end{align*}
\begin{align*}
21&\equiv 0\mod{3},\\ 
21&\equiv 1\mod{5},\\
21&\equiv 0\mod{7}.
\end{align*}
\begin{align*}
15&\equiv 0\mod{3},\\ 
15&\equiv 0\mod{5},\\
15&\equiv 1\mod{7}.
\end{align*}
Sunzi's problem is to solve
\begin{align*}
x&\equiv 2\mod{3},\\ 
x&\equiv 3\mod{5},\\
x&\equiv 2\mod{7}.
\end{align*}
Thus the general solution is
\[x=-70+63+30+105n=23+105n\]
and the least positive solution is $23$.
\newpage\section*{Exercise~\ref{E;Age}}
\begin{small}
\begin{gather*}
A\equiv 0-1039470\equiv 0\mod{3}\\
A\equiv (3^{2}+0-(-1)^{7}-9)\times 1-0\equiv 1\mod{5}\\
A\equiv (1^{2}+0-(2^{3})^{4}\times 4-3)\times(-1)-5
\equiv -(1-4-3)-5\equiv 1\mod{7}
\end{gather*}
\end{small}
so using the results of Exercise~\ref{E;do Sunzi}
their age 
\[x=0\times(-35)+1\times 21+1\times 15+105n=36+105n\]
so they are $36$.
\newpage\section*{Exercise~\ref{E;Chinese Euclid}}
If $n,\,m.\,k,\,r$ are strictly positive integers
with
\[n=mk+r\] 
and $m>r$ then
\begin{align*}
2^{n}-1&=2^{n}-2^{r}+2^{r}-1\\
&=2^{r}(2^{m}-1)(2^{(k-1)m}+2^{(k-2)m}+\dots+1)+2^{r}-1
\end{align*}
so
\[2^{n}-1=M(2^{m}-1)+(2^{r}-1)\]
and Euclid's algorithm works in parallel with
the indices.

Thus
$\gcd(2^{n}-1,2^{m}-1)=2^{\gcd(n,m)}-1$.

\newpage\section*{Exercise~\ref{E;Chinese general}}
(i) If $d$ divides $a_{i}$ and $a_{j}$
and
\begin{align*}\tag*{$\bigstar\bigstar$}
x&\equiv u_{i}\mod{a_{i}},\\
x&\equiv u_{j}\mod{a_{j}}
\end{align*}
then since $a_{i}$ divides $x-u_{i}$
and $a_{j}$ divides $x-u_{j}$ it follows that
$d$ divides $x-u_{i}$ and  $x-u_{j}$
so $d$ divides 
\[u_{i}-u_{j}=(x-u_{j})-(x-u_{i})\]
and
\[u_{i}\equiv u_{j}\mod{d}.\]
Taking $d=\gcd(a_{i}, a_{j})$ gives the desired result.

Suppose
\begin{align*}
x&\equiv u_{1}\mod{a_{1}},\\
x&\equiv u_{2}\mod{a_{2}},\\
x&\equiv u_{3}\mod{a_{3}}.
\end{align*}
Then
\begin{align*}
x'&\equiv u_{1}\mod{a_{1}},\\
x'&\equiv u_{2}\mod{a_{2}},\\
x'&\equiv u_{3}\mod{a_{3}}.
\end{align*}
if and only if
\begin{align*}
x-x'&\equiv 0\mod{a_{1}},\\
x-x'&\equiv 0\mod{a_{2}},\\
x-x'&\equiv u_{3}\mod{a_{3}}.
\end{align*}
that is to say $a_{j}$ divides $x-x'$ for each $j$.

Let us write $e$ for the lowest common multiple
of $a_{1}$, $a_{2}$ and $a_{3}$. 
Suppose $a_{j}$ divides $y$ for each $j$,
then we can find a $k$ such that
\[e>y-ke\geq 0.\]
Since $a_{j}$ divides $y-ke$ for each $j$
it follows by minimality that $y=ke$ so $e$ divides $y$.
The converse is trivial.

Thus
\begin{align*}
x'&\equiv u_{1}\mod{a_{1}},\\
x'&\equiv u_{2}\mod{a_{2}},\\
x'&\equiv u_{3}\mod{a_{3}}.
\end{align*}
if and only if $e$ divides $x-x'$, ie 
if and only if
\[x\equiv x'\mod{e}\]

(ii) Set $x_{1}=u_{1}$

Now  $x_{1}-u_{2}$ and $a_{1}$ are
both divisible by the highest common divisor of
$a_{1}$ and $a_{2}$ so by Euclid's algorithm
we can find $k$ and $m$  
such that
\[ka_{1}+ma_{2}=x_{1}-u_{2}.\]
Thus setting
\[x_{2}=x_{1}-ka_{1}\]
we have
\begin{align*}
x_{2}&\equiv x_{1}\equiv u_{1}\mod{a_{1}},\\
x_{2}&\equiv x_{1}-ka_{1}\equiv u_{2}+ma_{2}\equiv u_{2}\mod{a_{2}}.
\end{align*}

Let $f$ be the lowest common multiple of $a_{1}$ and $a_{2}$.
We observe that
$x_{1}-u_{3}$ and $f$ are
both divisible by the highest common divisor of
$f$ and $a_{3}$
so by Euclid's algorithm
we can find $K$ and $M$  
such that
\[kf+Ma_{3}=x_{2}-u_{3}.\]
Thus setting
\[x_{3}=x_{2}-Kf\]
we have
\begin{align*}
x_{3}&\equiv x_{2}-Kf\equiv x_{2}\equiv u_{1}\mod{a_{1}},\\
x_{3}&\equiv x_{2}-Kf\equiv x_{2}\equiv u_{2}\mod{a_{2}},\\
x_{3}&\equiv x_{2}-Kf\equiv u_{3}-Ma_{3}\equiv u_{3}\mod{a_{3}}
\end{align*}

(iii) The system
\begin{align*}\tag*{$\bigstar\bigstar$}
x&\equiv u_{1}\mod{a_{1}},\\
x&\equiv u_{2}\mod{a_{2}},\\
x&\equiv u_{3}\mod{a_{3}}
\end{align*}
is soluble if and only if 
\[u_{i}\equiv u_{j}\mod\gcd(a_{i}, a_{j})\]
for all $1\leq i<j\leq 3$.
If $x$ is a solution of $\bigstar\bigstar$,
then $x'$ is a solution of $\bigstar\bigstar$
if and only if $x\equiv x'\mod{e}$ where $e$ is the
least common multiple of the $a_{i}$

The system
\begin{align*}\tag*{$\bigstar$}
x&\equiv u_{1}\mod{a_{1}},\\
x&\equiv u_{2}\mod{a_{2}},\\
x&\equiv u_{3}\mod{a_{3}},\\
\vdots&\\
x&\equiv u_{n}\mod{a_{n}}
\end{align*}
is soluble if and only if 
\[u_{i}\equiv u_{j}\mod\gcd(a_{i}, a_{j})\]
for all $1\leq i<j\leq n$.
If $x$ is a solution of $\bigstar$,
then $x'$ is a solution of $\bigstar$
if and only if $x\equiv x'\mod{e}$ where $e$ is the
least common multiple of the $a_{i}$.


\newpage\section*{Exercise~\ref{E;bad composite}}
If $n$ is not prime then we can find $r$
and $s$ such that $n=rs$ and $r,s\geq 2$ so
$r\not\equiv 0$ and $s\not\equiv 0$ but
\[r\times s\equiv 0\mod{n}.\]

\newpage\section*{Exercise~\ref{E;international book}}
(ii) Suppose ${\mathbf a}$ is a book number.
If $a_{j}=c_{j}$ for $j\neq k$ then, if ${\mathbf c}$
satisfies the check,
\begin{align*}
0&\equiv 10c_{1}+9c_{2}+ \dots+2c_{9}+c_{10}\\
&\equiv 10c_{1}+9c_{2}+ \dots+2c_{9}+c_{10}
- 10a_{1}+9a_{2}+ \dots+2a_{9}+a_{10}\\
&\equiv (11-k)(c_{k}-a_{k})
\end{align*}
modulo $11$ so, since $11$ is prime
\[c_{k}-a_{k}\equiv 0\]
and so $c_{k}=a_{k}$.

(iii) If $a_{j}=b_{j}=0$ for $1\leq j\leq 8$ and
$a_{9}=5$, $a_{10}=1$, $b_{9}=b_{10}=0$
then ${\mathbf a}$ and ${\mathbf b}$ are both ISBNs
but differ in exactly two places.

(iv) and (v) Suppose ${\mathbf a}$ is a book number.
If $a_{j}=c_{j}$ for $j\neq p,q$ 
$a_{p}=c_{q}$ and $a_{q}=c_{p}$
then, if ${\mathbf c}$
satisfies the check,
\begin{align*}
0&\equiv 10c_{1}+9c_{2}+ \dots+2c_{9}+c_{10}\\
&\equiv 10c_{1}+9c_{2}+ \dots+2c_{9}+c_{10}
- 10a_{1}+9a_{2}+ \dots+2a_{9}+a_{10}\\
&\equiv (11-q)(c_{q}-c_{p})+(11-p)(c_{p}-c_{q})\\
&\equiv (q-p)(c_{p}-c_{q})
\end{align*}
modulo $11$ so, since $11$ is prime
\[c_{p}-c_{q}\equiv 0\]
and so $c_{j}=a_{j}$ for all $j$. The check works for
any single transposition.
\newpage\section*{Exercise~\ref{E;very little}}
By Fermat's little theorem
\[10^{p-1}\equiv 1\mod{p}\]
so that
\[10^{(p-1)k}\equiv 1\mod{p}\]
and
$10^{(p-1)k}-1$
is divisible by $p$ for each $k\geq 1$.
If $p\neq 3$ this tells us that
$(10^{(p-1)k}-1)/9$ (which has the form
$111\dots 1$) is divisible by $p$
for each $k\geq 1$.

If $p=3$, then, since $10^{k}\equiv 1^{k}\equiv 1\mod{3}$,
we have   $111\dots 1$ divisible by $3$
whenever the number has $3k$ digits.
\newpage\section*{Exercise~\ref{E;squares modulo two}}
(i) If $r^{2}\equiv a^{2}$, then $r\equiv a \mod{2}$.

(ii) The equation $r^{2}\equiv u\mod{2}$
has exactly one solution for all $u$
\newpage\section*{Exercise~\ref{E;modulo quadratic formula}}
If
\[am^{2}+bm+c\equiv 0\mod{p}\]
then
\[m^{2}+a^{-1}b+a^{-1}c\equiv 0\]
so
\[(m+2^{-1}a^{-1}b)^{2}\equiv4^{-1}(ba^{-1})^{2}-a^{-1}c\]
and
\[\big(2a(m+2^{-1}a^{-1}b)\big)^{2}\equiv b^{2}-4ac\]
so $b^{2}-4ac$ is a square.

Conversely if $b^{2}-4ac=u^{2}$ then arguing as before
\[am^{2}+bm+c\equiv 0\mod{p}\]
if and only if
\[\big(2a(m+2^{-1}a^{-1}b)\big)^{2}\equiv u^{2}\]
Thus $\star$ holds if and only if
\[\big(2a(m+2^{-1}a^{-1}b)-u\big)
\big(2a(m+2^{-1}a^{-1}b)-u\big)\equiv 0\]
so if and only if
\[2a(m+2^{-1}a^{-1}b)-u\equiv 0
\ \text{or}\ 2a(m+2^{-1}a^{-1}b)-u\equiv 0\]
Thus the solutions of $\bigstar$
are given by
\[m\equiv 2^{-1}(-b\pm u)\mod{p}.\]

If we work modulo $2$ then $a=1$ and 
\[0^{2}+b0+c=c,\ 1^{2}+b1+c=1+b+c.\]
The equation has solution $0$ if $c\equiv 0$ and
the solution $1$ if $b+c\equiv 1$. 
\newpage\section*{Exercise~\ref{E;no square root -1}}
(i) If $u^{2}\equiv -1$
then by Lemma~\ref{L;find root}~(ii)
\[(m^{2})^{(p+1)/4}\equiv m\ \text{or}\ (um^{2})^{(p+1)/4}\equiv m\mod{p}\]
for all $m$ contradicting
Lemma~\ref{L;simple squares}~(iii).

(ii) If $u^{2}\equiv a$ and $v^{2}\equiv -a$ then
$(u^{-1}v)^{2}\equiv -1$ which is impossible by (i).

(iii) Thus at most one of $a$ and $-a$ has a square root for each 
$a\not\equiv 0$.
But by Lemma~\ref{L;simple squares}~(iii) exactly half of
the non-zero integers modulo $p$ have square roots
so exactly one of $a$ and $-a$ has a square root for each 
$a\not\equiv 0$.

(iv) Thus using (iii) and Lemma~\ref{L;find root},
$u^{2}\equiv a$ has solution if and only if
$u^{(p+1)/2}\equiv u$.
\newpage\section*{Exercise~\ref{E;modulo nineteen}}
We have
\[2^{10}\equiv 16\times 16\times 4\equiv (-3)^{2}\times 4\equiv -2\] 
so $2^{5}\equiv -6$ is a square root of $-2$.
Thus $u^{2}\equiv 2$ has no solution and
$u^{2}\equiv -2$ has solutions $u\equiv\pm 6$.

We have
\[3^{10}\equiv 27^{3}\times 3\equiv 8^{3}\times 3\equiv 7\times 8\times 3
\equiv -3\]
so $3^{5}\equiv 8\times 9\equiv -4$ is a square root of $-3$.
Thus $u^{2}\equiv 3$ has no solution and
$u^{2}\equiv -3$ has solutions $u\equiv\pm 4$.
\newpage\section*{Exercise~\ref{E;fast power}}
Observe that $a^{2^{r+1}}=(a^{2^{r}})^{2}$ so
by induction $a^{2^{n}}$ can be computed by squaring $n-1$ times.

We may compute $2$, $2^{2}$, \dots, $2^{n-1}$
with $n-2$ multiplications and then
\[2^{m}=\prod_{w_{j}=1, j\geq 1}2^{j}\]
with $n-1$ multiplications so we have used at most $2n$ multiplications.

Modulo $43$ we have 
\begin{gather*}
2^{2}\equiv 4,\ 2^{4}\equiv 16,\\ 
2^{8}\equiv 16^{2}\equiv 256\equiv -2,\\
2^{16}\equiv 4.
\end{gather*}
Thus 
\[2^{22}\equiv 2^{16}\times 2^{4}\times 2^{2}
\equiv 4\times 16\times 4\equiv 16^{2}\equiv -2\]
and so $u\equiv 2\mod{p}$ has no solutions 
by Exercise~\ref{E;no square root -1}~(iv).
\newpage\section*{Exercise~\ref{E;start four roots}}
(i) We draw up a table of squares modulo $21$
\[
\begin{matrix}
n\equiv&0&1&2&3&4&5&6&7&8&9&10\\
n^{2}\equiv&0&1&4&9&-5&4&-6&7&1&-3&-5
\end{matrix}
\]
Thus 

$n^{2}\equiv 0$ has one solution $n\equiv 0$,


$n^{2}\equiv 1$ has four solutions $n\equiv \pm 1,\pm 8$,

$n^{2}\equiv 4$ has four solutions $n\equiv \pm 2,\pm 5$,

$n^{2}\equiv -5$ has four solutions $n\equiv \pm 4,\pm 10$,

$n^{2}\equiv -3$ has two solutions $n\equiv \pm 9$,

$n^{2}\equiv -6$ has two solutions $n\equiv \pm 6$,

$n^{2}\equiv 7$ has two solutions $n\equiv \pm 7$.

$n^{2}\equiv 9$ has two solutions $n\equiv \pm 3$.

Otherwise $n^{2}\equiv u$ has no root.

\vspace{2\baselineskip}

(ii) We draw up a table of squares modulo $15$
\[
\begin{matrix}
n\equiv&0&1&2&3&4&5&6&7\\
n^{2}\equiv&0&1&4&-6&1&-5&6&4
\end{matrix}
\]
Thus 

$n^{2}\equiv 0$ has one solution $n\equiv 0$,


$n^{2}\equiv 1$ has four solutions $n\equiv \pm 1,\pm 4$,

$n^{2}\equiv 4$ has four solutions $n\equiv \pm 2 \pm 7$,

$n^{2}\equiv -5$ has two solutions $n\equiv \pm 5$,

$n^{2}\equiv 6$ has two solutions $n\equiv \pm 6$,

$n^{2}\equiv -6$ has two solutions $n\equiv \pm 3$.

Otherwise $n^{2}\equiv u$ has no root.
\newpage\section*{Exercise~\ref{E;Euclid pq}}
Either observe that if $a\not\equiv 0 \mod{p}$
and $a\not\equiv 0 \mod{q}$ then $a$ and $pq$
have highest common factor $1$ so by Euclid's
algorithm we can find $u$ and $v$
such that
\[au+pqv=1\]
and so $au\equiv 1\mod{pq}$.

Or use Euclid to show that there exist $r,s$ with
\[ar\equiv 1\mod{p}\ \text{and}\ as\equiv 1\mod{q}.\]
Now use the Chinese remainder theorem to give a $u$
with
\[u\equiv r\mod{p}\ \text{and}\ u\equiv s\mod{q}\]
so
\[au\equiv 1\mod{p}\ \text{and}\ au\equiv 1\mod{q}\]
so by the uniqueness part of the Chinese remainder theorem
\[au\equiv 1\mod{pq}.\]
\newpage\section*{Exercise~\ref{E;four roots}}
$u^{2}\equiv a\mod{pq}$ has
one solution corresponding to each pair $(r,s)$
of solutions
\begin{align*}
r^{2}&\equiv 0\mod{p}\\
s^{2}&\equiv 0\mod{q}
\end{align*}

(i) If $a\equiv 0\mod{pq}$ then the only pair is $(0,0)$
so exactly one solution.

(ii) If  $a\equiv 0\mod{q}$, $a\equiv u^{2}\mod p$
with $a\not\equiv 0\mod p$ then two pairs $(\pm u,0)$
so two solutions.

If  $a\equiv 0\mod{q}$, $a\not\equiv v^{2}\mod p$ for any $v$
then two pairs $(\pm u,0)$
so two solutions.

Similar with roles of $p$ and $q$ reversed.

If  $a\not\equiv 0\mod{p}$ and $a\not\equiv 0\mod{q}$
then either $a\equiv u^{2}\mod p$, $a\equiv v^{2}\mod q$
so four pairs $(\pm u,\pm v)$ and four solutions
or no solutions.

(iii) There are $(p-1)/2$ non-zero values of $u^{2}$ modulo $p$
and $(p-1)/2$ non-zero values of $v^{2}$ modulo $2$.

We thus have
\begin{gather*}
|\{u\in A\,:\,u^{2}\equiv 0\mod{p}\}|=\frac{p+1}{2}\\
|\{u\in A\,:\,u^{2}\equiv 0\mod{q}\}|=\frac{q+1}{2}\\
|\{u\in A\,:\,u^{2}\equiv 0\mod{pq}\}|=1\\
|\{u\in A\,:\,u^{2}\equiv a\mod{pq}
\ \text{has exactly two solutions}\}|=\frac{p+q-2}{2}
\end{gather*}

There are $(p-1)/\times (q-1)/2$ pairs $(r,s)$
with
\begin{align*}
r^{2}&\equiv a\mod{p}\\
s^{2}&\equiv a\mod{q}
\end{align*}
when $a\not\equiv 0\mod{p}$, $a\not\equiv 0\mod{q}$
so
\begin{align*}
|\{u\in A\,:\,u^{2}\equiv a\mod{pq}& 
\ \text{has exactly four solutions}\}|\\
= (p-1)(q-1)/4.
\end{align*}
Since there are $pq-1$ non-zero integers modulo $pq$
\begin{align*}
|\{u&\in A\,:\,u^{2}\equiv a\mod{pq} 
\ \text{has no solutions}\}|\\
&=pq-1-\frac{p+q-2}{2}-\frac{p-1}{2}\frac{q-1}{2}
=\frac{pq-1}{2}+\frac{(p-1)(q-1)}{4}
\end{align*}

\vspace{2\baselineskip}\section*{Exercise~\ref{E;four roots check}$^{*}$}
\newpage\section*{Exercise~\ref{E;four roots binary}}
(Corrected by Nigel White.)

If $q=2$ we know that $u^{2}=a$ always has exactly one root.
Thus
\begin{align*}
r^{2}&\equiv a\mod{2}\\
s^{2}&\equiv a\mod{q}
\end{align*}
has exactly the same number of solution pairs
as 
\[s^{2}\equiv a\mod{q}\]
Thus

(i) $u^{2}\equiv a\mod{2q}$ has exactly one solution
if $a\equiv 0\mod{q}$.

(ii) If $a\not\equiv 0\mod{q}$
then $u^{2}\equiv a\mod{2q}$ either has no
solutions or has exactly two solutions.

(iii) Let $A=\{a\,:\,1\leq a\leq 2q-1\}$
\begin{gather*}
|\{u\in A\,:\,u^{2}\equiv a\mod{2q}
\ \text{has exactly two solutions}\}|=(q-1),\\
|\{u\in A\,:\,u^{2}\equiv a\mod{pq} 
\ \text{has no solutions}\}|=(q-1)
\end{gather*}

\newpage\section*{Exercise~\ref{E;four roots only two}}
If $p$ and $q$ are odd primes and $a\equiv 0\mod{q}$,
$a\not\equiv 0\mod{p}$ then if $v$ is a solution
of $u^{2}\equiv a\mod{pq}$ it follows that
$-v$ is the other distinct solution.

To see this observe that
\begin{align*}
u^{2}\equiv a\mod{pq}
&\Leftrightarrow u^{2}\equiv a\mod p
\ \text{and}\ u^{2}\equiv 0\mod q\\
&\Leftrightarrow (u-v)(u+v)\equiv 0\mod p
\ \text{and}\ u\equiv 0\mod q\\
&\Leftrightarrow u\equiv \pm v\mod p
\ \text{and}\ u\equiv \pm v\mod q\\
&\Leftrightarrow u\equiv \pm v\mod pq
\end{align*}
\newpage\section*{Exercise~\ref{E;fast Chinese}}
(i) Since $10^{300}\approx 2^{1000}$,
we know from Lemma~\ref{L;Euclid stop}
that we need only a few thousand operations.

(ii) Our proof of Lemma~\ref{L;Chinese two}
showed that we need only apply Euclid's algorithm
and the method of Lemma\ref{L;Bezout 2}
twice (actually we need only do it once)
and do few more steps.

(iii) Since $10^{300}\approx 2^{1000}$,
Lemma~\ref{E;fast power} shows that we 
need only a few thousand operations.
\newpage\section*{Exercise~\ref{E;reluctant oracle}}
Roughly speaking, we will get a satisfactory
answer once in a thousand times but if we ask our question $200\,000$
times the probability that we will get
less than $64$ is very small (how small can be estimated
using Theorem~\ref{T;Poisson} or less well using Tchebychev) 
and, if we have $64$ satisfactory answers, then
Exercise~\ref{L;many try oracle} tells us 
that with high probability we can determine $p$ and $q$ rapidly.

\newpage\section*{Exercise~\ref{E;try Rabin}}
By considering cases we find $1333=31\times 43$.
We wish to solve
\begin{align*}
u^{2}&\equiv -3\mod{31}\\
u^{2}&\equiv 11\mod{43}
\end{align*}
Now
\[(-3)^{2}\equiv 9,\ (-3)^{4}\equiv 12,\ (-3)^{8}\equiv 11\mod{31}\]
so $u\equiv \pm 11\mod{31}$.

Also, 
\begin{gather*}
11^{2}\equiv -8,\ 11^{4}\equiv 21,\ 11^{8}\equiv 11\mod{43}\\
11^{11}\equiv 11\times 11^{2}\times 11^{8}
\equiv (-8)\times(-8)^{2}\times(-8)^{8}\equiv -21\mod{43}
\end{gather*}
so $u\equiv \pm 21\mod{43}$.

We now need to use the Chinese remainder theorem.
Applying Euclid's algorithm we have
\begin{gather*}
43=1\times 31+12\\
31=3\times 12-5\\
12=2\times 5+2\\
5=2\times 2+1
\end{gather*}
Thus
\begin{align*}
1&=5-2\times 2=5-2\times(12-2\times 5)=5\times 5-2\times 12\\
&-2\times 12+5\times(3\times 12-31)=13\times 12-5\times 31\\
&=13\times (43-31)-5\times 31=13\times 43-18\times 31
\end{align*}
and
\begin{align*}
559\equiv13\times 43\equiv 1\mod{31}\\
559&\equiv 0\mod{43}
\end{align*}
\begin{align*}
-558\equiv 0\mod{31}\\
-558&\equiv 1\mod{43}
\end{align*}

Thus the possible roots are
\begin{gather*}
559\times11+558\times 21\equiv 538 \text{and} -538\equiv 795\\
559\times11-558\times 21\equiv 1096 \text{and} -1096\equiv 237.
\end{gather*}
\newpage\section*{Exercise~\ref{E;SNDO}}
Write $u$ and $v$ for the
first and second encoded message. Observe that
$N$ and $N'$
are coprime. (If not, I really have been stupid, since Euclid's
algorithm will now give SNDO the common factor.)
SNDO can use the known $N$ and $N'$ together with
the Chinese remainder theorem to compute $w$
with $w\equiv m^{2}\pmod{NN'}$ and $0\leq w\leq NN'-1$.
But $ 0\leq m^{2}\leq NN'-1$ so $w=m^{2}$
and $m$ is the positive square root of $m$.

[SNDO uses Euclid's algorithm to find $a$, $b$ with
$aN+bN'=1$. If $w\equiv bN'u+aNv \pmod{NN'}$, then
$w\equiv u\pmod{N}$ and $w\equiv v\pmod{N'}$.]

SNDO is no further forward in reading other messages.
For we have proved that even if we encode messages
known to SNDO and give SNDO the results the code
is still unbroken. Effectively SNDO knows $m$ and
$m^{2}$ (modulo $N$) in one case and nothing else
(since $N'$ and $m^{2}$ (modulo $N'$) are irrelevant).
\newpage\section*{Exercise~\ref{E;Rabin variation}}
My problem is, knowing $b$ and $s$ with
\[r^{2}+br-s\equiv 0\mod{pq},\]
to find $r$. I can do this by using the Chinese remainder
theorem and solving
\begin{align*}
r^{2}+br-s\equiv 0\mod{p}\\
r^{2}+br-s\equiv 0\mod{q}.
\end{align*}
The solutions of these equations are
\begin{align*}
r\equiv 2^{-1}(b\pm u)\mod{p}\\
r\equiv 2^{-1}(b\pm v)\mod{q}.
\end{align*}
where $u$ and $v$ are solutions of
\begin{align*}
u^{2}\equiv b^{2}-4s\mod{p}\\
v^{2}\equiv b^{2}-4s\mod{q}.
\end{align*}
Thus I can decode the messages by finding square roots
and using the Chinese remainder theorem.

If I can decode messages, then I can solve
\[r^{2}+br-s\equiv 0\mod{pq}\]
and so find $w$
with
\[w^{2}\equiv b^{2}-4s\mod{pq}.\]
But given any $n$ I can set $s=4^{-1}\times (b^{2}-n)$
to obtain a square root of $n$ modulo $pq$.
The new system is exactly secure as the old.
\newpage\section*{Exercise~\ref{E;explain cycle}}
If $a_{j}=a_{k}$ with $r\geq k\geq j\geq 1$
then 
\[a_{1}=T^{-j+1}(a_{j})=T^{-j+1}a_{k}=a_{k-j+1}\]
and $r>k-j+1\geq 1$ which is impossible.

Observe that 
\[T^{k}a_{s+1}=T^{k+1}a_{s}
=\begin{cases}
a_{s+2}&\text{if $1\leq s\leq r-1$}\\
a_{1}&\text{if $s=r$}
\end{cases}
\]

If 
\[\{a_{1},\,a_{2},\dots,\,a_{r}\}\cap
\{b_{1},b_{2},\dots ,b_{k}\}\neq \emptyset\]
then we can find $p$ and $q$ such that $a_{p}=b_{q}$.
If we write down the cycle expressions starting
with $a_{p}$ and $b_{q}$ we will get the same cycles.
Thus, by the previous paragraph,
$r=k$,
\[\{a_{1},\,a_{2},\dots,\,a_{r}\}=
\{b_{1},b_{2},\dots ,b_{r}\},\]
and taking $u=q-p$, we have
and $b_{s}=T^{u}a_{s}$ for all $s$.
\newpage\section*{Exercise~\ref{E;cycle type}}
(a) We have
\[(1\ 2\ 4\ 8\ 16\ 15\ 13\ 9)(3\ 6\ 12\ 7\ 14 \ 11\ 5\ 10)(17)\]

(b) We have
\[(1\ 6\ 11\ 16\ 4\ 9\ 14\ 2\ 7\ 12\ 17\ 5\ 10\ 15\ 3%
\ 8\ 13)\]

(c) We have
\[(1\ 3\ 9\ 10\ 13\ 5\ 15\ 11\ 16\ 14\ 8\ 7\ 4\ 12\ 2\ 6)(17)\]

(d) We have $T_{4}(16)=1=T_{4}(1)$.

\vspace{2\baselineskip}

(e) $S_{1}(5)=S_{1}(15)$ so $S_{1}$ is not a shuffle.

(f) $S_{2}$ is a shuffle given by
\[(1\ 6\ 11)(2\ 7\ 8)(3\ 8\ 11)(4\ 9\ 12)(5\ 10\ 15)\]

(g) $S_{3}$ is a shuffle given by
\[(1)(2\ 8)(3\ 12)(4)(5)(6)(7\ 13)(9)(10)(11)(14)\]

\newpage\section*{Exercise~\ref{E;length from cycle}}
(i) Observe that
\[T^{k}a_{j}=a_{j}\ \text{for all $j$}\Leftrightarrow T^{k}a_{1}=a_{1}.\]
Suppose that $T^{k}a_{1}=a_{1}$. Choose $m$ such that
\[r>k-mr\geq 0.\]
Then $T^{k-mr}a_{1}=T^{k}(T^{r})^{-m}a_{1}=a_{1}$ and
so, since $r$ is minimal, $k-mr=0$. Thus $k=mr$.
The converse is immediate.

(ii) Using (i),
\begin{align*}
T^{k}{x}=x\ \text{for all $x$}
&\Leftrightarrow 
\text{$k$ is divisible by $d_{k}$ for all $1\leq k\leq m$}\\
&\Leftrightarrow 
\text{$k$ is divisible by $\lcm(d_{1},d_{2},\dots,d_{m})$}\\
\end{align*}

(iii) $T_{1}$ has period $16$, $T_{2}$ has period $17$,
$T_{3}$ has period $16$, $S_{2}$ has period $3$
and $S_{3}$ has period $2$.

\newpage\section*{Exercise~\ref{E;start long period}}
(i) Without loss of generality $u\geq v\geq 2$
and
\[uv\geq 2u\geq u+v.\]

(ii) By Exercise~\ref{E;lowest common}
\[uv=\gcd(u,v)\lcm(u,v)=\lcm(u,v).\]

(iii) Suppose that $d_{1}$, $d_{2}$, \dots, $d_{k}$
are strictly positive integers and $d_{1}$ and $d_{2}$
have highest common factor $c\geq 2$. Then setting
$\tilde{d}_{1}=d_{1}/c$, $\tilde{d}_{j}=d_{j}$
for $k\geq j\geq 2$ we have

\[\lcm(\tilde{d}_{1},\tilde{d}_{2},\dots,\tilde{d}_{k})
=\lcm(d_{1},d_{2},\dots,d_{k})\]
and 
\[\tilde{d}_{1}+\tilde{d}_{2}+\dots+\tilde{d}_{k}
\leq d_{1}+d_{2}+\dots+d_{k}.\]

Thus there is no loss of generality in supposing
$d_{1}$, $d_{2}$, \dots $d_{k}$ coprime.
Suppose $d_{k}$ is not a power of a prime.
Then we can write $d_{k}=\tilde{d}_{k}\times\tilde{d}_{k+1}$
with $\tilde{d}_{k}$ and $\tilde{d}_{k+1}$ coprime.
Setting $\tilde{d}_{j}=d_{j}$ for $1\leq j\leq k-1$ we have
(by part~(i))
\[\tilde{d}_{1}+\tilde{d}_{2}+\dots+\tilde{d}_{k}+\tilde{d}_{k+1}
\leq d_{1}+d_{2}+\dots+d_{k}\]
and
\begin{align*}
\lcm(d_{1},d_{2},\dots,d_{k})&=d_{1}d_{2}\dots d_{k}\\
&=\tilde{d}_{1}\tilde{d}_{2}\dots \tilde{d}_{k}\tilde{d}_{k+1}\\
&=\lcm(\tilde{d}_{1},\tilde{d}_{2},\dots,\tilde{d}_{k},\tilde{d}_{k+1})
\end{align*}

Thus $\lcm(d_{1},d_{2},\dots,d_{k})$ 
is maximised subject to $d_{j}\geq 1$
and $d_{1}+d_{2}+\dots+d_{k}\leq n$, $m\geq 1$
by taking the $d_{j}$ powers of distinct primes.

(iv) By Lemma~\ref{L;longest period} and part~(iii)
the longest period of a shuffle
with $n$ cards is given by the maximum
value of
\[p_{1}^{m(1)}p^{m(2)}\dots p_{l}^{m(l)}\]
where $l$ is a strictly positive integer,
$p_{1}$, $p_{2}$, \dots, $p_{l}$ are distinct primes
and $m_{1}$, $m_{2}$, \dots, $m_{l}$ are strictly
positive integers with
\[p_{1}^{m(1)}+p^{m(2)}+\dots+p_{l}^{m(l)}\leq n.\]

\newpage\section*{Exercise~\ref{E;short long periods}}
I do not know any better method than exhaustive search
using Exercise\ref{E;start long period}~(iv).

$n=1$. Longest period $1$.

$n=2$. Longest period $2$.

$n=3$. Longest period $3$.

$n=4$. Since $2^{2}>3$, longest period $4$.

$n=5$. Since $2\times 3>5$, longest period $6$.

$n=6$.  Since $2\times 3>5$, longest period $6$.

$n=7$.  Since  $3\times 2^{2}>7$, longest period $12$.

$n=8$.  Longest period $3\times 5=15$.

$n=9$.  Since $2^{2}\times 5>2^{4}>3\times 5$, longest period $20$.

$n=10$. Longest period $2\times 3\times 5=30$.

$n=11$. Longest period $2\times 3\times 5=30$.

$n=12$. Longest period $2^{2}\times 3\times 5=60$.

\newpage\section*{Exercise~\ref{E;start Jonas}}
(i) We have

$n=1$, shuffle is $(12)$, $2$ shuffles to return.

$n=2$, shuffle is $(1243)$, $4$ shuffles to return.

$n=3$ shuffle is $(124)(365)$, $3$ shuffles to return.

$n=4$, shuffle is $(124875)(36)$, $6$ shuffles to return.

$n=5$, shuffle is $(12485[10]9736)$, $10$ shuffles to return.

$n=6$, shuffle is $(124836[12][11]95[10]7)$, $12$ shuffles to return.

$n=7$, shuffle is $(1248)(36[12]9)(5[10])(7[14][13][11])$,
$4$ shuffles to return.

When $n=4$, cards $3$ and $6$ just swap places each time
(so return to original position after any even number
of shuffles). When $n=7$, cards $5$ and $10$ just swap places each time
(so return to original position after any even number
of shuffles).

(ii) Mr Jonas prefers the out-shuffle 
because the first and last cards do not move. (Very useful indeed.)

We have

$n=1$, shuffle is $(1)92)$, stays in place.

$n=2$, shuffle is $(1)(23)(4)$, $2$ shuffles to return.

$n=3$ shuffle is $(1)(2354)(6)$, $4$ shuffles to return.

$n=4$, shuffle is $(1)(235)(476)(8)$, $3$ shuffles to return.

$n=5$, shuffle is $(1)(235986)(47)([10])$, $6$ shuffles to return.

$n=6$, shuffle is $(1)(23596[11][10]847)([12]$, $10$ shuffles to return.

$n=7$, shuffle is $(1)(235947[13][12][10]6[11]8)(14)$,
$12$ shuffles to return.


\newpage\section*{Exercise~\ref{E;Euclid general n}}
This is a simple generalisation of Lemma~\ref{L;prime field}~(i).
Since $\gcd(a,n)=1$ Euclid's algorithm tells us that we can find
$u$ and $v$ such that
\[au+nv=1\]
and so
\[au\equiv 1\mod{n}.\]

\newpage\section*{Exercise~\ref{E;totient}}
(i) Observe that
\begin{align*}
A_{j(1)}&\cap A_{j(2)}\cap \dots A_{j(u)}\\
&=\{rnp_{j(1)}^{-k_{j(1)}}p_{j(2)}^{-k_{j(2)}}\dots p_{j(s)}^{-k_{j(s)}}
\,:\,1\leq r\leq 
p_{j(1)}^{k_{j(1)}}p_{j(2)}^{k_{j(2)}}\dots p_{j(s)}^{k_{j(s)}}\}
\end{align*}
and so
\[|A_{j(1)}\cap A_{j(2)}\cap \dots A_{j(u)}|
=\frac{n}
{p_{j(1)}^{k_{j(1)}}p_{j(2)}^{k_{j(2)}}\dots p_{j(s)}^{k_{j(s)}}}.\]

(ii) By the inclusion-exclusion formula
\begin{align*}
\left|\bigcup_{j=1}^{u}A_{j}\right|
&=\sum_{u=1}^{s}(-1)^{s+1}\sum_{1\leq j(1)<j(2)<\dots<j(s)\leq u}
|A_{j(1)}\cap A_{j(2)}\cap \dots A_{j(u)}|\\
&=\sum_{u=1}^{s}(-1)^{s+1}\sum_{1\leq j(1)<j(2)<\dots<j(s)\leq u}
\frac{n}
{p_{j(1)}^{k_{j(1)}}p_{j(2)}^{k_{j(2)}}\dots p_{j(s)}^{k_{j(s)}}}
\end{align*}
so
\begin{align*}
\phi(n)
&=\left|X\setminus \bigcup_{j=1}^{u}A_{j}\right|=
|X|-\left|\bigcup_{j=1}^{u}A_{j}\right|\\
&=n\left(1-
\sum_{u=1}^{s}(-1)^{s}\sum_{1\leq j(1)<j(2)<\dots<j(s)\leq u}
\frac{1}
{p_{j(1)}^{k_{j(1)}}p_{j(2)}^{k_{j(2)}}\dots p_{j(s)}^{k_{j(s)}}}
\right)\\
&=n\left(1-\frac{1}{p_{1}}\right)
\left(1-\frac{1}{p_{2}}\right)
\left(1-\frac{1}{p_{u}}\right)\\
&=p_{1}^{k_{1}}\left(1-\frac{1}{p_{1}}\right)
p_{2}^{k_{2}}\left(1-\frac{1}{p_{2}}\right)
\dots p_{u}^{k_{u}}\left(1-\frac{1}{p_{u}}\right).
\end{align*}

(iii) We have $\phi(p)=p(1-p^{-1})=p-1$ when $p$ is a prime so
\begin{gather*}
\phi(2)=1,
\ \phi(3)=2,
\ \phi(4)=2^{2}\times\frac{1}{2}=2,
\ \phi(5)=4,\\
\phi(6)=2\times\frac{1}{2}\times 3\times\frac{2}{3}=2,
\ \phi(7)=6,
\ \phi(8)=8\times\frac{1}{2}=4,\\
\phi(9)=9\times\frac{2}{3}=6,
\ \phi(10)=2\times\frac{1}{2}\times 5\times\frac{4}{5}=4,\\
\phi(11)=10,
 \ \phi(12)=2^{2}\times\frac{1}{2}\times 3\times\frac{2}{3}=4.
\end{gather*}
\newpage\section*{Exercise~\ref{E;Euler to Fermat}}
If $p$ is prime, then $\phi(p)=p(1-p^{-1})=p-1$
and
\[a^{p-1}\equiv a^{\phi(p)}\equiv 1\mod{p}\]
whenever $\gcd(a,p)=1$ ie whenever
$a\not\equiv 0\mod{p}$.
\newpage\section*{Exercise~\ref{E;Wilson}}
(i) Observe that 
\[u^{2}\equiv 1\Leftrightarrow (u-1)(u+1)\equiv 0
\Leftrightarrow u\equiv\pm 1\mod{p}.\]
Thus if $rs\equiv 1$ and $r\not\equiv \pm1$ we have $r\not\equiv s$.
By choosing exactly one member of each pair $r,\,s$
with $rs\equiv 1$ and $r,s\not\equiv \pm1$ we obtain a $B$ with the 
required properties.  
Now
\begin{align*}
\prod_{r\in A}r&=1\times -1\times\prod_{u\in B}u\prod_{u\notin B}u
&\equiv 1\times -1\times 
\prod_{u\in B}u\prod_{u\in B}u^{-1}\\
&\equiv 1\times -1\times 
\prod_{u\in B}uu^{-1}\equiv -1
\end{align*}
modulo $p$.

(ii) If $n$ is not a prime and $n>4$
we know that either $n=rs$ with $n-1\geq r>s>1$
so $rs$ divides $(n-1)!$ and
\[(n-1)!\equiv 0\mod{n}\]
or $n=r^{2}$ and $n-1\geq 2r> r$
so $(2r)\times r$ and thus $r^{2}$ divides $(n-1)!$ and
\[(n-1)!\equiv 0\mod{n}.\]
 
Since $(2-1)!\equiv 1!\equiv 1\mod{2}$ and 
\[3!\equiv 6\equiv 2\not\equiv -1\mod{4}\]
the required result now follows fro~(i).

(iii) We have $p=4n+1$
so
\begin{align*}
-1\equiv(p-1)!&\equiv\prod_{r=1}^{2n}r\prod_{r=1}^{2n}(-r)
&(-1)^{2n}(2n)!\equiv((p-1)/2\big)!^{2}\mod{p}
\end{align*}

If $p\equiv -1\mod{4}$ so $p=4n-1$ the same argument gives
\begin{align*}
-1\equiv(p-1)!&\equiv\prod_{r=1}^{2n-1}r\prod_{r=1}^{2n-1}(-r)
&(-1)^{2n-1}(2n)!\equiv-((p-1)/2\big)!^{2}
\end{align*}
so
\[\bigg(((p-1)/2\big)!\bigg)^{2}\equiv1\mod{p}\]

(iv) We know that $u^{2}\equiv 1\mod{pq}$ has four distinct roots
$a$, $-a$, $b$, $-b$.
Call the set of four roots $X$.
Thus if $rs\equiv 1$ and $r\notin X$ we have $r\not\equiv s$.
By choosing exactly one member of each pair $r,\,s$
with $rs\equiv 1$ and $r,s\not\equiv \pm1$, we obtain a $B$
such that $B\cap X=\emptyset$ and if $u\notin X$
$u^{-1}\in B$ if and only if
$u\notin B$.

Thus
\begin{align*}
\prod_{r\in A}r&=\prod_{u\in X}u\times\prod_{u\in B}u\prod_{u\notin B}u
&\equiv a^{2}b^{2}\times 
\prod_{u\in B}u\prod_{u\in B}u^{-1}\\
&\equiv -1\times -1\times 
\prod_{u\in B}uu^{-1}\equiv 1
\end{align*}
modulo $pq$.
\newpage\section*{Exercise~\ref{E;end Jonas}}
(i) Observe that, if $1\leq r\leq n$, then
\[2r\equiv 2r\mod 2n+1\]
and, if $n+1\leq r\leq 2n$, then
\[2(r-n)-1\equiv 2r-(2n+1)\equiv 2r\mod 2n+1.\]

If we start in position $j$, then, after $m$ shuffles,
we are at $2^{m}j$ modulo $2n+1$. By the Euler--Fermat theorem,
\[2^{\phi(2n+1)}j\equiv 1\times j\equiv j\mod 2n+1,\]
so the pack returns to its original order after $\phi(2n+1)$
shuffles.

Since $53$ is prime, $\phi(53)=52$ and a standard pack
returns to its original order after $52$ in-shuffles.

(ii) Observe that, if $2\leq r\leq n$, then
\[2(r-1)\equiv 2(r-1)\mod 2n-1\]
and, if $n+1\leq r\leq 2n-1$, then
\[2((r-1)-n)-1\equiv 2(r-1)-(2n-1)\equiv 2r-1\mod 2n-1.\]

We ignore the fixed first and last card and
use the renumbering.
If we start in position $j$, then, after $m$ shuffles,
we are at $2^{m}j$ modulo $2n-1$. By the Euler--Fermat theorem,
\[2^{\phi(2n-1)}j\equiv 1\times j\equiv j\mod 2n-1,\]
so the pack returns to its original order after $\phi(2n-1)$
out-shuffles.

Since $51=3\times 17$, we have
$\phi(51)=\phi(3)\phi(17)=2\times 16$ and a standard pack
returns to its original order after $16$ out-shuffles.

(iii) Working modulo $51$, we have $2^{2}\equiv 4$, $2^{4}\equiv 16$
and
\[2^{16}\equiv 16^{4}\equiv 64^{2}\times 16\equiv 13^{2}\times 16
\equiv 16^{2}\equiv 64\times 4\equiv 13\times 4\equiv 1.\]
Thus
\[2^{8}j\equiv 1\times j\equiv j\mod 51,\]
and a standard pack
returns to its original order after $8$ out-shuffles.

The statement that a pack returns after $m$ shuffles
does not exclude the statement that it returns after $k$
shuffles. [This is the minimum answer. A more expansive discussion
would remark that if a pack returns after $m$ shuffles
and after after $k$ shuffles, then it will return after
the highest common factor of $m$ and $k$ shuffles.]

(iv) There is really no problem in just calculating
powers of $2$ up to the $26$th. Since the minimum
return period must divide any return period and since
$2$ must return to $2$ after a return period this does it.

Shorter ways are possible, since the only possible periods
are $1$ (obviously not a period), $2$, $4$, $13$ and $26$.
But $2^{2}\equiv 4$ modulo $53$, $2^{4}\equiv 16$
and
\[2^{13}\equiv 2\times 64^{2}\equiv 2\times 11^{2}\equiv 30\]
whilst
\[2^{26}\equiv 900\equiv -1.\]
No doubt even quicker ways are possible but only at the expense of
thought.
\newpage\section*{Exercise~\ref{E;shuffle reals}}
No changes are required if the reals are distinct.

If the reals are not distinct then we can (for example)
instruct our assistant not to swap cards if the numbers they
bear are equal. We will find one of the largest cards.
(So, if there is only one largest card, we will find it.)

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;guess full sort}$^{*}$}
\newpage\section*{Exercise~\ref{E;largest and smallest}}
The pack contains $n$ pairs. Place the larger of each pair
in pile $A$ and the  smaller of each pair
in pile $B$. The requires $n$ comparisons.
Pile $A$ must contain the largest
card in the pack so find the largest card in pile $A$
using $n-1$ operations. Pile $B$ must contain the smallest
card in the pack so find the smallest card in pile $A$
using $n-1$ operations. We have used $3n-2$ operations.
\section*{Exercise~\ref{E;guess records}$^{*}$}
\newpage\section*{Exercise~\ref{E;average record}}
Let $k\in A$ if and only if the $k$th card is a record.
\[X_{1}+X_{2}+\dots+X_{n}=\sum_{j\in A}1=|A|\]
where $|A|$ is the total number of records.

\[{\mathbb E}X_{j}=1\times\Pr(X_{j}=1)+0\times\Pr(X_{j}=0)=\frac{1}{j}\]
so

\[{\mathbb E}Y={\mathbb E}X_{1}+{\mathbb E}X_{2}+\dots+{\mathbb E}X_{n}
=1+\frac{1}{2}+\frac{1}{3}+\dots+\frac{1}{n}.\]
\newpage\section*{Exercise~\ref{E;estimate integral}}
(i) If $n\leq x\leq n+1$ then since $f$ is increasing
$f(n)\leq f(x)$ and $f(x)\leq f(n+1)$.

Since
\[f(n)\leq f(x)\leq f(n+1)\ \text{for $n\leq x\leq n+1$}\]
we have
\[\int_{n}^{n+1}f(n)\,dx\leq \int_{n}^{n+1}f(x)\,dx
\leq [\int_{n}^{n+1}f(n+1)\,dx\]
so
\[f(n)\leq\int_{n}^{n+1}f(x)\,dx\leq f(n+1).\]
Thus
\[\sum_{n=1}^{N-1}f(n)\leq \sum_{n=1}^{N-1}\int_{n}^{n+1}f(x)\,dx
\leq \sum_{n=1}^{N-1}f(n+1).\]
ie
\[\sum_{n=1}^{N-1}f(n)\leq \int_{1}^{N}f(x)\,dx
\leq \sum_{n=2}^{N}f(n).\]

If $f(x)>0$ for all $x$ then $f(1)>0$
so
\[\sum_{n=1}^{N}f(n)\geq \sum_{n=2}^{N}f(n)\geq \int_{1}^{N}f(x)\,dx.\]
Replacing $N$ by $N+1$ in the inequalities of the previous paragraph
\[\sum_{n=1}^{N}f(n)\leq \sum_{n=1}^{N+1}\int_{1}^{N}f(x)\,dx\]

(iii) The area under the big rectangles includes the area
under the curve so
\[\sum_{n=1}^{N-1}\int_{n}^{n+1}f(x)\,dx
\leq \sum_{n=1}^{N-1}f(n+1).\] 

The area under the small rectangles is included includes the area
under the curve so
\[\sum_{n=1}^{N-1}f(n)\leq \sum_{n=1}^{N}\int_{1}^{N}f(x)\,dx.\]

(iii) Suppose that $g$ is a well behaved decreasing function.
Then
\[g(n)\geq g(x)\geq g(n+1)\ \text{for $n\leq x\leq n+1$}\]
so
\[\int_{n}^{n+1}g(n)\,dx\geq \int_{n}^{n+1}g(x)\,dx
\leq \int_{n}^{n+1}g(n+1)\,dx\]
and summing
\[\sum_{n=1}^{N-1}g(n)\geq \sum_{n=1}^{N-1}\int_{n}^{n+1}g(x)\,dx
\geq \sum_{n=1}^{N-1}g(n+1),\]
ie
\[\sum_{n=1}^{N-1}g(n)\geq \int_{1}^{N}g(x)\,dx
\geq \sum_{n=2}^{N}g(n).\]

(Or we could simply set $f=-g$ and apply~(i).)

(iv) We have $g(x)=1/x$ decreasing so
\begin{align*}
\sum_{n=1}^{N}\frac{1}{n}
&=\sum_{n=1}^{N}g(n)\\
&\geq\int_{1}^{N-1}g(x)\,dx\\
&=\int_{1}^{N-1}\frac{1}{x}\,dx\\
&\geq \int_{1}^{N}\frac{1}{x}\,dx=\log N
\end{align*}
and
\begin{align*}
\sum_{n=2}^{N}\frac{1}{n}
&=\sum_{n=2}^{N}g(n)\\
&\leq\int_{1}^{N-1}g(x)\,dx\\
&\leq\int_{1}^{N}g(x)\,dx=\log N
\end{align*}
so that
\[\sum_{n=1}^{N}\frac{1}{n}\leq 1+\log N.\]
\newpage\section*{Exercise~\ref{E;expected number of records}}
Set $X_{k}=1$, if the $k$th card is a record, and
$X_{k}=0$, if not. Then
\[Y=X_{n}+X_{2}+\dots+X_{[bn]}\]
is the total number of records. It follows that
\[{\mathbb E}Y={\mathbb E}X_{n}+{\mathbb E}X_{2}+\dots+{\mathbb E}X_{[bn]}
=\frac{1}{n}+\frac{1}{n+1}+\dots+\frac{1}{[bn]}.\]

Now
\begin{align*}
\frac{1}{n}+\frac{1}{n+1}+\dots+\frac{1}{[bn]}
&\leq \sum_{j=n-1}^{[bn]-1}\int_{j}^{j+1}\frac{1}{x}\,dx\\
&=\int_{n}^{[bn]}\frac{1}{x}\,dx=\log([bn]/n)
\end{align*}
and
\begin{align*}
\frac{1}{n}+\frac{1}{n+1}+\dots+\frac{1}{[bn]}
&\geq \sum_{j=n}^{[bn]}\int_{j}^{j+1}\frac{1}{x}\,dx\\
&\geq \sum_{j=n}^{[bn]-1}\int_{j}^{j+1}\frac{1}{x}\,dx\\
&=\int_{n-1}^{[bn]}\frac{1}{x}\,dx=\log([bn]/(n-1))
\end{align*}
Since $[bn]/n\rightarrow b$ and $[bn]/(n-1)=([bn]/n)\big(n/(n-1)\big)
\rightarrow 0$ as $n\rightarrow\infty$
the expected number of records between the $n$th
and the last card is approximately $\log b$.
\newpage\section*{Exercise~\ref{E;four card record}}
(i) If $m=3$ we win if either the third card
is $4$ which happens with probability $1/4$
or the fourth card
is $4$ and the third is not $3$
(since the third card should not be the largest of
the three first cards) which happens with probability
$(1/4)\times(2/3)=1/6$. The total probability of winning
is $5/12$.

(ii) If $m=1$ we win if the  first card is $4$ ie with
probability $1/4$. If $m=4$ we win if the  first card is $4$ ie with
probability $1/4$.

If $m=2$ we look at the table marking our choice with boldface.
\begin{table}
\begin{center}
\begin{footnotesize}
\tabcolsep=3pt
\begin{tabular}{cccccccccccccccccccccccc}
1&1&1&1&1&1&2&2&3&4&3&4&2&2&3&4&3&4&2&2&3&4&3&4\\
{\bf 2}&{\bf 2}&{\bf 3}&{\bf 4}&{\bf 3}&{\bf 4}
&1&1&1&1&1&1
&{\bf 3}&{\bf 4}&2&2&{\bf 4}&3
&{\bf 3}&{\bf 4}&2&2&{\bf 4}&3\\
3&4&2&2&4&3&
{\bf 3}&{\bf 4}&2&2&{\bf 4}&3&
1&1&1&1&1&1&
4&3&{\bf 4}&3&2&2\\
4&3&4&3&2&2&
4&3&{\bf 4}&{\bf 3}&2&{\bf 2}&
4&3&{\bf 4}&{\bf 3}&2&{\bf 2}&
1&1&1&{\bf 1}&1&{\bf 1}
\end{tabular}
\tabcolsep=6pt
\end{footnotesize}
\end{center}
\end{table}
The probability of winning is $11/24$.

(iii) With three cards if $m=1$ or $3$ we must pick
the card we are on so we have probability $1/3$ of winning.
With $m=2$ we win if the second card is $3$
or if our second card is $1$ and the last card $3$
so we have probability $1/3+1/6=1/2$ of winning.
\newpage\section*{Exercise~\ref{E;five card record}}
If $m=1$ the probability of success
is $1/5$.

If $m=2$ the  probability of success is
\[\frac{4}{5}\times\frac{1}{4}+
\frac{1}{2}\times\frac{4}{5}\times\frac{3}{4}\times\frac{1}{3}
+\frac{1}{3}\times\frac{4}{5}\times\frac{3}{4}\times\frac{2}{3}
\times\frac{1}{2}
+\frac{1}{4}\times\frac{4}{5}\times\frac{3}{4}\times\frac{2}{3}
\times\frac{1}{2}=\frac{5}{12}.\]

If $m=3$ the probability of success is
\[\frac{3}{5}\times\frac{2}{4}+
\frac{1}{2}\times\frac{3}{5}\times\frac{2}{4}\times\frac{2}{3}
+\frac{1}{3}\times\frac{3}{5}\times\frac{2}{4}\times\frac{1}{3}
=\frac{13}{30}.\]

If $m\geq 4$ the probability of the largest number being 
among the $m$th or larger is $2/5<5/12$.
Since $13/30>5/12$ we should take $m=3$.
\newpage\section*{Exercise~\ref{E;another restaurant}}
The probability of dealing $u$ given cards before the
$tn$th card and $v$ after is
\begin{align*}
&\frac{[tn]}{n}\times\frac{[tn]-1}{n-1}\times\dots
\frac{[tn]-u+1}{n-u+1}\\
&\qquad\qquad\times \frac{n-[tn]}{n-u}\times\frac{n-[tn]-1}{n-u-1}\times\dots
\frac{[tn]-u-v+1}{n-u-v+1}\\
&=(n^{-1}[tn])\times\frac{n^{-1}[tn]-n^{-1}}{1-n^{-1}}\times\dots
\frac{n^{-1}[tn]-n^{-1}(u-1)}{1-n^{-1}(u-1)}\\
&\qquad\qquad\times \frac{1-n^{-1}[tn]}{1-n^{-1}u}\times
\frac{1-n^{-1}[tn]-n^{-1}}{1-n^{-1}(u-1)}\times\dots
\frac{n^{1}[tn]-n^{-1}(v-1)}{1-n^{-1}(u+v-1)}\\
&\rightarrow t^{u}(1-t)^{v}.
\end{align*}
as $n\rightarrow\infty$.
Thus
\[\Pr(\text{largest $k$ cards after $[tn]$, $k+1$st card
before})\approx t(1-t)^{k}\]
and so
\begin{align*}
\Pr(&\text{largest $k$ cards after $[tn]$, $k+1$st card before}\\
&\qquad\text{and largest card before other $k-1$ largest})\\
&=\frac{t(1-t)^{k}}{k}
\end{align*}
so as before
\[\Pr(\text{stop at largest card})\approx
t(1-t)+\frac{t(1-t)^{2}}{2}+\frac{t(1-t)^{3}}{3}+\dots.\]


\newpage\section*{Exercise~\ref{E;restaurant calculus}}
If $f(t)=-t\log t$, then
\[f'(t)=-\log t-1\]
so $f'(t)>0$ and $f(t)$ is increasing for $t<e^{-1}$,
while $f'(t)<0$ and $f(t)$ is decreasing for $t>e^{-1}$.
Thus $f$ attains its maximum at $e^{-1}$.
\newpage\section*{Exercise~\ref{E;second best}}
(i) If the largest card is dealt before $m$
then no new card will be a record and we will stop
at the last card and it will not be a record.
If we stop at the last card and it is not a record
no card on or after the $m$th can be a record
so none of them can be the largest in the pack.
Thus the largest in the pack is in the first $m-1$.

If $n$ is large
\begin{align*}
\Pr(\text{stop at last card and it is not largest})
&=\Pr(\text{largest in first $m-1$})\\
&=\frac{m-1}{n}\approx e^{-1}
\end{align*}
\begin{align*}
\Pr(\text{stop at last card and it is largest})
&\leq \Pr(\text{last card is largest})\\
&=\frac{1}{n}\approx 0
\end{align*}
Thus
\[\Pr(\text{stop at last card}\approx e^{-1}\]

Also
\begin{align*}
\Pr(\text{choose}&\ \text{largest card or stop at last})
=\Pr(\text{choose largest})\\
&\qquad+\Pr(\text{stop at last card and it is not largest})\\
&\approx 2e^{-1}
\end{align*}
Thus the probability that we neither choose the last card 
nor the largest is approximately $1-2e^{-1}$.

(ii) If $n$ is large
 \begin{align*}
\Pr(\text{stop}&\ \text{at last card and it is not largest})\\
&=\Pr(\text{largest in first $m-1$)}\\
&=\frac{tn-1}{n}
\end{align*}
\begin{align*}
\Pr(\text{stop at last card and it is largest})
&\leq \Pr(\text{last card is largest})\\
&=\frac{1}{n}
\end{align*}
so
\[\Pr(\text{stop at last card})\leq t\]
Also 
\begin{align*}
\Pr(\text{none}&\ \text{of the $k$ largest 
cards is turned over before the $m$th
card})\\
&=\frac{n-m}{n}\times\frac{n-m-1}{n-1}\times\dots\times
\frac{n-m-k+1}{n-k+1}\\
&\leq (1-t)^{k}
\end{align*}
But, if we do not stop at one of the highest $k$ cards, 
then either none of the $k$ largest 
cards is turned over before the $m$th
or at least one of the $k$ largest 
cards is turned over before the $m$th
in which case we must have stopped at the last card.
\begin{align*}
&\Pr(\text{stop at one of the $k$ th largest cards})\\
&\geq 1-\Pr(\text{non of the $k$ largest 
cards is turned over before the $m$th})\\
&\quad-\Pr(\text{stop at last card})\\
&\geq 1-t-(1-t)^{k}
\end{align*}

If we choose $\epsilon/2>t>\epsilon/4$
and $k$ such that $(1-\epsilon/4)^{k}<\epsilon/2$
\[\Pr(\text{stop at one of the $k$ largest cards})
\geq 1-\epsilon\]
however large $n$ is.
\newpage\section*{Exercise~\ref{E;yes no}}
(i) Is the first digit $0$? Is the second digit $0$?
Is the third digit $0$?

Label the objects by sequences of $n$ zeros and ones
(there are $2^{n}$ such sequences). Now ask 
`Is the $j$th digit $0$?' for $1\leq j\leq n$.

(ii) If $N$ is the number of head words
then we are told that $N\leq 2^{20}$
so the result follows from~(i).

We could label the $k$th word by the sequence
\[{\mathbf x}_{k}=x_{1,k}x_{2,k}\dots x_{20,k}\]
with 
\[k=\sum_{j=1}^{20}2^{j-1}x_{j,k}.\]

\newpage\section*{Exercise~\ref{E;weak Stirling}}
(i) We have for all values of $n$ 
\begin{align*}
n!&=n\times (n-1)\times (n-2)\times\dots\times2\times 1\\
&\leq n\times n\times n\times\dots\times n\times n=n^{n}
\end{align*}
and
\begin{align*}
n!&=\prod_{r=1}^{n}r\geq \prod_{r=n/2}^{n}r\\
&\geq \prod_{r=n/2}^{n}\frac{n}{2}=\left(\frac{n}{2}\right)^{n/2}.
\end{align*}
Thus
\begin{align*}
n\log n&=\log n^{n}\geq \log n!\geq \log\left(\frac{n}{2}\right)^{n/2}\\
&=\frac{n}{2}(\log n-\log 2)\geq \frac{n}{4}\log n
\end{align*}
if $n\geq 4$.

(iii) There are lots of different variations. For example,
if $n$ is odd and $n\geq 9$,
\begin{align*}
n!&=\prod_{r=1}^{n}r\geq \prod_{r=(n-1)/2}^{n}r\\
&\geq \prod_{r=(n-1)/2}^{n}\frac{n}{3}=\left(\frac{n+1}{2}\right)^{n/3}\\
&\geq \left(\frac{n}{2}\right)^{n/3}.
\end{align*}
Thus
\begin{align*}
n\log n&=\log n^{n}\geq \log n!\geq \log\left(\frac{n}{2}\right)^{n/3}\\
&=\frac{n}{2}(\log n-\log 3)\geq \frac{n}{4}\log n.
\end{align*}
\newpage\section*{Exercise~\ref{E;middle card}}
\begin{gather*}
a_{2}=2^{2}+2\times 2=2\times 4=8\\
a_{3}=2^{3}+2\times 8=3\times 8=24\\
a_{4}=2^{4}+2\times 3\times 8=4\times 2^{4}=64\\
a_{5}=2^{5}+2\times 4\times 2^{4}=5\times 2^{5}=160.
\end{gather*}

If $a_{m}=m2^{m}$ then
\[a_{m+1}=2^{m+1}+2a_{m}=2^{m+1}+m2^{m}=(m+1)2^{m}.\]
Since $a_{1}=2=1\times 2^{1}$ it follows by induction that
\[a_{m}=m2^{m}\]
for all $m\geq 1$.
\newpage\section*{Exercise~\ref{E;middle card two}}
We could add $2^{m}-n$ dummy cards.

If $2^{m-1}<n\leq 2^{m}$, we can sort a pack of $n$ cards 
in $m2^{m}$ operations. But
\[(m-1)\log 2\leq \log n\]
so
\[m\leq \frac{1+\log n}{\log 2}\]
so 
\[m2^{m}\leq \frac{1+\log n}{\log 2}2n.\]
\newpage\section*{Exercise~\ref{E;bound search}}
Suppose that we know that $e_{r}\leq 4r\log r$
for all $2\leq r\leq n-1$. By $\bigstar$ and
Lemma~\ref{L;help sort}
\begin{align*}
e_{n}&=\frac{n^{2}}{n-1}
+\frac{2}{n-1}\big(e_{2}+\dots+e_{n-1})\\
&\leq \frac{n^{2}}{n-1}+\frac{4}{n-1}\sum_{j=2}^{n-1}j\log j\\
&\leq \frac{n^{2}}{n-1}+\frac{4}{n-1}
\left(\frac{n^{2}\log n}{2}-\frac{n^{2}}{4}\right)\\
&=\frac{2n^{2}\log n}{n-1}\\
&\leq 4n\log n.
\end{align*}
Since 
\[e_{2}=1\leq 4\times 2\times \log 2\]
the result follows by induction.
\newpage\section*{Exercise~\ref{E;quite sort}}
Let ${\mathbb I}_{[a,\infty)}(t)=1$ if $t\geq a$
and ${\mathbb I}_{[a,\infty)}(t)=0$ if $t<a$.
\[a{\mathbb I}_{[a,\infty)}(t)\leq X\]
for all $t\geq 0$, so
\[a{\mathbb I}_{[a,\infty)}(X)\leq X\]
and
\[
a\Pr(X\geq a)={\mathbb E}\big(a{\mathbb I}_{[a,\infty)}(X)\big)
\leq {\mathbb E}X\]
as stated.

Thus the probability that the number of operation required is
greater than $a$ times the expected number is less than $1/a$.

(Of course if we work harder we can get better bounds
but this is already satisfactory for many purposes.)
\newpage\section*{Exercise~\ref{E;first shuffle}} 
If the pack is well shuffled then the two packs we
construct in the first round will be well shuffled
and so, by induction, will all the further packs we
examine. But if a pack is well shuffled the bottom
card will be equally likely to be any card in the pack
so choosing it will be the same as choosing
a random card.

If the
pack is already sorted, then at each stage we divide
into a pack of one card and a pack of the rest taking
\[(n-1)+(n-2)+\dots+1=\frac{n(n-1)}{2}\approx\frac{n^{2}}{2}\]
(or thereabouts depending on the fine details of our procedure)
operations.
\newpage\section*{Exercise~\ref{E;Google}}
\[\frac{(8\times 10^{9})^{2}}{2}=4\times 10^{18}.\]
The long way requires $4\times 10^{9}$ seconds
or about $12000$ years (see Exercise~\ref{E;long Hanoi}).

On the other hand
\[4\times (8\times 10^{9})\times\log(8\times 10^{9})
\approx 10^{9}\times 730 \]
so the short way takes about $12$ minutes.
\newpage\section*{Exercise~\ref{E;last shall be first}}
Observe, for example, that
\[\min_{1\leq j\leq n}a_{j}=-\max_{1\leq j\leq n}-a_{j}.\]
\newpage\section*{Exercise~\ref{E;airports}}
Starting from the first airport we may choose
the first port of call in $n-2$ ways (we cannot choose the starting or
end point), the second in $n-3$ ways,
\dots, the $n-2$nd in one way and the fly to the destination airport.
Thus there are
\[(n-2)\times (n-3)\times\dots 1=(n-2)!\]
routes.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;short London}$^{*}$}
\newpage\section*{Exercise~\ref{E;integer parabola}}
(i) We have
\[\frac{n^{2}}{4}-r(n-r)=\frac{n^{2}-4nr+4r^{2}}{4}
= \frac{(r-\tfrac{1}{2}n)^{2}}{4}\geq 0.\]
\newpage\section*{Exercise~\ref{E;wolf}}
Let us write
\begin{gather*}
a=\{P,W,G,C\},\ b=\{P,W,G\}, c=\{P,W,C\}\\
f=\{P,G,C\},\ g=\{P,C\},\ h=\emptyset
\end{gather*}
Then
\[d_{ab}=d_{ba}=d_{bc}=d_{cb}=d_{bf}=d_{fb}=d_{cg}=d_{gc}=d_{fg}
=d_{gf}=2\]
$d_{gh}=d_{hg}=1$ and all other distances are $\infty$.
We get shortest paths $abcgh$ and $abfgh$
both of length $7$. 

(ii) An obvious notation is to write
$(n,m,k)$ for the state when there are $n$ pints in the $8$
pint jug, $m$ in the $5$ pint jug and $k$ in the $3$ pint jug.
We observe that the distance from any $(n,m,k)$
to $(8,0,0)$ is $1$ (just pour everything in to the big jug).
On the other hand if $8>n>0$, $5>m>0$ and
$3>k>0$ then the distance from any other
point is $\infty$ (how do you know when to stop pouring?).

In fact there are very few paths and
a little thought gives
\begin{align*}
(8,0,0)&\rightarrow(3,5,0)\rightarrow(3,2,3)
\rightarrow(6,2,0)\rightarrow(6,0,2)\\
&\rightarrow(1,5,2)
\rightarrow(1,4,3)\rightarrow(0,4,4).
\end{align*}
 

\newpage\section*{Exercise~\ref{E;Dijkstra}}
(i) At the first stage $A_{1}$ is a `new settled town'.
All the signposts point upwards.

At the $n$th stage we simply make the `new settled town'
an `old settled town'.

(ii) We claim that at the beginning of the $r$th
stage the signposts in the settled towns show the
shortest route to $A_{1}$. Assuming this observe that
the shortest route to $A_{1}$
from a given unsettled town through a settled town is
\emph{either} via an old settled town in which case
the distance shown on the signpost will be no larger
than the distance to the new settled town plus the
shortest distance from the new settled town and
the town council will do nothing \emph{or}
the distance shown will be greater in which case
the town council will make the appropriate alteration.
In each case the signpost will now show the shortest
distance from the unsettled town to $A_{1}$
via a settled town. Just as in the old algorithm
an unsettled town which now has a sign showing
a distance no larger than any other unsettled town
has a signpost showing the next town on the shortest route to $A_{1}$
and the total distance required. If we choose one of these
as our new settled town the inductive hypothesis holds with $r$
replaced by $r+1$. The case $r=1$ is trivial so
algorithm works by induction.

(iii) Each town council makes at most one comparison and there
are $n$ councils. We then have to find the smallest
of the distances shown on at most $n$ signposts and this
requires less than $n$ comparisons. Thus we need less than $2n$
comparisons at each stage. Since there are $n$ steps we need
at most $2n^{2}$ comparisons in all.

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;back up hill}$^{*}$}
\newpage\section*{Exercise~\ref{E;bite bullet}}
(i) There are $n^{2}$ ordered pairs $(i,k)$
and to compute $r_{ik}$ we need to find the smallest
of the $n$ numbers $p_{ij}+q_{jk}$. This requires $n-1$
comparisons so we use $n^{2}\times(n-1)\leq n^{3}$
comparisons.

(ii) Let $A=U\bullet(V\bullet W)$ and
$B=(U\bullet V)\bullet W$.

We can find a $S$ such that
\[a_{ij}=\min_{s}\big(u_{rs}+\min_{t}(v_{st}+w_{tj})\big)
=u_{iS}+\min_{t}(v_{St}+w_{tj})\]
and a $T$ such that
\[\min_{t}(v_{St}+w_{tj})=v_{ST}+w_{Tj}.\]
Now
\[\min_{s}(u_{is}+v_{sT})\leq u_{iS}+v_{ST}\]
so
\begin{align*}
b_{ij}&\leq \min_{t}\big(\min_{s}(u_{is}+v_{st})+w_{tj}\big)\\
&\leq\min_{s}(u_{is}+v_{sT})+w_{Tj}\\
&\leq u_{iS}+v_{ST}+w_{Tj}=a_{ij}.
\end{align*}
Similarly $a_{ij}\leq b_{ij}$ so $a_{ij}=b_{ij}$ as required.
\newpage\section*{Exercise~\ref{E;distribute bullet}}
(i) and (ii) Sometimes false. Set
\[U=
\left(
\begin{matrix}
0&1&4\\1&0&4\\0&4&4
\end{matrix}
\right)
,\ V=
\left(
\begin{matrix}
0&4&4\\4&0&1\\4&1&0
\end{matrix}
\right).
\]
Then
\[\min_{j}(u_{1j}+v_{j3})=\min(0+4,1+1,4+0)=2\]
and
\[\min_{j}(v_{1j}+u_{j3})=\min(0+4,4+4,4+0)=4\]
so
$U\bullet V\neq V\bullet U$
although $U$ and $V$ are symmetric.

(iii) Always true. Write $A=V^{T}$, $B=U^{T}$, $C=(U\bullet V)^{T}$
$D=V^{T}\bullet U^{T}$.
Then
\begin{align*}
d_{ik}&=\min_{j}(a_{ij}+b_{jk})=\min_{j}(a_{ji}+b_{jk})\\
&=\min_{j}(b_{kj}+a_{ji})=c_{ij}
\end{align*}
as required.

(iv) Sometimes false.
Take
\[U=
\left(
\begin{matrix}
0&2\\3&0
\end{matrix}
\right)
,\ V=
\left(
\begin{matrix}
0&3\\2&0
\end{matrix}
\right)
,\ W=
\left(
\begin{matrix}
0&4\\4&0
\end{matrix}
\right)
\]
Then
\[U\bullet W=U,\ V\bullet W=V\]
but
\[U+V=\left(
\begin{matrix}
0&5\\5&0
\end{matrix}
\right)\]
so
\[(U+V)\bullet W=W\neq (U+V)=U\bullet W+V\bullet W.\]
\newpage\section*{Exercise~\ref{E;bullet power}}
Clearly
\[d^{[m]}_{ij}=d_{ij}=\text{shortest distance
from $A_{i}$ to $A_{j}$ through
at most $1$ town}.\]
Suppose that $d^{[r]}_{ij}$ is the shortest distance
from $A_{i}$ to $A_{j}$ by a route passing through
at most $r$ towns. If we want to travel from
$A_{i}$ to $A_{j}$ we must go to a town $A_{k}$
(possibly $A_{i}$ or $A_{j}$) and then take the shortest
rout from $A_{k}$ to $A_{j}$ passing through
at most $r-1$ towns. Thus
\begin{align*}
\text{shortest}&\ \text{distance
from $A_{i}$ to $A_{j}$ through
at most $r$ towns}\\
&=\min_{k}(d_{ik}+\text{shortest distance
from $A_{k}$ to $A_{j}$ through}\\
&\qquad\qquad\qquad\qquad\qquad\qquad\text{at most $r-1$ towns})\\
&=\min_{k}(d_{ik}+d^{[r-1]}_{kj})=d^{[r]}_{ij}.
\end{align*}
The stated result follows by induction.

(ii) Since the distance between any two towns is positive
there can be no advantage in visiting the same town twice
so the shortest route (if one exists) must pass through at most
$n-1$ towns. (Similarly, but more simply, if any route exists, 
then one exists passing through $n-1$ towns or fewer.)
Thus 
$D^{[m]}=D^{[n-1]}$ for all $m\geq n-1$. 
and, if $d^{[n-1]}_{ij}=\infty$, there is no
route of any kind from $A_{i}$ to $A_{j}$.
Since $D^{[m]}=D^{[n-1]}$ for all $m\geq n-1$
$d^{[n]}_{ij}$
is the length of the shortest path from $i$ to $j$.
\newpage\section*{Exercise~\ref{E;Floyd}}
(i) Since
$2^{N-1}\leq n$ we have, on taking logarithms,
\[(N-1)\log 2\leq \log n\]
so
\[N\leq 1+\frac{\log n}{\log 2}.\]

(ii) Choose $N$ so that $2^{N-1}\leq n\leq 2^{N}$.
Then we can compute
\[D^{[n]}=D^{[2^{N}]}\]
in less than 
\[N\leq 1+\frac{\log n}{\log 2}\leq K\log n\]
operations. (We can take $K=1$ if $n$ is not too small.
For the purposes of the question we could take $K=10$.)
so we can compute $D^{[n]}$ with less than $Kn^{3}\log n$
comparisons.
\newpage\section*{Exercise~\ref{E;no shortest path}}
\begin{align*}
d_{i(1)i(2)}+d_{i(2)i(3)}+\dots+d_{i(r-1)i(r)}
&=1-2+1-2+\dots\\
&=
\begin{cases}
2-r/2&\text{if $r$ is even}\\
-(r-1)/2&\text{if $r$ is odd}
\end{cases}
\end{align*}
\newpage\section*{Exercise~\ref{E;negative cycles}}
(i) If
\[d_{j(1)j(2)}+d_{j(2)j(3)}+\dots+d_{j(s-1)j(s)}=-k<0\]
then
defining $j(rs+t)=j(t)$ for $1\leq t\leq s$, $r\geq 1$
we have
\[\sum_{u=1}^{Ns-1}d_{j(u)j(u+1)}=-Nk\rightarrow-\infty\]
as $n\rightarrow\infty$.

(ii) Given $k$ and $l$, take a path from $A_{k}$ to $A_{j(1)}$,
go round the length decreasing loop many times, then take
a path from $A_{j(1)}$ to $A_{l}$.
\newpage\section*{Exercise~\ref{E;miss shortest}}
The closest town to $A_{1}$ is $A_{2}$, the closest
town to $A_{1}$ via $A_{2}$ or directly is $A_{3}$ reached via $A_{2}$
so our algorithm gives the path $A_{1}A_{2}A_{3}$.
There is only one other possible path from $A_{1}$ to $A_{3}$.
It is $A_{1}A_{4}A_{3}$ of length $0$ and
is thus the shortest path.
\newpage\section*{Exercise~\ref{E;good Floyd}}
(i) Since there are only $n$ towns any cycle without repetition
contains at most $n$ towns. Given a length decreasing cycle
follow it until the first return. Either we have performed a negative 
cycle with at most $n$ towns or we may throw away the first cycle
and obtain a smaller negative cycle. Since the process terminates 
(we have only a finite number of cycle steps) we must
eventually find a  negative 
cycle with at most $n$ towns ie we can find $r\leq n$ and
$i$ with $d^{[n]}_{kk}<0$. Automatically $d_{kk}^{[n]}<0$.

(ii) If $d^{[n]}_{kk}\geq 0$, then there is no shorter path 
from $k$ to $k$ than
staying at $k$. Thus 
\[d^{[n]}_{kk}=\text{length of shortest path 
from $k$ to $k$ in $n$ or less steps}=0.\]

Since there are only $n$ towns, it follows that,
if there is any path from $A_{i}$ to $A_{j}$, then by removing
cycles there is a path $P$ involving at most $n-1$ steps so
having
\[d^{[n]}_{ij}\leq \text{length of $P$}<\infty.\]

Since there are no  negative cycles, removing cycles
decreases the length of paths from $A_{i}$ to  $A_{j}$.
Thus the shortest paths from $A_{i}$ to $A_{j}$ have at most $n-1$ steps
and so have length equal to $d^{[n]}_{ij}$.
\newpage\section*{Exercise~\ref{E;Gresham}}
Before 1835 melt down US gold dollars. Exchange in France for
French gold coins at a slight loss. Exchange French gold
coins for French silver coins. Melt down French silver coins
and use to buy US silver coins. Exchange US silver coins
for US gold coins and start again.
You have increased your holdings in gold by a little less
than $15\tfrac{1}{2}/15=31/30$ but decreased the amount of gold coin
in US circulation and increased the amount of silver.

After 1835 run the process backwards.
\newpage\section*{Exercise~\ref{E;housebuilding}}
(i) There must be a route from $A_{1}$ to $A_{n}$.
There must be no cycles (if there are then we can go round and round 
to produce ever longer paths).

We can use Floyd's algorithm to solve the problem
with $d_{ij}$ replaced by $-d_{ij}$ (for $d_{ij}\neq\infty$).

(ii) If task $A_{i}$ must be completed before $A_{j}$
and take time $\alpha$, set $d_{ij}=\alpha$. Otherwise take
$d_{ij}=0$. The longest path from $A_{1}$
(start building) to $A_{n}$ (stop building)
gives the time to completion.
  
In general those tasks on the longest path will produce delay
if they take longer. (If a task is not
on a longest path then increasing the time taken on that
task by a small amount will not increase 
the total time required.)


\newpage\section*{Exercise~\ref{E;salesman}}
(i) Roads $(12)$, $(23)$, $(34)$, $(45)$, $(46)$
join all towns. The cost is minimal because we
need at least $5$ roads so a $5$ unit cost is cheapest.

(ii) The method works for $n=2$ since there is only one route.

Suppose it works for $n=m$. Suppose we have $m+1$ towns
with towns $A_{1}$ and $A_{2}$ the closest. If we have
any collection of linking roads for the $m+1$ towns
then there is a set of roads linking $A_{1}$ to $A_{2}$.
If we remove one of those roads and build a road direct from 
$A_{1}$ to $A_{2}$ then we still have collection 
of linking roads for the $m+1$ towns
(after the deletion each town must still be linked 
to at least one of $A_{1}$ and $A_{2}$, and
after the rebuild each town must will be linked 
to $A_{1}$) which will be at least as cheap.
Thus a cheapest set of roads will contain
the road from $A_{1}$ to $A_{2}$ so we may start
by linking $A_{1}$ to $A_{2}$. This reduces the problem to linking
the `city' $\{A_{1},A_{2}\}$ and the towns $A_{3}$,
\dots, $A_{m+1}$. By our inductive hypothesis our method will produce
a cheapest solution to this problem and so to the full problem.

The required result follows by induction.

(iii) We first give an upper bound. We need to find
the least element of at most $n^{2}$ numbers at most $n$
times so we need at most $n^{3}$ comparisons.

Next we give a lower bound. If we are on the $m$th step
and $3n/4\geq m\geq n/4$ then there are at least
$[n/4]^{2}$ possible roads from towns to the city.
Thus we need to make to find the least element
of at least  $[n/4]^{2}$ numbers at least $[n/2]$ times.
Thus (making underestimates) we need at least
$(n-8)^{3}/32$ comparisons. 

Combining these we see that the number of comparisons

(iv) The inductive proof is a repeat of that for (ii).

The method works for $n=2$ since there is only one route.

Suppose it works for $n=m$. Suppose we have $m+1$ towns
with towns $A_{1}$ and $A_{2}$ the closest. If we have
any collection of linking roads for the $m+1$ towns
then there is a set of roads linking $A_{1}$ to $A_{2}$.
If we remove one of those roads and build a road direct from 
$A_{1}$ to $A_{2}$ then we still have collection 
of linking roads for the $m+1$ towns
(after the deletion each town must still be linked 
to at least one of $A_{1}$ and $A_{2}$, and
after the rebuild each town must will be linked 
to $A_{1}$) which will be at least as cheap.
Thus a cheapest set of roads will contain
the road from $A_{1}$ to $A_{2}$ so we may start
by linking $A_{1}$ to $A_{2}$. This reduces the problem to linking
the `city' $\{A_{1},A_{2}\}$ and the towns $A_{3}$,
\dots, $A_{m+1}$. By our inductive hypothesis our method will produce
a cheapest solution to this problem and so to the full problem.

The required result follows by induction.

(v) Initially each town is a conurbation. 
Read the list of distances in order of increasing size.
If you come to a route joining two distinct conurbations
build the road and assign the towns in the two conurbations
to a single conurbation removing the two original conurbations
from the list. When all towns are in a single conurbation
stop.

(vi) If we use quicksort we need at most
\[4\frac{n(n-1)}{2}\log \frac{n(n-1)}{2}\leq 8n\log n\]
comparisons.

(vii) If we enter $A_{1}$, $A_{5}$ or $A_{6}$
by a $1$ unit route we must leave by a $10$ unit route.
We must enter and leave all three so either we
enter and leave one by a $10$ unit route or
we use three $10$ unit routes. Thus we must use
at least two $10$ unit routes and our cost is at least
$24$ units. 

A route which is this cheap is given by is given by 
\[A_{1}A_{2}A_{3}A_{5}A_{4}A_{6}A_{1}.\]
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;adults versus children}$^{*}$}
\section*{Exercise~\ref{E;camping breakdown}$^{*}$}
\newpage\section*{Exercise~\ref{E;no camping breakdown}}
Consider the table of preferences.
\begin{center}
\begin{tabular}{cl}
$A$'s preferences&$B>C>D$\\
$B$'s preferences&$A>C>D$\\
$C$'s preferences&$D>A>B$\\
$D$'s preferences&$C>A>B$
\end{tabular}
\end{center}
The if we group as $(A,B)$ and $(C,D)$ everyone 
has their first preferences.
\newpage\section*{Exercise~\ref{E;apply marriage}}
First stage $(A,j)$

Second stage $(B,j)$, $A$

Third stage $(B,j)$, $(A,k)$

Fourth stage $(B,j)$, $(A,k)$, $(C,m)$

Fifth stage $(D,j)$, $B$, $(A,k)$, $(C,m)$ 

Sixth $(D,j)$, $(A,k)$, $(B,m)$, $C$

Seventh $(D,j)$, $(A,k)$, $(B,m)$, $(C,l)$
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;watch my hands}$^{*}$}
\newpage\section*{Exercise~\ref{E;early marriage}}
Those without partners have taken no part in the events. We have thus
witnessed an application of the algorithm to the $r$ gentlemen and
ladies who have been paired. The pairing is thus stable
for those involved.
\newpage\section*{Exercise~\ref{E;false kindergarten}}

\emph{Not terminating}  Six participants $A$, $B$, $C$, $D$,
$E$ and $F$. 

$A$ preferences $B>C$ and prefers $C$ to any of $D$, $E$ or $F$

$B$ preferences $C>A$ and prefers $A$ to any of $D$, $E$ or $F$

$C$ preferences $A>B$ and prefers $B$ to any of $D$, $E$ or $F$

$D$, $E$ and $F$'s preferences irrelevant.

$A$, $E$ and $F$ in room, $B$, $C$, $D$ to enter in stated order.

Room sees
\begin{align*}
A,E,F&\rightarrow(A,B),E,F\rightarrow (B,C),A,E,F\\
&\rightarrow
(A,C),B,E,F\rightarrow (B,C),A,E,F\rightarrow\ldots
\end{align*}



\emph{Terminating but at unstable point}
Apply the algorithm to the participants in
Exercise~\ref{E;camping breakdown}
with $A$ and $B$ inside the room,
$C$ coming in first and
$D$ having preferences $A>B>C$.
$C$ matches with $A$, $D$ is turned down by $A$
and $B$ and proposes to $C$ who must accept. 
However the system of 
Exercise~\ref{E;camping breakdown}
is unstable.

\newpage\section*{Exercise~\ref{E;life not fair}}
(i) The system gives:-

First stage $(A,j)$. 

Second and final stage $(A,j)$, $(B,k)$.

The reversed system gives

First stage $(j,B)$. 

Second and final stage $(j,B)$, $(k,A)$.

Gentlemen prefer our procedure (they get their first choice).
Ladies prefer reversed procedure (they get their first choice).

(ii) Each gentleman enters in turn,
proposes to his preferred lady
and is accepted.

(iii) The following are stable by inspection.

$(A,j)$ $(B,k)$, $(C,l)$, $(D,m)$

$(A,k)$ $(B,j)$, $(C,l)$, $(D,m)$

$(A,j)$ $(B,k)$, $(C,m)$, $(D,l)$

$(A,k)$ $(B,l)$, $(C,m)$, $(D,l)$.

(vi) Let the gentlemen be $A_{m}$ the ladies $a_{m}$ $[1\leq m\leq 2N]$

If $A_{2r-1}$ has first preference $a_{2r-1}$, second $a_{2r}$,

$A_{2r-1}$ has first preference $a_{2r}$, second $a_{2r-1}$,

$a_{2r-1}$ has first preference $A_{2r}$, second $A_{2r-1}$,

$a_{2r}$ has first preference $A_{2r-1}$, second $A_{2r}$,

\noindent then any pairing with 
\[(A_{2r-1},a_{2r-1}),\,(A_{2r},a_{2r})
\ \text{or}\ (A_{2r-1},a_{2r}),\,(A_{2r},a_{2r-1})\] 
for each $1\leq r\leq N$
is stable and there are $2^{N}$ such pairs.

If we add $A_{2N+1}$ with first choice $a_{2N+1}$ and
$a_{2N+1}$ with first choice $A_{2N+1}$ then the pairings 
already given
 remain stable if we add the pair $(A_{2N+1},a_{2N+1})$.

(v) If we have $n$ gentlemen $A_{j}$ and $n$ ladies $a_{j}$
such that $A_{j}$ has first preference $a_{j}$ and
$a_{j}$ has first preference $A_{j}$ then the only stable
pairing has $(A_{j},a_{j})$.
\newpage\section*{Exercise~\ref{E;start Bertram}}
Suppose that at the first rejection
Agatha rejects Albert. Then Agatha must have rejected
Albert in favour of someone else, let
us say Bertram.
(Either Albert proposed and she preferred to stick with Bertram
or Bertram proposed and she let go of Albert to take up
Bertram.) Thus Agatha prefers Bertram to Albert and
(since there were no previous rejections and Bertram starts
by proposing to his favourite) Agatha is  Bertram's first choice.

There can be no stable solution in which Agatha and Albert
are married since Bertram can always leave his wife for
Agatha (his first choice) and Agatha will drop Albert for him. 

\newpage\section*{Exercise~\ref{E;order no matter}}
Suppose that two applications of our algorithm give
two different results. Then there must exist one man
Albert, say who is married to two different ladies
Bertha and Caroline in the two applications.
If he prefers Bertha to Caroline the second application
gives a stable arrangement in which his married to someone
he likes less well than in the first contrary
to Lemma~\ref{L;best for boys}. A similar objection applies
if he prefers  Caroline to Bertha so we get a contradiction.
All applications of our algorithm must give
the same result.
\newpage\section*{Exercise~\ref{E;fictitious university}}
Since the solution does not depend on the order in which the
suitors (copies of universities) enter we can leave the fictitious
university copies to last. Just before the first fictitious copy
enters the students can be divided into the happy (who have
a fianc{\'e}) and the unhappy. Each fictitious university copy
will be rejected by each happy student and end up with an
unhappy student so the same students will fail to find a place
and the same students will be assigned to each university regardless
of the preferences of the fictitious university copies. 
\newpage\section*{Exercise~\ref{E;picky students}}
[There are many possibilities and these are not claimed to be the most
efficient.]
(i) Suppose there are $N$ students. 
We introduce $N$ extra fictitious universities 
each offering one place and such
that the $j$th fictitious university $U_{j}$ prefers the $j$ th student
to all others.
The $j$th student places the universities she wants to go to
in order then university $U_{j}$ then the remaining fictitious and 
undesired universities in some order. 

Since the solution does not depend on the order in which the
suitors (copies of universities) enter we can leave the $U_{j}$
to last. $U_{j}$ will propose to student $j$ who will accept
(finishing the process) if she has not got an acceptable
place or reject in favour of the acceptable place she has already got.

If the universities have a total of $M$ places
they introduce $M$ shadow applicants. Each university
lists the $k$ applicants it wants in order then
$M-k$ shadows, then the $M$ remaining shadows and unwanted
applicants. If a university copy proposes to a shadow 
that university copy will already have
been turned down by all its wanted applicants (who will have been accepted
by universities they prefer).

(ii) The university of Pismo splits in two `Scholarship Pismo'
and `Place Pismo' and students may order the list
of Scholarship U's and Place U's in any way they wish
(eg A with S, B with S, A without S, C with S, \dots).
[This used to be done with College choice in Oxbridge.) 
\newpage\section*{Exercise~\ref{E;ladies want same}}
Since any lady will leave her present partner if the
universal favourite offers himself, the only
stable solution
will marry him to his first choice.
With these two removed the problem reduces with $n$ pairs
reduces to the problem with $n-1$ pairs so
the only stable choice has the second favourite choosing his favourite
amongst the remaining $n-1$ and so on.

In the context of university entrance the top
candidate chooses her university, the second chooses
from all the universities which are not already full,
the third  chooses
from all the universities which are not already full,
and so on.
\newpage\section*{Exercise~\ref{E;equal marriage}}
We can replace the non-strict old preferences 
by new preferences such that

(1) If $A$ (a lady or gentleman)
strictly prefers $a$ to $b$ in the old system
then $A$ strictly prefers $a$ to $b$ in the new system.

(2) If $A$ gives equal preference $a$ to $b$ in the old system
then either $A$ prefers $a$ to $b$ in the new system 
or  $A$ prefers $b$ to $a$ in the new system

We then solve the new problem using Gale-Shapely.
Since the result is stable with the new preferences
it it is stable under the old.

On the other hand if gentleman $A$ 
and $B$ like ladies $a$ and $b$ equally and vice versa
then neither  $(A,a);(B,b)$ nor $(A,b);(B,a)$  
satisfy the condition
that there do not exist one lady and one
gentleman in different
pairs
by like each other at least as much as their present partner.

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;try votes}$^{*}$}
\newpage\section*{Exercise~\ref{E;two alternatives}}
Since there are only two issues $(2')$ and $(3')$
which deal with $3$ issues are vacuously satisfied.

If everybody prefers $A$ to $B$ 
then at least half the voters prefer $A$ to $B$
and the society prefers $A$ to $B$.

If everybody prefers $B$ to $A$ 
then it is false that
at least half the voters prefer $A$ to $B$
so the society prefers $B$ to $A$.

Thus (1$'$) is satisfied in every case.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;your votes fail}$^{*}$}

\newpage\section*{Exercise~\ref{E;paradox dice}}
Suppose you choose $B$ and I choose $C$.
The following table shows the winner for
the various combinations of throws.
\[
\begin{matrix}&3&5&7\\
1&B&B&B\\
6&C&C&B\\
8&C&C&C
\end{matrix}
\]
We see that the probability that $C$ beats $B$ 
is $5/9$.

Suppose you choose $C$ and I choose $A$.
The following table shows the winner for
the various combinations of throws.
\[
\begin{matrix}&1&6&8\\
2&A&C&C\\
4&A&C&C\\
9&A&A&A
\end{matrix}
\]
We see that the probability that $A$ beats $C$ 
is $5/9$.
\newpage\section*{Exercise~\ref{E;Trybula}}
We have
\begin{gather*}
\Pr(X>Y)=\Pr(X=4)=1-p\\
\Pr(Y>Z)=\Pr(Z=0)=1-p\\
\Pr(Z>X)=\Pr(Z=3,\,X=1)=p^{2}
\end{gather*}
Since $1-p$ is a decreasing and $p^{2}$ an increasing 
function of $p$ for $p\geq 0$
it follows that $\min(1-p,p^{2})$
attains a maximum for $p\geq 0$ when $1-p=p^{2}$
ie $p^{2}+p-1=0$.
Thus
\[p={-1\pm\sqrt{5}}{2},\ p\geq 0\]
so
\[p=\tau={\sqrt{5}-1}{2}\]
(note that $1>\tau>0$) maximises
\[\min\big(\Pr(X>Y),\,\Pr(Y>Z),\,\Pr(Z>X)\big)\]
and with this choice
\[\Pr(X>Y)=\Pr(Y>Z)=\Pr(Z>X)=\tau.\]

You will be able to and 
will choose a more advantageous lane than the red car.
He will then been able to and will
choose a more advantageous lane than the you.
At every stage one of the drivers will be unhappy
and choose a new lane.

\newpage\section*{Exercise~\ref{E;many more sided dice}}
(i) We have
\begin{gather*}
\Pr(\text{$A$ beats $B$})=\Pr(\text{$A$ throws $4$})=\frac{2}{3}\\
\Pr(\text{$B$ beats $C$})=\Pr(\text{$C$ throws $2$})=\frac{2}{3}
\end{gather*}
and
\begin{align*}
\Pr(\text{$C$ beats $D$})&=\Pr(\text{$C$ throws $6$})
+\Pr(\text{$C$ throws 2 and $D$ throws $1$})\\
&=\frac{1}{3}+\frac{1}{2}\times\frac{2}{3}=\frac{2}{3}\\
\Pr(\text{$D$ beats $A$}&=
\Pr(\text{$D$ throws $5$})
+\Pr(\text{$D$ throws $1$ and $A$ throws $0$})\\
&=\frac{1}{2}+\frac{1}{2}\times\frac{1}{3}=\frac{2}{3}.
\end{align*}

$A$ wins against $B$ 
if $B$ throws $2$, $3$ or $4$ or if $B$ throws $15$, $16$ or $17$
and $A$ throws $18$. Thus the probability of $A$ winning 
against $B$ is
\[\frac{1}{2}+\frac{1}{2}\times{1}{6}=\frac{21}{36}.\]

$B$ wins against $C$ if $B$ throws $15$, $16$ or $17$
or if $B$ throws $2$, $3$ or $4$ and $C$ throws $1$  
Thus the provability of $A$ winning 
against $B$ is
\[\frac{1}{2}+\frac{1}{2}\times{1}{6}=\frac{21}{36}.\]

$C$ wins against $A$ unless $A$ throws $18$
or $A$ does not throw $18$ but $C$ throws $1$,
Thus the provability of $C$ winning 
against $A$ is
\[1-\frac{1}{6}-\frac{5}{6}\times\frac{1}{6}
=\frac{25}{36}.\]
\newpage\section*{Exercise~\ref{E;Condorcet}}
$C$ and $A$ prefer $a$ to $b$.
$A$ and $B$ prefer $b$ to $c$.
$B$ and $C$ prefer $c$ to $a$.

By symmetry we need only consider the case when
$c$ is left out of the first vote. Then $a$
will win the first vote and then lose the second vote to $c$.

\newpage\section*{Exercise~\ref{E;two scissors}}
If your opponent chooses $A$ and $B$
then one of them will beat the other. Suppose $A$ beats $B$.
If you always play $A$ then you will draw when
your opponent plays $A$ and win when they play $B$.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;Roland and Collins}$^{*}$}
\section*{Exercise~\ref{E;teddy bear}$^{*}$}
\newpage\section*{Exercise~\ref{E;blimps}}
(i) Whether the second pass is defended or not, it
will always be quicker than the first path,
whether defended or not. Since 
Colonel Schr{\"o}der will always take the second pass,
Lieutenant Luk{\'a}{\v{s}} must defend the second pass.

(ii) Suppose Lieutenant Luk{\'a}{\v{s}}
decides to use
a random strategy and defend the first pass with probability $q$
and the second with probability $1-q$.
If Colonel Schr{\"o}der uses the first pass his
expected time to destination is
\[f_{1}(q)=4(1-q)+6q=4+2q\]
and if he uses the second pass his
expected time to destination is
\[f_{2}(q)=3(1-q)+2q=3-q.\]

Assuming that Colonel Schr{\"o}der 
can guess the chosen $q$
and makes the correct decision, the expected time
for his troops to reach
their destination will be
\[f(q)=\min(f_{1}(q),f_{2}(q))
=f_{2}(q)=3-q
\]
Thus $f$ is a decreasing function of $q$ and
Luk{\'a}{\v{s}} should take $q=0$
and always defend the second pass.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;Calum's diagram}$^{*}$}
\newpage\section*{Exercise~\ref{E;best hat}}
If Calum take $q=\hat{q}$ and Rowena takes $p=\hat{p}$
then Rowena's expected winnings are $e(\hat{p})$, 
and Calum's expected losses are $f(\hat{q})$.
Since Calum's losses are Rowena's gains,
$e(\hat{p})=f(\hat{q})$.
\newpage\section*{Exercise~\ref{E;special Rowena}}
(i) He gets $a_{11}$ regardless of what happens.

(ii) Calum will have a non-unique choice if
\[f(q)=\max(a_{12}+(a_{11}-a_{12})q,a_{22}+(a_{21}-a_{22})q)\]
has a horizontal section on which it takes
its minimum value ie if
\[a_{11}-a_{12}=0\ \text{and}\ a_{12}<\max(a_{21},a_{22})\]
or
\[a_{21}-a_{22}=0\ \text{and}\ a_{22}<\max(a_{11},a_{12})\]
or
\[a_{11}=a_{12}=a_{21}=a_{22}.\]

(iii) Consider the following matrix of Rowena's winnings
\[\left(
\begin{matrix}
0&0\\
1&-1
\end{matrix}
\right).\]
Calum can play any strategy which takes the second
column with probability $q\geq 1/2$. Rowena
must pick the first row (ie has the unique choice $p=1$).
\newpage\section*{Exercise~\ref{E;many many games}}
We have an $n\times m$ matrix $A=(a_{ij})$.
If Rowena has chosen row
$i$ and Calum has chose column $j$, then Calum pays
the amount $a_{ij}$ to
Rowena. The object of Rowena is to maximise the
expected sum paid to her and the object of  Calum
is to minimise that sum.

We shall say that Rowena adopts strategy ${\mathbf p}$
if she chooses row $i$ with probability $p_{i}$
and that  Calum adopts strategy ${\mathbf q}$
if he chooses row $j$ with probability $q_{j}$.
If Rowena adopts strategy ${\mathbf p}$
and Calum adopts strategy ${\mathbf q}$,
then the expected gain for Rowena is
\begin{align*}
e({\mathbf p},{\mathbf q})
=&a_{11}p_{1}q_{1}+a_{12}p_{1}q_{2}+a_{13}p_{1}q_{3}+\dots\\
&+a_{21}p_{2}q_{1}+a_{22}p_{2}q_{2}+a_{23}p_{2}q_{3}+\dots\\
&+a_{31}p_{3}q_{1}+a_{22}p_{3}q_{2}+a_{23}p_{3}q_{3}+\dots\\
&+\dots
\end{align*}
which may be written more briefly as
\[e({\mathbf p},{\mathbf q})=\sum_{i=1}^{n}\sum_{j=m}^{3}a_{ij}p_{i}q_{j}
=\sum_{i=1}^{n}\sum_{j=m}^{3}p_{i}a_{ij}q_{j}\]
or, still more briefly, in matrix notation
\[e({\mathbf p},{\mathbf q})={\mathbf p}^{T}A{\mathbf q}.\]
\newpage\section*{Exercise~\ref{E;matrix in saddle}}
Take
\[H=
\left(
\begin{matrix}3&2\\1&0\end{matrix}
\right).\]
Then
\[
\max_{i}\min_{j}h_{ij}=\max\{2,0\}=2\neq 1=\min\{3,1\}
=\min_{i}\max_{j}h_{ij}.\]
\newpage\section*{Exercise~\ref{E;simple Morra}}
\[
\begin{array}{c|c|c|c|c|c}
&[11]&[12]&[21]&[22]\\\hline
[11]&0&1&-1&0\\\hline
[12]&-1&0&0&1\\\hline
[21]&1&0&0&-1\\\hline
[22]&0&-1&1&0
\end{array}
\]

The game is symmetric so the expected winnings with
best play is $0$. If row chooses each play with probability $1/4$
the expected value of the outcome for column is $0$
whichever column is chosen. Thus row's play is optimal.

The same argument shows that for the general game 
each player should choose each outcome $[r,s]$ with equal probability.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;complex Morra}$^{*}$}
\newpage\section*{Exercise~\ref{E;bad Morra}}
If row plays each row with probability $1/9$
the expected value to row of column playing column $[rs]$
is
\[e_{[rs]}=\frac{1}{9}\sum_{[ij]} a_{[rs][ij]}.\]
Thus
\begin{gather*}
e_{[11]}=3/9=1/3,\ e_{[12]}=0,\ e_{[13]}=-3/9=-1/3,\\
e_{[21]}=3/9=1/3,\ e_{[22]}=0,\ e_{[23]}=-3/9=-1/3,\\
e_{[31]}=3/9=1/3,\ e_{[32]}=0,\ e_{[33]}=-3/9=-1/3.
\end{gather*}
Since $e_{[11]}>0$ row's strategy cannot be right.
Column can gain an advantage by always guessing $3$.

I would always guess $3$. (Does not matter how many fingers I hold out.) 

\newpage\section*{Exercise~\ref{E;solve Morra}}
Since the game is symmetric the outcome of best play
must have expected value $0$. If row plays $\hat{\mathbf p}$.
then expected value of the game to row
if column plays row $[rs]$ is $e_{[rs]}$ with
\begin{align*}
e_{[11]}&=\tfrac{5}{12}\times (-2)+\tfrac{1}{3}\times 0+\tfrac{1}{4}\times 4
=\tfrac{1}{6}>0\\
e_{[12]}&=\tfrac{5}{12}\times 0+\tfrac{1}{3}\times (-3)+\tfrac{1}{4}\times 4
=0\\
e_{[13]}&=\tfrac{5}{12}\times 0+\tfrac{1}{3}\times 0+\tfrac{1}{4}\times 0
=0\\
e_{[21]}&=\tfrac{5}{12}\times (-3)+\tfrac{1}{3}\times 4+\tfrac{1}{4}\times 0
=\tfrac{1}{12}\\
e_{[22]}&=\tfrac{5}{12}\times 0+\tfrac{1}{3}\times 0+\tfrac{1}{4}\times 0
=0\\
e_{[23]}&=\tfrac{5}{12}\times 0+\tfrac{1}{3}\times 4+\tfrac{1}{4}\times (-5)
=\tfrac{1}{16}\\
e_{[31]}&=\tfrac{5}{12}\times 0+\tfrac{1}{3}\times 0+\tfrac{1}{4}\times 0
=0\\
e_{[32]}&=\tfrac{5}{12}\times 4+\tfrac{1}{3}\times (-5)+\tfrac{1}{4}\times 0
=0\\
e_{[33]}&=\tfrac{5}{12}\times 4+\tfrac{1}{3}\times 0+\tfrac{1}{4}\times (-6)
=\tfrac{1}{6}>0
\end{align*}
 
(ii) Follows from the table.

(iii) No. For example, if we know they are always going
to play $[2,2]$ we can always play $[3,2]$.
\newpage\section*{Exercise~\ref{E;reduce games}}
Rowena will always do better by choosing $R_{1}$ rather than $R_{4}$.
Our system thus reduces to
\[\begin{array}{c|rrr}
&C_{1}&C_{2}&C_{3}\\\hline
R_{1}&4&-2&-5\\
R_{2}&-2&4&3\\
R_{3}&-3&6&2
\end{array}\]
Now Calum can always do better by choosing $C_{3}$ rather than $C_{2}$.
Our system  reduces to
\[\begin{array}{c|rr}
&C_{1}&C_{3}\\\hline
R_{1}&4&-5\\
R_{2}&-2&3\\
R_{3}&-3&2
\end{array}\]
Now Rowena can always do better 
by choosing $R_{2}$ rather than $R_{3}$.
Our system  reduces to
\[\begin{array}{c|rr}
&C_{1}&C_{3}\\\hline
R_{1}&4&-5\\
R_{2}&-2&3\\
\end{array}\]

Suppose Rowena chooses $R_{1}$ with probability $p$
and $R_{2}$ with probability $1-p$. If
Calum chooses $C_{1}$, Rowena's expected winnings
are
\[e_{1}(p)=4p-2(1-p)=6p-2.\]
If
Calum chooses $C_{3}$, Rowena's expected winnings
are
\[e_{2}(p)=-5p+3(1-p)=3-8p.\]
Rowena chooses $p$ to maximise
\[
\min(6p-2,3-8p)
=\begin{cases}
6p-2&\text{if $p\leq 5/14$}\\
3-8p&\text{if $p\geq 5/14$}.
\end{cases}
\]
Thus Rowena chooses $R_{1}$ with probability $5/14$, $R_{2}$ 
with probability $9/14$ and never chooses $R_{3}$ or $R_{4}$.

Suppose Calum chooses $C_{1}$ with probability $q$
and $C_{3}$ with probability $1-q$. If
Rowena chooses $R_{1}$, Rowena's expected winnings
are
\[f_{1}(q)=4q-5(1-q)=9q-5.\]
If
Rowena chooses $R_{2}$, Rowena's expected winnings
are
\[f_{2}(q)=-2q+3(1-q)=3-5q.\]
Calum chooses $q$ to minimise
\[
\max(9q-5,3-5q)
=\begin{cases}
3-5q&\text{if $q\leq 4/7$}\\
9q-5&\text{if $q\geq 4/7$}.
\end{cases}
\]
Thus Calum chooses $C_{1}$ with probability $4/7$, $C_{3}$ 
with probability $3/7$ and never chooses $R_{2}$.

Observe that Rowena's expected winnings $E_{j}$ 
if she plays as advised and Calum
chooses $C_{j}$
are
\begin{align*}
E_{1}=4\times\tfrac{5}{14}-2\times\tfrac{9}{14}=\tfrac{1}{7}\\
E_{2}=(-2)\times\tfrac{5}{14}+4\times\tfrac{9}{14}=\tfrac{13}{7}>\tfrac{1}{7}\\
E_{1}=(-5)\times\tfrac{5}{14}+3\times\tfrac{9}{14}=\tfrac{1}{7}\\
\end{align*}
and 
Rowena's expected winnings $F_{k}$ 
if Calum plays as advised and she
chooses $R_{k}$
are
\begin{align*}
F_{1}&=4\times\tfrac{4}{7}-5\times\tfrac{3}{7}=\tfrac{1}{7}\\
F_{2}&=(-2)\times\tfrac{4}{7}+3\times\tfrac{3}{7}=\tfrac{1}{7}\\
F_{3}&=(-3)\times\tfrac{4}{7}+2\times\tfrac{3}{7}=-\tfrac{6}{7}<\tfrac{1}{7}\\
F_{4}&=3\times\tfrac{4}{7}-6\times\tfrac{3}{7}=-\tfrac{6}{7}<\tfrac{1}{7}.
\end{align*}
Thus our strategies are indeed optimal.
\newpage\section*{Exercise~\ref{E;bluff}}
Bingham should always bet if the card is black
since he is always better off betting whatever you do.
Thus $b=1$.

If you always fold, then Bingham's expected winnings are
\[e_{F}=\tfrac{1}{2}+\tfrac{1}{2}\big(p-(1\times(1-p))\big)=p.\]
If you always call, then Bingham's expected winnings are
\[e_{C}=2\times\tfrac{1}{2}-2p\times\tfrac{1}{2}-(1-p)\times\tfrac{1}{2}
=\tfrac{1}{2}(1-p).\]
Thus if you know what Bingham is going to do,
his expected winnings are
\[\min\{p,\tfrac{1}{2}(1-p)\}=
\begin{cases}
p&\text{if $p\leq\tfrac{1}{3}$}\\
\tfrac{1}{2}(1-p)&\text{if $p\geq\tfrac{1}{5}$}
\end{cases}
\]
so Bingham should take $b=1$, $p=\tfrac{1}{3}$ and his expected
winnings are $\tfrac{1}{3}$.

Now consider your play. If Bingham always passes on red (but 
always bets on black)
his expected winnings are
\[f_{P}=-\tfrac{1}{2}+\tfrac{1}{2}(2q+(1-q))=\frac{q}{2}.\]
If Bingham always bets, his expected winnings are
\[f_{B}=2q\times(\tfrac{1}{2}-\tfrac{1}{2})+(1-q)=1-q.\]
Thus if Bingham knows what you are going to do
his expected winnings are
\[\max\{\tfrac{1}{2}q,1-q\}=
\begin{cases}
1-q&\text{if $q\leq\tfrac{2}{3}$}\\
\tfrac{1}{2}q&\text{if $q\geq\tfrac{2}{3}$}
\end{cases}
\]
so you should take $q=\tfrac{2}{3}$ and (as already
found earlier) his expected
winnings are $\tfrac{1}{3}$.
\newpage\section*{Exercise~\ref{E;Blotto}}
(i) If $n=1$, then $a_{1}=b_{1}$. If $n=2$
$a_{1}=b_{2}$, $a_{2}=b_{1}$ . We always have a draw.

(ii) Suppose $A$ always takes $a_{j}=1$ or $a_{j}=0$. Let
$X$ be the set of $j$ where $a_{j}=1$, $Y$ the set of $j$
where $b_{j}=1$ and $Z$ the set of $j$
where $b_{j}\geq 2$. Then $A$ wins on battlefields with
$j\in X\setminus(Y\cup Z)$ and $B$ wins on battlefields with
$j\in Z\cup (Y\setminus X)$. Otherwise we have draws.
Writing $|W|$ for the number of elements of $W$, we have
\begin{align*}
|X\setminus(Y\cup Z)|&-|Z\cup (Y\setminus X)|\\
&=\big(|X|-|X\cap Y|-|X\cap Z|\big)-\big(|Z|+|Y|-|X\cap Y|)\\
&=\big(|X|-|Z|-|Y|)-|X\cap Z|\geq |X|-2|Z|-|Y|\\
&=n-2|Z|-|Y|\geq 0
\end{align*}
so $A$ has a draw or better.

(iii) Without loss of generality we suppose that $A$
has chosen $a_{1}\geq a_{2}\geq\dots\geq a_{n}$. Since
$m>n$ we have $a_{1}\geq 2$. If $B$ chooses
$b_{1}=a_{1}-2$, $b_{2}=a_{2}+1$, $b_{3}=a_{3}+1$, $b_{j}=a_{j}$
for $j\geq 4$, she will win.
\newpage\section*{Exercise~\ref{E;intermediate duel}}
(i) If $a>b$ then
\[h(b)=f(b)+g(b)>f(a)+g(b)>f(a)+g(a)=h(a).\]
Thus $h$ is strictly increasing.
Since the sum of continuous functions is continuous, $h$ 
is continuous. 

(ii) $h(0)=f(0)+g(0)=1+1=2$ and  $h(1)=0+0=0$.

(iii) The intermediate value theorem tells us
that (i) and (ii) imply the existence of an 
$x_{0}$ with $0<x_{0}<1$ with $h(x_{0})=1$.
Since $h$ is strictly increasing the solution is unique.

\newpage\section*{Exercise~\ref{E;George and Fred}}
(i) Suppose $y>x_{0}$. If $z\geq y$
\[\Pr(\text{George paintballed})=f(z)<f(x_{0}).\]
If $z<y$
\[\Pr(\text{George paintballed})=1-g(y)>1-g(x_{0})=f(x_{0}).\]
Thus Fred should choose $z<y$ and, with this choice,
\[\Pr(\text{George paintballed})=f(y)>f(x_{0}).\]

(ii)  Suppose $y<x_{0}$ so $f(y)+g(y)>1$. If $z>y$
\[\Pr(\text{George paintballed})=f(z)<f(y).\]
If $z<y$
\[\Pr(\text{George paintballed})=1-g(y)<f(y).\]
If $z=y$
\[\Pr(\text{George paintballed})=f(y).\]
Thus Fred should choose $z=y$
and, with this choice,
\[\Pr(\text{George paintballed}=f(y)>f(x_{0}).\]

(iii) Suppose $y=x_{0}$. If  If $z>y$
\[\Pr(\text{George paintballed})=f(z)<f(x_{0}).\]
If $z\leq y$
\[\Pr(\text{George paintballed})=1-g(x_{0})=f(x_{0}).\]
Thus Fred should choose $z\leq x_{0}$
and, with this choice,
\[\Pr(\text{George paintballed}=f(x_{0}).\]

(iv) Thus Fred should fire at $x_{0}$ and,
by the same argument with roles reversed
George should fire at $x_{0}$.

\newpage\section*{Exercise~\ref{E;expected one}}
If they do not fire simultaneously, either
the one who did not fire is paintballed and the firer
is not  paintballed or the one who fires misses
and will certainly be paintballed.
The number of paintballed players is $1$.

The probability both paintballed is $pq$, probability
neither paintballed is $(1-p)(1-q)$.
The expected number of paintballed participants
is $p+q=1$.

If they fire at $x>x_{0}$ the expected number 
of paintballed participants
is $f(x)+g(x)<1$.

If they fire at $x<x_{0}$ the expected number 
of paintballed participants
is $f(x)+g(x)>1$.
\newpage\section*{Exercise~\ref{E;ice-cream}}
It is what one would expected if customers go to
the nearest ice-cream seller and customers are evenly distributed.

If the first seller is at $x<1/2$
then the if the second goes to $y=\tfrac{1}{2}(x+\tfrac{1}{2})$
then, since $y>x$, the first seller will have
\[f\big(x,\tfrac{1}{2}(x+\tfrac{1}{2})\big)
=\tfrac{3}{4}x+\tfrac{1}{4}<1/2.\]
By symmetry, or by repeating the argument,
if the first seller is at $x>1/2$ then there is a $y$
with
\[f(x,y)<1/2\]
However if $x=1/2$ then, if $y>1/2$,
\[f(x,y)=(\tfrac{1}{2}+y)/2>1/2\]
and by symmetry, or by repeating the argument,
if $y<1/2$,
\[f(x,y)=(\tfrac{1}{2}+y)/2>1/2.\]
Finally
\[f(\tfrac{1}{2},\tfrac{1}{2})=1/2.\]
Thus the first ice-cream seller will choose $x=1/2$
and by symmetry the second will also chose $y=1/2$.

Presumably (but this is not really a mathematical question)
they will move towards each other and when they have met
they will jostle for the more central position slowly moving
to the centre.
\newpage\section*{Exercise~\ref{E;buses}}
Suppose that the other bus company chooses to start at
$a$ minutes past the hour. Then the expected proportion
of passengers carried by the first company
is
\begin{align*}
\frac{1}{60}\sum_{r=0}^{59}f(r,a)
&=\frac{1}{60}\sum_{j=0}^{59}f(j,0)\\
&=\frac{1}{60}\left(\frac{1}{2}+\sum_{j=1}^{59}\frac{j}{60}\right)\\
&=\frac{1}{60}\left(\frac{1}{2}+\frac{59}{2}\right)=\frac{1}{2}.
\end{align*}
By symmetry, if each company employs its best tactics
they must get equal expected return. Since
the total expected return (as a proportion of passengers) is $1$,
if each company employs its best tactics
they must get return $1/2$.

If the first company knows the departure time of the second
and decides to leave $a$ minutes before, then it will get
$(60-a)/60$ of the total carried for $1\leq a\leq 59$
and $1/2$ if $a=0$. Thus it will leave one minute earlier
than the other company. Thus each week the company can move
will go $1$ minute before the other. (So after the second week
the changing company will move its departure time $2$ minutes
earlier.)  The author believes that has actually seen this happen
with the dates of college research fellowship interviews.
\newpage\section*{Exercise~\ref{E;loyal horse}}
The travellers should finish together 
(otherwise the one who arrives later could spend a little longer on
the horse and arrive sooner yet still not beat the first
traveller).  
Thus the travellers must spend the same time on 
the horse and the horse must be left at the halfway point.
It takes the first rider $x/(2v)$ to get to the halfway point riding
and $x/(2u)$ to finish walking. The time taken
is 
\[\left(\frac{1}{2u}+\frac{1}{2v}\right)x.\]

If they do something more complicated then they must still finish together.
If they met earlier then they meet for the first time and
the argument above shows that their best average speed 
up to this point is $\big((2u)^{-1}+(2v)^{-1}\big)^{-1}$. 
The same holds for the
average speed between the $k$th and $k+1$st meeting
so they can not improve their average speed over the course
so they can not arrive earlier.

The same arguments show that with the clever horse 
they can not do better than the first rider riding
a certain distance the leaving the horse to walk back 
toward the second who then mounts and proceeds 
to the finishing line crossing at the same time.
Each must spend the same time in the saddle so
the first leaves the horse at $\tfrac{1}{2}(1+\alpha)x$.
The  noble and sagacious steed will then walk
back meeting the walker at $\tfrac{1}{2}(1-\alpha)x$.

The time taken by the first traveller is
\[\tfrac{1}{2}(1+\alpha)\frac{x}{v}+\tfrac{1}{2}(1-\alpha)\frac{x}{u}\]
The time taken by the horse is
\[2\times(1+\alpha)\frac{x}{v}
+{\alpha x}{w}.\]
These two times must be equal so
\[\frac{1+\alpha}{v}+\frac{1-\alpha}{u}
=2\frac{1+\alpha}{v}+2\times{\alpha}{w}.\]
whence
\[-\frac{1+\alpha}{v}+\frac{1-\alpha}{u}
=2\times{\alpha}{w}\]
and
\[\alpha=\frac{v^{-1}-u^{-1}}{u^{-1}+v^{-1}+2w^{-1}}.\]
Thus the total time taken is
\begin{align*}
\frac{x}{2}&\left(v^{-1}+u^{-1})
+\frac{u^{-1}-v^{-1}}{u^{-1}+v^{-1}+2w^{-1}}(v^{-1}-u^{-1})\right)\\
           &=\left(v^{-1}+u^{-1}
             -\frac{(u^{-1}-v^{-1})^{2}}{u^{-1}+v^{-1}+2w^{-1}}\right)\\
  &=\frac{x}{1+\tfrac{u}{v}\tfrac{v+w}{u+w}}.
 \end{align*}
\newpage\section*{Exercise~\ref{E;convex Alice}}
Since $t,\,1-t,\,p_{j},\,q_{j}\geq 0$ we have
$tp_{j}\geq 0$, $(1-t)q_{j}\geq 0$ and 
\[tp_{j}+(1-t)q_{j}\geq 0.\]
Further
\[\sum_{j=0}^{n}(tp_{j}+(1-t)q_{j})
=t\sum_{j=0}^{n}p_{j}+(1-t)\sum_{j=0}^{n}q_{j}=t+(1-t)=1.\]
Thus 
\[{\mathbf u},{\mathbf v}\in\tilde{K},\ 1\geq t\geq 0
\Rightarrow t{\mathbf u}+(1-t){\mathbf v}\in\tilde{K}\]
and $\tilde{K}$ is convex.

\newpage\section*{Exercise~\ref{E;old and new convex}}
Write
\[K=\{(x,y)\in{\mathbb R}^{2}\,:\,f(x)\geq y\}.\]
Then
\begin{align*}
(x_{1},y_{1}),&(x_{2},y_{2})\in K,\ 1\geq t\geq 0\\
&\Rightarrow f(x_{1})\geq y_{1},\ f(x_{2})\geq y_{2},
\ 1\geq t\geq 0\\
&\Rightarrow f\big(tx_{1}+(1-t)x_{2}\big)\geq
tf(x_{1})+(1-t)f(x_{2})\\
&\qquad\qquad\geq ty_{1}+(1-t)y_{2}\\
&\Rightarrow
t(x_{1},y_{1})+(1-t)(x_{2},y_{2})\\
&\qquad\qquad=(tx_{1}+(1-t)x_{2},ty_{1}+(1-t)y_{2})\in K
\end{align*}
so $K$ is convex.

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;Hahn's hyperbola}$^{*}$}
\newpage\section*{Exercise~\ref{E;Rule four}}
(i) If $(ax^{*},by^{*})$ is a best choice
for  $K_{a,b}$ when we use
the status quo point $(ax_{0},by_{0})$,
then $(x^{*},y^{*})=(a^{-1}ax^{*},b^{-1}by^{*})$
is a best choice
for  $K=(K_{a,b})_{a^{-1},b^{-1}}$ with 
status quo point $(x_{0},y_{0})=(a^{-1}ax_{0},b^{-1}by_{0})$.

(ii) We have
\begin{align*}
(u_{1},v_{1}),&\ (u_{2},v_{2})\in L_{a,b},
\ 1\geq t\geq 0\\
&\Rightarrow (a^{-1}u_{1},b^{-1}v_{1}),\ (a^{-1}u_{2},b^{-1}v_{2})\in L,
\ 1\geq t\geq 0\\
&\Rightarrow 
(ta^{-1}u_{1}+(1-t)a^{-1}u_{2},tb^{-1}v_{1}+(1-t)b^{-1}v_{2})\in L\\
&\Rightarrow \big(a(ta^{-1}u_{1}+(1-t)a^{-1}u_{2},
b(tb^{-1}v_{1}+(1-t)b^{-1}v_{2})\in L_{a,b}\\
&\Rightarrow t(u_{1},v_{1})+(1-t)(u_{2},v_{2})\in L_{a,b}.
\end{align*}

\newpage\section*{Exercise~\ref{E;add convex}}
Observe that
\begin{align*}
t(u+x_{1},v+y_{1})+&(1-t)(u+x_{2},v+y_{2})\\
&=\big(u+(tx_{1}+(1-t)x_{2}),v+(ty_{1}+(1-t)y_{2})\big).
\end{align*}

\newpage\section*{Exercise~\ref{E;Alice, Bob and Caroline}}
We carry out the argument with $n$ people.

\noindent{\bf Rule 1} (Pareto optimality)
Let $K$ be a set of options in ${\mathbb R}^{n}$. 
If ${\mathbf x}$ and ${\mathbf y}$are distinct
points of $K$,
$x_{j}\geq y_{j}$ for all $j$ and $x_{k}>y_{k}$
for some $k$, then
${\mathbf x}$ is preferred to ${\mathbf y}$.

\noindent{\bf Lemma A} Consider a set of options
\[K=\left\{{\mathbf x}\,:\,\sum_{j=1}^{n}x_{j}\leq 1\right\}.\]
The set of best choices under Rule~1
is 
\[E=\left\{{\mathbf x}\,:\,\sum_{j=1}^{n}x_{j}\leq 1\right\}.\]
\begin{proof} If $\sum_{j=1}^{n}x_{j}<1$, 
set $y_{1}=x_{1}+1-\sum_{j=1}^{n}x_{j}$
and $y_{j}=x_{j}$ for $j\geq 2$. 
Then ${\mathbf y}$ is preferred to ${\mathbf x}$.
\end{proof}

\noindent{\bf Rule 2} (Fairness)
Let $K$ be a set
of options which is symmetric between Alice and Bob
in the sense that ${\mathbf x}\in K$,
$y_{j}=x_{\sigma j}$ for all $j$ and some bijection
\[\sigma:\{1,2,\dots, n\}\rightarrow\{1,2,\dots, n\}\]
If the status quo point ${\mathbf z}$ has the form
\[{\mathbf z}=(z,z,\dots z)\]
any best choice must be of the form
\[{\mathbf z}=(w,w,\dots w).\]

\noindent{\bf Lemma B} Consider a set of options
\[K=\left\{{\mathbf x}\,:\,\sum_{j=1}^{n}\leq 1\right\}\]
with status quo point ${\boldsymbol 0}$.
Under Rule~1 and Rule~2 there is a unique best choice
$(1/n,1/n,\dots,1/n)$.
\begin{proof}
Since $K$ and ${\boldsymbol 0}$ are symmetric we can apply Rule~2. 
Observe that the only symmetric point 
in the set $E$ of Lemma~A is 
\[{\mathbf x}^{*}=(1/n,1/n,\dots,1/n).\]
\end{proof}

\noindent{\bf Rule 3}
(Indifference to rejected alternatives)
Let $K$ and $K'$ be a sets of options
with ${\mathbf z}\in K'\subseteq K$. Suppose that 
${\mathbf x}^{*}\in K$
is a best choice for $K$ with status quo point ${\mathbf z}$.
Then, if ${\mathbf x}^{*}\in K'$, it will be a best choice for
$K'$ with status quo point ${\mathbf z}$.

\noindent{\bf Lemma C} Consider a set of options
\[K\subseteq\left\{{\mathbf x}\,:\,\sum_{j=1}^{n}\leq 1\right\}\]
with status quo point ${\boldsymbol 0}$.
If $(1/n,1/n,\dots,1/n)\in K$, then
under Rules~1 to~3 it is the unique best choice.

\noindent{\bf Lemma D} Suppose that $K$ is a convex set
such that 
\[{\mathbf u}=(1/n,1/n,\dots,1/n)\in K\] 
and 
$\prod_{j=1}^{n}x_{j}\leq n^{-n}$ for all 
${\mathbf x}\in K$ with $x_{j}\geq 0$ for all $j$.
Then
\[K\subseteq\left\{{\mathbf x}\,:\,\sum_{j=1}^{n}\leq 1\right\}.\]
\begin{proof} Suppose ${\mathbf x}\in K$ and $x_{j}\geq 0$
for all $j$. Then
\[{\mathbf u}+t({\mathbf x}-{\mathbf u})
=((1-t){\mathbf u}+{\mathbf x}\in K\]
for all $1\geq t\geq 0$ and so
\[
n^{-n}\geq \prod_{j=1}^{n}\big(n^{-1}+t(x_{j}-n^{-1})\big)
\]
and so
\[t\sum_{j=1}^{n}(x_{j}-n^{-1})+t^{2}P_{{\mathbf x}}(t)\leq 0\]
for some polynomial $P_{{\mathbf x}}(t)$. Thus, dividing by $t$,
\[\sum_{j=1}^{n}(x_{j}-n^{-1})+tP_{{\mathbf x}}(t)\leq 0\]
for all $1\geq t>0$. Allowing $t\rightarrow 0+$, we obtain
\[\sum_{j=1}^{n}(x_{j}-n^{-1})\leq 0\]
ie
\[\sum_{j=1}^{n}x_{j}\leq 1\]
as stated.
\end{proof}

Lemmas C and D combine to give us Lemma E.

\noindent{\bf Lemma E} Suppose that $K$ is a convex set
such that 
\[{\mathbf u}=(1/n,1/n,\dots,1/n)\in K\] 
and 
$\prod_{j=1}^{n}x_{j}\leq n^{-n}$ for all 
${\mathbf x}\in K$ with $x_{j}\geq 0$ for all $j$.
If the status quo point is ${\boldsymbol 0}$,  then,
under Rules~1 to~4, ${\mathbf u}$ is the unique best choice.

\noindent{\bf Rules 4 and 5} (Scale and translation invariance)
If $a_{j}>0$ and ${\mathbf b}\in{\mathbb R}^{n}$
define 
$T_{{\mathbf a},{\mathbf b}}:{\mathbb R}^{n}\rightarrow {\mathbb R}^{n}$
by 
\[T_{{\mathbf a},{\mathbf b}}({\mathbf x})={\mathbf y}\]
with
\[y_{j}=a_{j}x_{j}+b_{j}.\]
We demand that, if ${\mathbf x}^{*}$ is a best choice
for some set $K$ with status quo point ${\mathbf u}$,
then $T_{{\mathbf a},{\mathbf b}}{\mathbf x}^{*}$ is a best choice
for $T_{{\mathbf a},{\mathbf b}}K$ 
with status quo point $T_{{\mathbf a},{\mathbf b}}{\mathbf u}$.

\noindent{\bf Theorem} Consider a convex set of options $K$
with status quo point ${\mathbf u}$.
If ${\mathbf x}^{*}\in K$, $x^{*}_{j}>u_{j}$ for all $j$.
and 
\[\prod_{j=1}^{n}(x_{j}-u_{j})\leq 
\prod_{j=1}^{n}(x_{j}^{*}-u_{j})\]
for all ${\mathbf x}\in K$ with $x_{j}>u_{j}$ for all $j$,
then, under  Rules~1 to~5, $(x^{*},y^{*})$ is the unique best choice.
\begin{proof} Use Lemma E together with rules~4 and~5
applied with ${\mathbf b}=-{\mathbf u}$, $a_{j}=n^{-1}(x_{j}-u_{j})^{-1}$.
\end{proof} 
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;informal bargain}$^{*}$}
\newpage\section*{Exercise~\ref{E;hard threat point}}
(i) Since the status point is $(0,0)$
the only points $(x,y)$ to consider must have $y\geq 0$
so $y=0$ so be $(x,0)$. If $0\leq x<1$ 
then $(1,0)$ is preferred to $(x,0)$. There is no point
preferred to $(1,0)$ which is therefore a unique best
choice.

(ii) Suppose (a) and (b) false.
Then we can find $(x,0)\in K$ with $x>0$
and $(0,y)\in K$ with $y>0$. By
convexity 
\[(x/2,y/2)=\tfrac{1}{2}(x,0)+\tfrac{1}{2}(0,y)\in K\]
yet $x/2,y/2>0$ contradicting the condition on $K$.

Part~(i) shows that (b) may be false but (a)
true. Interchanging $x$ and $y$ this shows that
(a) may be false but (b)
true.

If we take 
\begin{gather*}
(a_{0},b_{0})=(0,0),\ (a_{1},b_{1})=(0,-1),\\
(a_{2},b_{2})=(-1,0)\ \text{and}\ (a_{3},b_{3})=(-1,-1)
\end{gather*}
and status quo point $(0,0)$, then the only point 
$(x,y)$ in $\tilde{K}$ with $x\geq 0,\,y\geq 0$
is $(0,0)$ so both (a) and (b) are true.

(iii) By translation we may suppose $(x_{0},y_{0})=(0,0)$ 
Take $K=\tilde{K}$ in part~(ii).
If (a) and (b) are true then the status point is the 
unique best point. If (b) is false then by the argument of (i)
the unique best point is $(x^{*},0)$
with $x^{*}$ the largest $x$ with $(0,x)\in K$.
\newpage\section*{Exercise~\ref{E;problems with open}}
(i) Observe that
\[a^{2}+b^{2}-2ab=(a-b)^{2}\geq 0.\]

(ii) Write
\[\|{\mathbf x}\|=(x^{2}+y^{2})^{1/2}.\]
Using the triangle inequality (see Exercise~\ref{E;Jensen}~(iv)),
we see that, if $1\geq t\geq 0$,
\begin{align*}
&{\mathbf u},{\mathbf v}\in D
\Rightarrow \|{\mathbf u}\|,\|{\mathbf v}\|<1\\
&\Rightarrow \|t{\mathbf u}+(1-t){\mathbf v}\|
\leq \|t{\mathbf u}\|+\|(1-t){\mathbf v}\|
=t\|{\mathbf u}\|+(1-t)\|{\mathbf v}\|<1\\
&\Rightarrow t{\mathbf u}+(1-t){\mathbf v}\in D
\end{align*}
Thus $D$ is convex.

In a similar manner
\begin{align*}
&{\mathbf u},{\mathbf v}\in \bar{D}
\Rightarrow \|{\mathbf u}\|,\|{\mathbf v}\|\leq 1\\
&\Rightarrow \|t{\mathbf u}+(1-t){\mathbf v}\|
\leq \|t{\mathbf u}\|+\|(1-t){\mathbf v}\|
=t\|{\mathbf u}\|+(1-t)\|{\mathbf v}\|\leq 1\\
&\Rightarrow t{\mathbf u}+(1-t){\mathbf v}\in \bar{D}
\end{align*}
Thus $\bar{D}$ is convex.

(iii) If $0<k<1$ then $(k^{1/2},k^{1/2})\in H_{k}\cap D$
so $H_{k}\cap D\neq\emptyset$.

However if $k\geq 1$
\[(x,y)\in H_{k}\Rightarrow xy\geq 1\Rightarrow x^{2}=y^{2}\geq 2
\Rightarrow (x,y)\notin D.\]
so $H_{k}\cap D=\emptyset$.

(iv) Set $x^{*}=y^{*}=1$. Then $(x^{*},y^{*})\in \bar{D}$
and
\[x^{*}y^{*}=1\geq\frac{x^{2}+y^{2}}{2}=xy\]
for all $(x,y)\in \bar{D}$ with $x,y\geq 0$.
\newpage\section*{Exercise~\ref{E;proof bargain}}
(i) We may take $(x_{0},y_{0})=(0,0)$ since
\[\tilde{K}=\{(x-x_{0},y-y_{0})\,:\,(x,y)\in K\}\]
is also a closed convex set such that

(a) Whenever $(x,y)\in \tilde{K}$ we have
$x,y\leq M+|x_{0}|+|y_{0}|$,

(b) $(x_{1}-x_{0},y_{1}-y_{0})\in \tilde{K}$
and $x_{1}-x_{0}\geq 0$, $y_{1}-y_{0}\geq 0$.

(ii) Suppose $(x^{*},y^{*}),(x^{**},y^{**})\in K$ distinct 
and $x^{*}y^{*}=x^{**}y^{**}=k$.
Then
\[\big(\tfrac{1}{2}(x^{*}+x^{**}),\tfrac{1}{2}(y^{*}+y^{**})\big)
=\tfrac{1}{2}(x^{*},y^{*})+\tfrac{1}{2}(x^{**},y^{**})\in K\]
but
\begin{align*}
\tfrac{1}{2}(x^{*}+x^{**})\times\tfrac{1}{2}(y^{*}+y^{**})
&=\tfrac{1}{4}(x^{*}y^{*}+x^{**}y^{**}+x^{*}y^{**}+x^{**}y^{*})\\
&=\frac{k}{4}\left(2+\frac{x^{*}}{x^{**}}+\frac{x^{**}}{x^{*}}\right)\\
&=k+k\left(\left(\frac{x^{*}}{x^{**}}\right)^{1/2}-
\left(\frac{x^{**}}{x^{*}})\right)^{1/2}\right)^{2}\\
&>0
\end{align*}
unless
\[\left(\frac{x^{*}}{x^{**}}\right)^{1/2}-
\left(\frac{x^{**}}{x^{*}}\right)^{1/2}=0\]
that is to say $x^{*}=x^{**}$ and so $y^{*}=y^{**}$.
Thus the point $(x^{*},y^{*})$ is unique if it exists.

(iii) Since $(0,0)\in K$, $0\in E$, condition~(i) tells
us that $e\in E$ implies $e\leq M^{2}$.

(iv) By the definition of the supremum we can find
$k_{n}\in E$ with $k_{n}\rightarrow k$.
Choose $(x_{n},y_{n})\in K$ with $x_{n},y_{n}\geq 0$
such that $x_{n}y_{n}=k_{n}$.

(v) We know that $0\leq x_{n}\leq M$ so we 
by the theorem of Bolzano--Weierstrass we may find
a subsequence $m(j)\rightarrow \infty$ and
an $x^{*}\in{\mathbb R}$ such that $x_{m(j)}\rightarrow x^{*}$.
We can now find a subsequence $n(j)=m(j(k))$ of the $m(j)$
with $n(j)\rightarrow \infty$ and
a $y^{*}\in{\mathbb R}$ such that $y_{n(j)}\rightarrow y^{*}$.

(vi) Now  $x_{n(j)}\rightarrow x^{*}$. Since $x_{n(j)}\geq 0$
$x^{*}\geq 0$. Similarly $y^{*}\geq 0$.
Since $K$ is closed $(x^{*},y^{*})\in K$.
By continuity
$x^{*}y^{*}=k$ so
\[xy\leq k= x^{*}y^{*}\]
whenever $(x,y)\in K$ and $x,\,y\geq 0$.
\newpage\section*{Exercise~\ref{E;advertising war}}
If we set $X=x+3$, $Y=y+1$, we see that we must solve the
bargaining problem for $X+Y\leq 13$. By symmetry
and Peano we know that $X=Y=13/2$ so $x=7/2$ and $y=11/2$
represent the Nash solution. Since $B$ makes $1$ from
the new arrangement, $A$ must pay $B$ an extra $9/2$.
 
\newpage\section*{Exercise~\ref{E;Jules}}
(i) The expected outcome for each is
\begin{align*}
f(q)&=-100q^{2}-5q(1-q)+5(1-q)q-(1-q)^{2}\\
&=-1+2q-101q^{2}=-101(q-101^{-1})^{2}+101^{-2}-1
\end{align*}
which is maximised by taking $q=1/101$.

(ii) Since the situation is symmetric between Jules
and Jim, the Nash solution will be, so $p_{3}=p_{4}$.
If they decide on a choice with $p_{j}=q_{j}$
and $q_{2}>0$. Then $p_{1}=q_{2}+q_{4}$, $p_{2}=q_{2}$,
$p_{2}=0$ will make them happier. Thus for the Nash solution
$p_{2}=0$, $p_{3}=p_{4}$.

For both suggested status quo points the only
point in the quadrant $\{(x,y)\,:\,x,y\geq 0\}$
is $p_{3}=p_{4}=1/2$ so this is the Nash solution
(with $p_{1}=p_{2}=0$).

(iii) Exactly as in~(ii) we are looking for 
a solution $p_{3}=p_{4}=x$, $p_{2}=0$
$p_{1}=1-2x$ with $0\leq x\leq 1/2$
which maximises
\[x(5+a)-(1-2x)=x(7+a)-1.\]
If $a>-7$ we want $x=1/2$ and $p_{3}=p_{4}=1/2$ 
(with $p_{1}=p_{2}=0$).
If $a<-7$ we want $x=0$ and $p_{2}=1$, $p_{1}=p_{3}=p_{4}=0$
so both always swerve.
\newpage\section*{Exercise~\ref{E;Nash prisoners}}
Since the situation is symmetric between the two
prisoners, the  Nash solution will be symmetric
ie both confess with probability $p$, one or
other confess with probability $q$, and neither confess
with probability $1-2q-p$.

The expected sentence for each is then
\[-2p-3q+0q-(1-p-2q)=-1-p-q\]
which is minimised by taking $p=q=0$ and both keeping stum.
\newpage\section*{Exercise~\ref{E;higher hankerchief}}
We need the following result.

\noindent{\bf Theorem}  Let 
\begin{gather*}
\bar{B}=\{(x,y,z \in{\mathbb R}^{3}\,:\,x^{2}+y^{2}+z^{2}\leq 1\}\\
\partial B=\{(x,y,z)\in{\mathbb R}^{3}\,:\,x^{2}+y^{2}+z^{2}= 1\}.\
\end{gather*}
We cannot find a continuous function $F:\bar{B}\rightarrow\partial B$
with $F(x,y,z)=(x,y,z)$ for all $(x,y,z)\in\partial B$.

We now prove Theorem~\ref{T;fix 3}.

Suppose that $f:\bar{B}\rightarrow \bar{B}$ is a continuous
function with no fixed point,
that is to say that $f({\mathbf x})\neq {\mathbf x}$
for all ${\mathbf x}\in \bar{B}$.

We can now define a function $F:\bar{B}\rightarrow\partial D$
by the recipe `starting at $f({\mathbf x})$, draw a line
through ${\mathbf x}$ and continue it until it cuts
the boundary $\partial D$ at $F({\mathbf x})$'.

Observe that, if we make a small change in ${\mathbf x}$,
there will only be a small change in $f({\mathbf x})$
(since $f$ is continuous) and so only a small change
in $F({\mathbf x})$. Thus $F$ is continuous.
By construction, $F({\mathbf x})={\mathbf x}$ for all 
${\mathbf x}\in\partial B$ and we have a contradiction
with the result of with our first theorem.

Thus no $f$ of the type described 
can exist and the result follows.

The generalisations are immediate.

\noindent{\bf Theorem}  Let 
\begin{gather*}
\bar{B}=\{({\mathbf x} \in{\mathbb R}^{n}\,:\,\|{\mathbf x}\|\leq 1\}\\
\partial B=\{({\mathbf x} \in{\mathbb R}^{n}\,:\,\|{\mathbf x}\|=1\}.\
\end{gather*}
We cannot find a continuous function $F:\bar{B}\rightarrow\partial B$
with $F({\mathbf x})={\mathbf x}$ for all ${\mathbf x}\in\partial B$.

\noindent{\bf Theorem}
We the notation as before
if $f:\bar{B}\rightarrow \bar{B}$ is continuous, then there is
an $({\mathbf x})\in \bar{B}$ such that $f({\mathbf x})=({\mathbf x})$.


\newpage\section*{Exercise~\ref{E;rubber ball}}
We go directly to general, the result for $3$ being obtained by
setting $n=3$.

\noindent{\bf Lemma}
Let
\[\bar{B}=\{({\mathbf x} \in{\mathbb R}^{n}\,:\,\|{\mathbf x}\|\leq 1\}.\]
Suppose that $E$ is a set in ${\mathbf R}^{n}$
such that there exist continuous functions
$h_{1}:\bar{B}\rightarrow E$ and  $h_{2}:E\rightarrow \bar{B}$
with the properties that
\begin{align*}
h_{2}\big(h_{1}({\mathbf x})\big)={\mathbf x}
&\ \text{for all ${\mathbf x}\in \bar{B}$}\\
h_{1}\big(h_{2}({\mathbf u})\big)={\mathbf u}
&\ \text{for all ${\mathbf u}\in E$}.
\end{align*}
Then, if $h:E\rightarrow E$ is continuous, there is
an ${\mathbf u}_{0}\in E$ such that $h({\mathbf u}_{0})
={\mathbf u}_{0}$.

The proof runs unaltered.

If we set
\[f({\mathbf x})=h_{2}\Big(f\big(h_{1}({\mathbf x})\big)\Big),\]
then $f$ is a continuous function from $\bar{B}$ to $\bar{B}$
and so has a fixed point ${\mathbf x}_{0}$.
Set ${\mathbf u}_{0}=h_{2}({\mathbf x}_{0})$. Then
\[g({\mathbf u}_{0})=g\big(h_{2}({\mathbf x}_{0})\big)
=h_{2}\Bigg(h_{1}\bigg(h_{2}\Big(g\big(h_{1}({\mathbf x}_{0})
\big)\Big)\bigg)\Bigg)=h_{2}\big(f({\mathbf x}_{0})\big)
={\mathbf u}_{0}.\]

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;two by two Nash}$^{*}$}
\newpage\section*{Exercise~\ref{E;many equilibrium}}
Write 
\[{\mathbb R}_{+}=\{x\in{\mathbb R}\,:\,x\geq 0\}\]
Consider the set
\[E=\left\{({\mathbf p},{\mathbf q},{\mathbf r})\,:\,
{\mathbf p}\in{\mathbb R}_{+}^{n},{\mathbf q}\in{\mathbb R}_{+}^{m},
{\mathbf r}\in{\mathbb R}_{+}^{l},
\sum_{i=1}^{n}p_{i}=\sum_{j=1}^{m}q_{j}=\sum_{k=1}^{l}q_{k}
\right\}.\]
We observe that $E$ is a bounded closed convex subset of
${\mathbb R}^{n+m+l}$.

Let $p^{[i]}_{j}=1$ for $i=j$, $p^{[i]}_{j}=0$ otherwise.
Define
\[u_{i}({\mathbf p},{\mathbf q},{\mathbf r})
=\max(0,\alpha({\mathbf p}^{[i]}{\mathbf q},{\mathbf r})
-\alpha({\mathbf p},{\mathbf q},{\mathbf r})\]
and
\begin{align*}
v_{j}&=({\mathbf p},{\mathbf q},{\mathbf r})
=\max(0,\alpha({\mathbf p},{\mathbf q}^{[j]},{\mathbf r})
-\alpha({\mathbf p},{\mathbf q},{\mathbf r})\\
w_{k}&=({\mathbf p},{\mathbf q},{\mathbf r})
=\max(0,\alpha({\mathbf p},{\mathbf q},{\mathbf r})
-\alpha({\mathbf p},{\mathbf q},{\mathbf r}^{[k]})
\end{align*}
similarly.


We now set 
$h({\mathbf p},{\mathbf q},{\mathbf r})
=({\mathbf p}',{\mathbf q}',{\mathbf r}')$
where
\begin{align*}
p_{i}'&=\frac{p_{i}+u_{i}({\mathbf p},{\mathbf q},{\mathbf r})}
{1+\sum_{s=1}^{n}u_{s}({\mathbf p},{\mathbf q},{\mathbf r})}\\
q_{j}'&=\frac{q_{j}+v_{j}({\mathbf p},{\mathbf q},{\mathbf r})}
{1+\sum_{t=1}^{m}v_{t}({\mathbf p},{\mathbf q},{\mathbf r})}\\
r_{k}'&=\frac{r_{k}+w_{k}({\mathbf p},{\mathbf q},{\mathbf r})}
{1+\sum_{d=1}^{m}w_{d}({\mathbf p},{\mathbf q},{\mathbf r})}.
\end{align*}

We observe that $h$ maps $E$ to $E$ and $h$ is continuous
so $h$ has a fixed point 
$({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})$.

Suppose, if possible, that
\[\alpha({\mathbf p}^{[i]},{\mathbf q}^{*},{\mathbf r}^{*})
>\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\ \text{whenever $p^{*}_{i}>0$}.\]
Then
\[p^{*}_{i}
\alpha({\mathbf p}^{[i]},{\mathbf q}^{*},{\mathbf r}^{*})\geq
p^{*}_{i}\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\ \text{for all $i$}\]
and
\[p^{*}_{i_{0}}
\alpha({\mathbf p}^{[i_{0}]},{\mathbf q}^{*},{\mathbf r}^{*})>
p^{*}_{i_{0}}
\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\ \text{for some $i_{0}$}\]
so
\[\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
=\sum_{i=1}^{n}p_{i}^{*}
\alpha({\mathbf p}^{[i]},{\mathbf q}^{*},{\mathbf r}^{*})
>\sum_{i=1}^{n}p_{i}^{*}
\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
=\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})\]
which is absurd. Thus our original assumption must be wrong
and there must be some $i_{1}$ with
\[\alpha({\mathbf p}^{[i_{1}]},{\mathbf q}^{*},{\mathbf r}^{*})
\leq \alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\ \text{and $p^{*}_{i_{1}}>0$}.\]
Without loss of generality and to fix ideas, we suppose $i_{1}=1$.

We now know that
\[\alpha({\mathbf p}^{[1]},{\mathbf q}^{*},{\mathbf r}^{*})
\leq \alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\ \text{and $p^{*}_{1}>0$}\]
and so
\[u_{1}({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
=\max\big(0,\alpha({\mathbf p}^{[1]},{\mathbf q}^{*},{\mathbf r}^{*}
-\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})\big)=0.\]
Thus, by the definition of $h$,
\[
p^{*}_{1}=\frac{p_{1}^{*}+
u_{1}({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})}
{1+\sum_{i=1}^{n}u_{i}({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})}\\
=\frac{p_{1}^{*}}
{1+\sum_{i=1}^{n}u_{i}({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})}.
\]
Since $p^{*}_{1}>0$, it follows that
\[\sum_{i=1}^{n}u_{i}({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})=0\]
and so 
$u_{i}({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})=0$ for all $i$.

Thus 
\[\alpha({\mathbf p}^{[i]},{\mathbf q}^{*},{\mathbf r}^{*})\leq
\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})\]
for all $i$ and so
\[
\alpha({\mathbf p},{\mathbf q}^{*},{\mathbf r}^{*})
=\sum_{i=1}^{n}p_{i}\alpha({\mathbf p}^{[i]},{\mathbf q}^{*},{\mathbf r}^{*})
\leq 
\sum_{i=1}^{n}p_{i}\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
=\alpha({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\]
for all possible choices of ${\mathbf p}$.

The same argument shows that
\begin{align*}
\beta({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\geq \beta({\mathbf p}^{*},{\mathbf q},{\mathbf r}^{*})&
\ \text{for all ${\mathbf q}$},\\
\gamma({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r}^{*})
\geq \gamma({\mathbf p}^{*},{\mathbf q}^{*},{\mathbf r})&
\ \text{for all ${\mathbf r}$}.
\end{align*}
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;many Nash}$^{*}$}
\newpage\section*{Exercise~\ref{E;general traffic}}
Suppose that Albert is driving one car and Bertha the other.
If Albert chooses left with probability $p$ 
and right with probability $1-p$ whilst Bertha
chooses left with probability $q$ 
and right with probability $1-q$, then the expected value
of the game to Albert is
\[\alpha(p,q)=apq-p(1-q)-q(1-p)=(a+2)pq-p-q=\big((a+2)q-1\big)p-q.\]
If $a>-1$ then writing $q_{0}=1/(a+2)$
\begin{align*}
\text{if $q>q_{0}$, then}
\ &\alpha(1,q)>\alpha(p,q)\ \text{for all $1>p\geq 0$}\\
\text{if $q<q_{0}$, then}
\ &\alpha(0,q)>\alpha(p,q)\ \text{for all $1\geq p>0$}.
\end{align*}
In addition, we observe that
$\alpha(q_{0},q_{0})=\alpha(p,q_{0})$
for all $p$. Since similar results apply for Bertha, we see that
there are exactly three Nash equilibrium points $(p,q)=(0,0)$
with expected value to each the players of $0$,
$(p,q)=(1,1)$ with expected value to each the players of $a$
and $(p,q)=(q_{0},q_{0})$ with expected value to the two players
of  $-q_{0}$.

If $a=-1$ then
\[\alpha(p,q)=(q-1)p-q,\]
and
\[\text{if $q<1$, then}
\ \alpha(0,q)>\alpha(p,q)\ \text{for all $1\geq p>0$}.\]
and $\alpha(p,1)=-1$ for all $p$.
Since similar results apply for Bertha, we see that
there are exactly two Nash equilibrium points $(p,q)=(0,0)$
with expected value to each the players of $0$
and $(p,q)=(1,1)$ with expected value $-1$.

If $a<-1$ then, since
\[\alpha(p,q)=apq-p(1-q)-q(1-p)=(a+2)pq-p-q=\big((a+2)q-1\big)p-q,\]
we have
\[\alpha(0,q)>\alpha(p,q)\ \text{for all $1\geq p>0$ and all $q$}.\]
Since similar results apply for Bertha, we see that
there is only one Nash equilibrium point $(p,q)=(0,0)$
with expected value to each the players of $0$.
\newpage\section*{Exercise~\ref{E;Nash traffic}}
Suppose that Albert is driving the row car.
He chooses left with probability $p$
and Bertha (driving the column car) 
chooses left with probability $q$.
The expected value of the game to Bertha
is
\[\alpha(p,q)=p(aq-(1-q))+(1-p)(-q+0)=(q(a+2)-1)p-q.\]
If $a\geq-1$, then
\begin{gather*}
\text{if $q>(2+a)^{-1}$ then $\beta(1,q)>\beta(p,q)$ for all $1>p\geq 0$}\\
\text{if $q<(2+a)^{-1}$ then $\beta(0,q)>\beta(p,q)$ for all $1\geq p> 0$}\\
\text{if $q=(2+a)^{-1}$ then $\beta(0,q)=\beta(p,q)$ for all $1\geq p\geq 0$}\\
\end{gather*}
Since similar results hold for Bertha,
there are three Nash equilibrium points 
$(p,q)=(0,0)$ with expected value to Albert of $a$
and to Bertha of $0$, $(p,q)=(1,1)$ 
with expected value to Albert of $0$
and to Bertha of $a$ and
$(p,q)=(1-(2+a))^{-1},(2+a)^{-1})$ with expected value
to both players of $-(2+a)^{-1})$.

If $a<-1$
then
\[
\text{$\beta(0,q)>\beta(p,q)$ for all $1\geq p> 0$}
\]
and, since similar results hold for Bertha,
there is one Nash equilibrium point
$(p,q)=(0,1)$ with expected value to Albert of $-1$
and to Bertha of $-1$
\newpage\section*{Exercise~\ref{E;two easy Nash}}
If the value to Row of the various possibilities is given by
\[\left(
\begin{matrix}a&b\\c&d\end{matrix}
\right)\]
then if Row plays first row with probability $p$
and Column plays first column with probability $q$
the expected value of the game to Row is
\begin{align*}
\rho(p,q)&=apq+bp(1-q)+c(1-p)q+d(1-p)(1-q)\\
&=Apq+Bp+Cq+D=(Aq+B)p+Cq+D.
\end{align*}
Similarly the expected value of the game to Column
is
\[\kappa(p,q)=(\alpha p+\beta)q+\gamma p+\delta\] 


If $A+B,B>0$ then
\[\rho(1,q)>\rho(p,q)\ \text{for all $1>p\geq 0$}\]
and we set $p^{*}=1$. If $\alpha +\beta\geq 0$ we set
$q^{*}=1$, if $\alpha +\beta<0$ we set $q^{*}=0$
By inspection we have Nash equilibrium at $(p^{*},q^{*})$.

If $A+B,B<0$ then
\[\rho(1,q)>\rho(p,q)\ \text{for all $1>p\geq 0$}\]
and we set $p^{*}=0$. If $\beta\geq 0$ we set
$q^{*}=1$, if $\alpha<0$ we set $q^{*}=0$.
By inspection we have Nash equilibrium at $(p^{*},q^{*})$.

If $A+B$ and $B$ do not have the same sign but $\alpha+\beta$
and $\alpha$ do we interchange to role of row and column.

In the remaining cases $A+B$ and $B$ do not have the same sign
and $\alpha+\beta$ and $\beta$ do not have the same sign
then, taking $p^{*}=-\beta/\alpha$, we see that
$\kappa(p^{*},q)$ does not depend on $q$
and, taking  $q^{*}=-B/A$, we see that
$\rho(p,q^{*})$ does not depend on $q$.
Thus $(p^{*},q^{*})$ is a Nash equilibrium point.


\newpage\section*{Exercise~\ref{E;Hawks}}
(ii) As $D$ becomes large (so the costs of fighting become large)
$p$ and $q$ become small so the players become
more and more dovelike (but it is still worth an occasional
hawk play) and the expected payoff 
\[\frac{V(D-V)}{2D}=\frac{V}{2}\left(1-\frac{V}{D}\right)
\rightarrow \frac{V}{2}\]
the dove pair payoff.

As $D\rightarrow V+$ the rewards of being a hawk against a dove
remain high but the cost of being a hawk against a hawk diminishes
towards zero. $p,q\rightarrow 1$ so the players play
dove less and less often and the expected payoff 
\[\frac{V(D-V)}{2D}=\frac{V}{2}\left(1-\frac{V}{D}\right)\
\rightarrow 0\]
the payoff for two hawks when the cost of fighting equals
the reward.

(iii) If $V=D$ then, with the notation of the previous paragraphs
\[\alpha(p,q)=\frac{V-Dq}{2}p+\frac{V}{2}(1-q)\]
so if $q\neq 1$
\[\alpha(1,q)>\alpha(p,q)\ \text{for $1>p\geq 0$}.\]
The only Nash equilibrium point is $(p,q)=(1,1)$
and the payoff for both players is then $0$.


\newpage\section*{Exercise~\ref{E;lefters}}
(i) Since there are slightly more lefters than righters
a righter is more likely to collide (with a lefter)
than a lefter (with a righter). The average lefter
will collect fewer damage points and outbreed the
average righter by a bit. Thus the next generation
will contain a higher proportion of lefters and
the selective pressures against righters will increase.
Eventually the flock will consist of lefters
(who will then write books on the obvious merits
of lefters as demonstrated by their success against righters).

If here are slightly more righters than 
lefters the reverse process will take place.
 
(ii) If the proportion of lefters in the population
is $p$ then, roughly speaking, the average breeding points
a lefter will collect will be
\[L(p)=A\big(pa-(1-p)\big)\]
and the average number that a righter will
collect will be
\[R(p)=-Ap.\]
Now
\[
L(p)-R(p)=A(p(a+2)-1).\]

If $a\leq -1$ so $(a+2)\leq 1$ then $L(p)<R(p)$ for all $0<p\leq 1$
so lefters will die out. 


If $a>-1$ then taking $p^{*}=(a+2)^{-1}$
(and observing that $L(p)-R(p)$ increases as $p$ increases
and decreases as $p$ decreases) we see that if a some stage $p$ is
at least a bit larger than $p^{*}$ the lefters will eventually take over,
but if $p$ is
at least a bit smaller
than $p^{*}$ the righters will.
\newpage\section*{Exercise~\ref{E;bourgeois}}
If we release a few bourgeois into a flock of
doves then since bourgeois
on average, do better than doves
in an encounter with a dove and
better than doves, 
in an encounter with
other bourgeois
the bourgeois are likely to replace the doves.
 
If we release a few bourgeois into a flock of
hawks then since bourgeois
on average do better than hawks
in an encounter with a hawks and
better than hawks
in an encounter with
other bourgeois,
the bourgeois are likely to replace the hawks. 
\newpage\section*{Exercise~\ref{E;cemetery}}
Suppose that the distance to the cemetery is $x$ yards
and $B$ drives at speed $u$ yards an hour.
If $A$ sets of at time $0$, then
$A$ arrives after a time $x/(4u)$ and $B$
after a time $(x-100)/u$. Thus
\[\frac{x}{4u}<\frac{x-100}{u}.\]
Simplifying, we get 
\[x<4x-400\]
so $3x>400$ and $x>133\tfrac{1}{3}$.

\newpage\section*{Exercise~\ref{E;hare}}
Let us take the time when the race starts to be $0$
The hare overtakes the tortoise half a kilometre
from the starting post at time $1/(2v)$ so
the hare has travelled a distance 
\[\left(\frac{1}{2v}-\frac{1}{2}\right).\]
Thus
\[\left(\frac{1}{2v}-\frac{1}{2}\right)V=\frac{1}{2}\]
and
\begin{equation*}\tag{1}
\frac{1}{v}-\frac{1}{V}=1.
\end{equation*}

At the second meeting the tortoise has travelled $X-\tfrac{5}{4}$
in a time $T=(X-\tfrac{5}{4})/v$ and the hare has travelled
$X+\tfrac{5}{4}$ running for $T-1$ hours.
Thus
\[\left(\left(X-\frac{5}{4}\right)\frac{1}{v}-1\right)V
=X+\frac{5}{4}\]
and so
\begin{equation*}\tag{2}
\left(X-\frac{5}{4}\right)\frac{1}{v}
-\left(X+\frac{5}{4}\right)\frac{1}{V}=1.
\end{equation*}
Substituting in $(2)$ from $(1)$ we get
\[\left(X-\frac{5}{4}\right)\left(1-\frac{1}{V}\right)
-\left(X+\frac{5}{4}\right)\frac{1}{V}=1.\]
Simplifying gives
\[\left(X-\frac{5}{4}\right)-\frac{5}{2V}=1\]
so
\[V=\frac{10}{4X-9}.\]
 
We have
\[\frac{1}{v}=1+\frac{1}{V}=1+\frac{4X-9}{10}=\frac{4X+1}{10}\]
and so
\[v=\frac{1}{4X-9}.\]

The hare runs $1/2$ hours to cover a distance $2X$
so
\[\frac{5}{4X-9}=\frac{V}{2}=2X\]
and
\[8X^{2}-18X-5=0.\]
Thus
\[X=\frac{9\pm\sqrt{9^{2}+40}}{8}=\frac{9\pm 11}{8}.\]
Since $X>0$ we have $X=20/8=5/2$.

The tortoise travels at $1$ kilometre per hour
and will take $5/2$ hours to reach the cabbage patch.

\newpage\section*{Exercise~\ref{E;duel 1}}
(i) [Note this part of the execise has been changed in the corrections]
If $b\leq 1/4$, then $c\leq 1/4$ so $3b+c(1-b)^{2}<1$.
If $b\geq 1/3$, then $3b+c(1-b)^{2}>1.$

(ii) If $C$ misses on his first shot, then 
either $B$ hits $A$ and $C$ has first shot in a two sided
duel against $A$ or $B$ misses $A$ and $C$ has first shot in a two sided
duel against $B$. In either case $C$ has a probability $c$ of hitting
his remaining opponent with his first shot and becoming
outright winner.

(iii) If $b$ and $c$ are very small then, with high probability,
$C$ misses $A$ (by accident or design), $B$ misses $A$,
$A$ hits $B$,
$C$ misses $A$ and $A$ hits $C$ so winning outright.

If $b$ is very close to $1$ and $c$ is very small
then, with high probability,
$C$ misses $A$ (by accident or design), $B$ hits $A$,
$C$ misses $B$ and $B$ hits $C$ so winning outright.

If $b$ and $c$ are very close to $1$
then, with high probability,
$C$ misses $A$ (by design), $B$ hits $A$,
and $C$ hits $B$ so winning outright.

The verbal arguments can be verified algebraically
but there is no need to do so.

\newpage\section*{Exercise~\ref{E;duel 2}}
(i) Since $pq$ is very small compared with $p+q$
the probability that $P$ wins if she shoots first
\[\frac{p}{p+q-pq}\approx\frac{p}{p+q}.\]
Since $q$ is small compared with $1$,
the probability that $P$ wins if she shoots second
\[\frac{(1-q)p}{p+q-pq}\approx\frac{p}{p+q}.\]

Since $P$ will probably miss with her first shot it makes
it makes little difference
whether she shoots first or second.

(ii) Since the order of firing in the two-sided duel
now makes little difference the participants simply
want to make sure that they are faced with the weakest
possible opponent in that duel. Thus everyone will fire
at the strongest player who is not themselves
(thus $A$ fires at $B$ while $B$ and $C$ fire at $A$).

Since $a$, $b$ and $c$ are small $A$ is in effect
engaging in a two-sided duel in which he has probability
$b$ of hitting and his opponent has probability $b+c$
of hitting him. The probability of $A$ surviving this duel
is approximately $a/(a+b+c)$. If he survives, he must now duel $C$ with
a probability approximately $a/(a+c)$ of surviving to win.
His chances of winning outright is thus about
\[P_{A}=\frac{a}{a+b+c}\times\frac{a}{a+c}=\frac{a^{2}}{(a+b+c)(a+c)}.\]

The probability of $A$ not surviving the first duel is
$(b+c)/(a+b+c)$. If $A$ does not survive, then $B$ and $C$ duel with
$B$ having a probability $b/(b+c)$ of winning. Thus
$B$ has approximate probability
\[P_{B}=\frac{b+c}{a+b+c}\times\frac{b}{b+c}=\frac{b}{a+b+c}.\]
of winning outright.

The probability of $C$ winning outright is approximately
\begin{align*}
P_{C}&=1-\Pr(\text{$A$ wins})-\Pr(\text{$B$ wins})\\
&=1-\frac{a^{2}}{(a+b+c)(a+c)}-\frac{b}{a+b+c}\\
&=\frac{2ac+c^{2}}{(a+b+c)(a+c)}
\end{align*}

(iii) We have
\begin{align*}
1&=\frac{a^{2}}{(a+0+0)(a+0)}> \frac{a^{2}}{(a+b+c)(a+c)}\\
&> \frac{a^{2}}{(a+a+a)(a+a)}=\frac{1}{6}.
\end{align*}
If $a$ is fixed,
$P_{A}\rightarrow 1$ as $b,\ c\rightarrow 0$.
If $A$ is much better than $B$ and $C$ then
he is likely to win. If $A$, $B$ and $C$ 
have approximately equal skill then
$A$ must engage in a duel in which he has one shot for every two of his
more or less equally opponents so two out of every three
paintballs are aimed at him and he has probability about $1/3$
of surviving. If he survives then he faces a duel on more or less 
equal terms for which his survival probability is about $1/2$
thus his worse case chances are about $1/3\times1/2=1/6$.

We have
\[\frac{1}{2}>\frac{b}{a+b}>\frac{b}{a+b+c}>0.\]
If $a$ is fixed, $P_{B}\rightarrow 0$ as $b,\,c\rightarrow 0$,
$P_{B}\rightarrow 1/2$ as $b\rightarrow a$, $c\rightarrow 0$.
Thus $P_{B}$ can take all values between $1/2$ and $0$.
$B$'s best chance is if he his almost as good as
$A$ so has chance about $1/2$ of surviving to duel with $C$.
If $C$ is incompetent $B$'s chance of triumph remains $1/2$.
If $P_{A}$ is close to $1$, $P_{B}$ must be close to $0$.

We have
\begin{align*}
\frac{1}{2}&=\frac{2a^{2}+a^{2}}{(a+2a)(a+a)}
&>\frac{2ac+c^{2}}{(a+2c)(a+c)}>\frac{2ac+c^{2}}{(a+b+c)(a+c)}>0
\end{align*}
$C$ will always survive to the second duel where
his best chance is to be almost as skilled as his opponent
in which his chance of triumph is almost $1/2$ so
$C$'s best case is when $A$, $B$ and $C$ are almost equally
skilled. If $P_{A}$ is close to $1$, $P_{C}$ must be close to $0$.
\newpage\section*{Exercise~\ref{E;fly}}
(i) The fly is approaching $B$ at speed $c+b$ so
it takes time
\[t_{A}(x)=\frac{x}{c+b}.\]
to reach $B$. The cyclists are approaching each other
at speed $a+b$ so the distance apart of the cyclists
when the fly reaches $B$ is
\[D_{A}=x-\frac{x}{c+b}\times{a+b}=\frac{c-a}{c+b}x.\]

(ii) We have
\[S_{A}(x)=d_{A}(x)+S_{B}(D_{A}(x)),
\ S_{B}(x)=d_{B}(x)+S_{A}(D_{B}(x))\]
so
\[S_{A}(x)=ct_{A}+S_{B}\left(\frac{c-a}{c+b}x\right)
=\frac{cx}{c+b}+S_{B}\left(\frac{c-a}{c+b}x\right)\]
and
\[S_{B}(x)=\frac{cx}{c+a}+S_{B}\left(\frac{c-b}{c+a}x\right).\]
Thus
\[S_{A}(x)=\frac{cx}{c+b}+\frac{c(c-a)x}{(c+a)(c+b)}
+S_{A}\left(\frac{(c-a)(c-b)}{(c+b)(c+a)}x\right)\]
Now $S_{A}(x)=xS_{A}(1)$ so writing $SA(1)=A_{1}$
\[\left(1-\frac{(c-a)(c-b)}{(c+b)(c+a)}\right)S_{1}
=\frac{c}{c+b}+\frac{c(c-a)}{(c+a)(c+b)}\]
so
\[\big((c+a)(c+b)-(c-a)(c-b)\big)S_{1}=c(c+a)+c(c-a)\]
and
\[2(a+b)cS_{1}=2c^{2}\]
whence
\[S_{1}=\frac{c}{a+b}, S_{A}(x)=\frac{cx}{a+b}.\]

(iii) We have
\begin{align*}
S_{A}(x)&=\left(\frac{cx}{c+b}+\frac{c(c-a)x}{(c+a)(c+b)}\right)
\sum_{j=0}^{\infty}\left(\frac{(c-a)(c-b)}{(c+b)(c+a)}\right)^{j}\\
&=\frac{2c^{2}x}{(c+a)(c+b)}
\left(1-\frac{(c-a)(c-b)}{(c+b)(c+a)}\right)^{-1}\\
&=\frac{cx}{a+b}.
\end{align*}

(iv) The cyclists meet after a time $x/(a+b)$ and the fly has flown
$cx/(a+b)$.

\newpage\section*{Exercise~\ref{E;craps}} (Corrected by Matthew Towers)
If on each throw there is a probability $a$ of you winning and
a probability $b$ of the banker winning 
and $1-a-b$ of no decision your probability
$p$ of ultimately winning is given by
\[p=a+(1-a-b)p\]
ie $p=a/(a+b)$ the probability of throwing a $7$ or $11$
is $(6+2)/36=8/36$.

If you roll $k\neq 2,3,7,11,12$ your chances of winning
a particular throw are $a=r(k)/36$ and of the banker winning
is $b=1/6$
are as follows
\begin{tabular}{c|c|c}
    $k$ & $r$ & win probability \\
    \hline
    4 & 3 & $1/3$ \\
    5 & 4 & $2/5$ \\
    6 & 5 & $5/11$ \\
    8 & 5 & $5/11$ \\
    9 & 4 & $2/5$ \\
    10 & 3 & $1/3$
\end{tabular}
so your win probability for the full game is
\begin{align*}                                                                          
    P(\text{win}) &= P(\text{win}|\text{initial roll 7, 11})(8/36) \\                   
                  & \phantom{=}+P(\text{win}|\text{initial roll 2, 3,                   
                  12})(4/36) \\                                                         
                  & \phantom{=}+P(\text{win}|\text{initial roll not 2, 3, 7,            
                  11, 12})(24/36) \\                                                    
                  &= 8/36 + 0 + (24/36)(2\cdot (3/24) \cdot (1/3) +                     
                  2\cdot (4/24)\cdot (2/5) + 2 \cdot (5/24) \cdot                       
                  (5/11)) \\                                                            
                  &= 244/495 \approx 0.493                                              
\end{align*}
where $2(3/24)(1/3)$ is for 4 or 10, $2(4/24)(2/5)$ is 5 or 9, and
$2(5/24)(5/11)$ is 6 or 8. Matthew adds
`Wikipedia agrees with me, so I must be
right'.


\newpage\section*{Exercise~\ref{E;St Peter}}
\begin{align*}
u_{n}&=\sum_{r=1}^{n}2^{r}\Pr(\text{$r-1$ tails then heads})\\
&=\sum_{r=1}^{n}2{r}2^{-r}=\sum_{r=1}^{n}1=n
\end{align*}


\newpage\section*{Exercise~\ref{E;double}}
(i) We have
\begin{align*}
v_{n}&=-\sum_{r=1}^{n}\Pr(\text{$r-1$ tails then heads})
-(2^{n}-1)\Pr(\text{$n$ tails})\\
&=1-2^{-n}-\sum_{r=1}^{n}2^{-r}=0
\end{align*}

(ii) We have
\begin{align*}
v_{n}&=-\sum_{r=1}^{n}\Pr(\text{$r-1$ tails then heads})\\
&=1-2^{-n}
\end{align*}


\newpage\section*{Exercise~\ref{E;biased Peter}}
We take $>p>0$, $p\neq 1/2$.

First St Petersburg.

\begin{align*}
u_{n}(p)&=\sum_{r=1}^{n}2^{r}\Pr(\text{$r-1$ tails then heads})\\
&=(1-p)\sum_{r=1}^{n}p^{r-1}2^{r}\\
&=2(1-p)\frac{1-(2p)^{n}}{1-2p}\\
&=\frac{2(1-p)}{1-2p}(1-(p/2)^{n})
\end{align*}

If $p>1/2$, $u_{n}(p)\rightarrow\infty$ as $n\rightarrow\infty$.

If $p<1/2$ 
\[u_{n}(p)\rightarrow 2\frac{1-p}{1-2p}\]
and the game is trouble free.

Next Double or Quits with penalty.
\begin{align*}
v_{n}&=-\sum_{r=1}^{n}\Pr(\text{$r-1$ tails then heads})\\
&\qquad\qquad -(2^{n}-1)\Pr(\text{$n$ tails})\\
&=-\sum_{r=1}^{n}(1-p)p^{r-1}+(2^{n}-1)p^{n}\\
&=(p^{n}-1)+(2^{n}-1)p^{n}=(2p)^{n}-1
\end{align*}

If $p<1/2$, $u_{n}(p)\rightarrow -1$ as $n\rightarrow\infty$.

If $p>1/2$, $u_{n}(p)\rightarrow \infty$ as $n\rightarrow\infty$.

Finally Double or Quits without penalty.
\begin{align*}
v_{n}&=-\sum_{r=1}^{n}\Pr(\text{$r-1$ tails then heads})\\
&=-\sum_{r=1}^{n}(1-p)p^{r-1}\\
&=(p^{n}-1)\rightarrow -1
\end{align*}
as $n\rightarrow\infty$.
\newpage\section*{Exercise~\ref{E;Keys}}
Without replacement
\[
\Pr(\text{suceed on $r$th go})=
\begin{cases}
1/n&\text{for $1\leq r\leq n$}\\
0&\text{otherwise.}
\end{cases}
\]
so
\[a_{n}=\sum_{r=1}^{n}r/n=(n+1)/2.\]

Lemma~\ref{L;length game} tells us that $b_{n}=n$
(since with replacement we have probability $1/n$
of getting in on any go independent of what has gone before).

Finally
\begin{align*}
c_{n}&=\sum_{j=1}^{\infty}j\Pr(\text{in on $j$th go})\\
&=\frac{1}{n}+
\sum_{j=2}^{\infty}j\frac{n-1}{n}\left(\frac{n-2}{n-1}\right)^{j-2}
\frac{1}{n-2}\\
&=\frac{1}{n}+
\frac{(n-1)^{2}}{n(n-2)}
\sum_{j=2}^{\infty}j\left(\frac{1}{n-1}\right)^{j}\\
&=\frac{1}{n}+
\frac{(n-1)^{2}}{n(n-2)}
\left(-\frac{1}{n-1}
+\sum_{j=1}^{\infty}j\left(\frac{1}{n-1}\right)^{j}\right)\\
&=\frac{1}{n}+
\frac{(n-1)^{2}}{n(n-2)}
\left(-\frac{1}{n-1}+(n-1)\right)\\
&=(n-1)+\frac{1}{n}
\end{align*}

Thus 
\[\frac{a_{n}}{b_{n}}=\frac{1+n^{-1}}{2}\rightarrow \frac{1}{2}\]
and
\[\frac{b_{n}}{c_{n}}=\frac{1}{1-n^{-1}+n^{-2}}\rightarrow 0\]
as $n\rightarrow \infty$.


\newpage\section*{Exercise~\ref{E;fair to unfair}} 
(i) All tails has probability $1/4$. One head and one
tail (in some order) has probability $1/2$. 
At least one head has probability $3/4$.

(ii) Each particular outcome has probability $1/8$,
so events can have probability $r/8$ and only
those values $[0\leq r\leq 8]$.

(iii) Chose $r$ particular outcomes. If you get
one of those shout heads. If not, tails.
You have probability $r/2^{n}$ of shouting heads.
$[0\leq r\leq 2^{n}]$. If $r=0$ or $r=2^{n}$
you can dispense with the coins and always shout
tails or always shout heads. 
\newpage\section*{Exercise~\ref{E;dyadic induction}}
It is probably easiest to separate existence and uniqueness.

Let $P(n)$ be the statement 
that if 
$0\leq r\leq 2^{n}-1$,
then we can find  $e_{j}\in\{0,1\}$ such that
\[r=e_{1}2^{n-1}+e_{2}2^{n-2}+e_{3}2^{n-3}+\dots+e_{n-1}2+e_{n}.\]

$P(1)$ is true (set $e_{1}=r$).
Suppose $P(n)$ is true and
$0\leq r\leq 2^{n+1}-1$. If $0\leq r\leq 2^{n}-1$
then by the inductive hypothesis
we can find  $d_{j}\in\{0,1\}$ such that
\[r=d_{1}2^{n-1}+d_{2}2^{n-2}+d_{3}2^{n-3}+\dots+d_{n-1}2+d_{n}\]
and so, setting $e_{j}=d_{j-1}$ for $2\leq j\leq n+1$,
$e_{1}=0$ we have $e_{j}\in\{0,1\}$ such that
\[r=e_{1}2^{n}+e_{2}2^{n-1}+e_{3}2^{n-2}+\dots+e_{n}2+e_{n+1}.\]
If not, then $2^{n}\leq r\leq 2^{n+1}-1$
and setting $s=r-2^{n}$ we have
\[0\leq s\leq 2^{n}-1\]
and by the inductive hypothesis
we can find  $d_{j}\in\{0,1\}$ such that
\[r=d_{1}2^{n-1}+d_{2}2^{n-2}+d_{3}2^{n-3}+\dots+d_{n-1}2+d_{n}.\]
Setting $e_{j}=d_{j-1}$ for $2\leq j\leq n+1$,
$e_{1}=1$ we have $e_{j}\in\{0,1\}$ such that
\[r=e_{1}2^{n}+e_{2}2^{n-1}+e_{3}2^{n-2}+\dots+e_{n}2+e_{n+1}.\]
By induction $P(n)$ holds for all $n$.

Let $Q(n)$ be the statement 
that if 
$0\leq r\leq 2^{n}-1$, the expansion
\[r=e_{1}2^{n-1}+e_{2}2^{n-2}+e_{3}2^{n-3}+\dots+e_{n-1}2+e_{n}\]
is unique. $Q(1)$ is true by inspection of cases.

Suppose $Q(n)$ is true and
\begin{align*}
e_{1}2^{n}+e_{2}2^{n-1}&+e_{3}2^{n-3}+\dots+e_{n}2+e_{n+1}\\
&=d_{1}2^{n}+d_{2}2^{n-1}+d_{3}2^{n-3}+\dots+d_{n}2+d_{n+1}
\end{align*}
with $e_{j},d_{j}\in\{0,1\}$.
If $e_{1}=1$, $d_{1}=0$, then
\[
e_{1}2^{n}+e_{2}2^{n-1}+e_{3}2^{n-2}+\dots+e_{n}2+e_{n+1}\geq 2^{n}\]
and
\begin{align*}
d_{1}2^{n}+d_{2}2^{n-1}&+d_{3}2^{n-3}+\dots+d_{n}2+d_{n+1}\\
&\leq 2^{n-1}+2^{n-3}+\dots+2+1=2^{n}-1<2^{n}
\end{align*}
which is impossible. Similarly we can not have
$e_{1}=0$, $d_{1}=1$ so $d_{1}=e_{1}$ and
\[e_{2}2^{n-1}+e_{3}2^{n-2}+\dots+e_{n}2+e_{n+1}
=d_{2}2^{n-1}+d_{3}2^{n-2}+\dots+d_{n}2+d_{n+1}\]
whence (since $\sum_{j=2}^{n+1}e_{j}2^{n+1-j}\leq 2^{n}-1$)
by the inductive hypothesis
$e_{j}=d_{j}$ for all $2\leq j\leq n+1$.
Thus $Q(n+1)$ is true.

By induction $Q(n)$ holds for all $n$.
\section*{Exercise~\ref{E;toss unfair}*}
\newpage\section*{Exercise~\ref{E;next toss}}
(i) If 
\[p<X_{1}2^{-1}+X_{2}2^{-2}
\dots+X_{n}2^{-n}\]
then the process was halted in round $n$
or earlier with left being recorded.

If 
\[p\geq X_{1}2^{-1}+X_{2}2^{-2}
\dots+X_{n}2^{-n}+2^{-n}\]
then the process was halted in round $n$
or earlier with left being recorded.

(ii) If 
\[ X_{1}2^{-1}+X_{2}2^{-2}
\dots+X_{n}2^{-n}\leq p
<X_{1}2^{-1}+X_{2}2^{-2}+
\dots+X_{n}2^{-n}+2^{-n-1}\]
then $B$ is true and if
\begin{small}
\[ X_{1}2^{-1}+X_{2}2^{-2}
\dots+X_{n}2^{-n}+2^{-n-1}\leq p
<X_{1}2^{-1}+X_{2}2^{-2}+
\dots+X_{n}2^{-n}+2^{-n}\]
\end{small}
then (A) is true. Clearly (A) and (B) cannot both be true.

(iii) If (A) is true the probability of a decision in the
$n+1$st round is the probability that $X_{n+1}=0$
ie $1/2$. If (B) is true the probability of a decision in the
$n+1$st round is the probability that $X_{n+1}=1$
ie $1/2$. Since exactly one of (A) and (B) is true
 the probability of a decision in the
$n+1$st round is $1/2$.

\newpage\section*{Exercise~\ref{E;busts}}
Let $X_{k}=1$ if the $k$th purchase contains the
$j$th poet and $X_{k}=0$ otherwise.
Set $M=(1+\epsilon)Nn$ and
\[S_{M}=\sum_{k=1}^{M}X_{k}.\]
Then
\[{\mathbb E} S_{M}=\sum_{k=1}^{M}{\mathbb E}X_{k}=Mn^{-1}
=(1+\epsilon)N\]
and since the $X_{j}$ are independent
\[\var S_{M}=\sum_{k=1}^{M}\var X_{k}=\sum_{k=1}^{M}\frac{n-1}{n^{2}}
\leq \sum_{k=1}^{M}\frac{1}{n}=(1+\epsilon)N.\]
Thus
\begin{align*}
\Pr(\text{they obtain}\ &\text{fewer than $N$ busts of the $j$th poet})\\
&=\Pr(S_{M}<N)\\
&\leq \Pr(|S_{M}-{\mathbb E} S_{M}|\geq \epsilon N)\\
&\leq \frac{\var S_{M}}{(\epsilon N)^{2}}\\
&\leq \frac{(1+\epsilon)N}{(\epsilon N)^{2}}=(1+\epsilon)\epsilon^{-1}N^{-1}
\end{align*}
if $N\geq \epsilon^{-3}$.

Thus, if $N\geq 2n\epsilon^{-3}$,
\begin{align*}
\Pr(&\text{they obtain fewer than $N$ busts some poet})\\
&\leq \sum_{j=1}^{n}
\Pr(\text{they obtain fewer than $N$ busts of the $j$th poet})\\
&\leq \epsilon
\end{align*}
and  they will have at least $N$ full sets of poets with
probability at least $1-\epsilon$.
\newpage\section*{Exercise~\ref{E;same marriage}}
(i) No gentleman proposes to the same lady twice.
There are $n$ ladies so no gentleman makes more than $n$ proposals.
Thus there are no more than $n^{2}$ proposals.

(ii) If we have $n$ gentlemen with the same list
then each proposes to the favoured lady on entry
(giving $n$ proposals).
One of them is accepted permanently
(though some others may be accepted temporarily). The others
then perform our algorithm as if the favoured lady did not exist
and we had $n-1$ gentlemen with the same preferences.
Thus the number of proposals is
\[n+(n-1)+(n-2)+\dots+1=n(n+1)/2\]

\newpage\section*{Exercise~\ref{E;explain traffic equations}}
We write $P_{XY}$ for the probability that we reach
$HHT$ before $HTH$ if the last two throws have been
$XY$ and the game is not settled.

If we are at $HH$ then with probability $1/2$ we go to
$HHT$ and I win and with probability $1/2$ we go to
$HHH$ and the probability I now win is $p_{HH}$.
Thus
\[p_{HH}=\frac{1}{2}(p_{HH}+1).\]
If we are at $HT$ then with probability $1/2$ we go to
$HTH$ and I lose and with probability $1/2$ we go to
$HTT$ and the probability I now win is $p_{TT}$.
Thus
\[p_{HT}=\frac{1}{2}(0+p_{TT}).\]
If we are at $TH$ then with probability $1/2$ we go to
$THH$ and the probability I now win is $p_{HH}$
and with probability $1/2$ we go to
$THT$ and the probability I now win is $p_{HT}$.
Thus
\[p_{TH}=\frac{1}{2}(p_{HH}+p_{HT}).\]
If we are at $TT$ then with probability $1/2$ we go to
$TTH$ and the probability I now win is $p_{TH}$
and with probability $1/2$ we go to
$TTT$ and the probability I now win is $p_{TT}$.
Thus
\[p_{TH}=\frac{1}{2}(p_{TH}+p_{HH}).\]

Finally we note that after the first two throws we have probability
$1/4$ of being at each of $HH$, $HT$, $TH$, $TT$ so
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT}).\]
\newpage\section*{Exercise~\ref{E;choose triples}}
(i) We write $P_{XY}$ for the probability that we reach
$HHT$ before $HTT$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(p_{HH}+1),\ \ p_{HT}=\frac{1}{2}(0+p_{TT})\\
P_{TH}=\frac{1}{2}(p_{HH}+p_{HT}),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
Thus
\[p_{TT}=\frac{2}{3},\ p_{HH}=1,\ p_{HT}=\frac{1}{3},\ p_{HT}=\frac{2}{3}\]
and
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{2}{3}.\] 

(ii)  We write $P_{XY}$ for the probability that we reach
$THH$ before $HHT$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(p_{HH}+0),\ \ p_{HT}=\frac{1}{2}(p_{TH}+p_{TT})\\
P_{TH}=\frac{1}{2}(1+p_{HT}),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
Thus
\[p_{HH}=0,\ p_{TT}=p_{TH},\ p_{HT}=p_{TH},\ p_{TH}=1\]
and so
\[p_{HH}=0,\ p_{TT}=p_{TH}=p_{HT}=1\]
and
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{3}{4}.\]

The result is also obvious from the diagram. You get to $HHT$
from $HHH$ and $HHT$ but all other paths are blockaded.

(iii) Interchanging $T$ and $H$, we see that:-

$HTT$ has probability $7/8$ of beating $TTT$,

$TTH$ has probability $2/3$ of beating $THT$,

$TTH$ has probability $2/3$ of beating $THH$,

$HTT$ has probability $3/4$ of beating $TTH$.
\newpage\section*{Exercise~\ref{E;two letter bets}}
If the first player chooses $HH$ and the second $TH$
then unless the first two throws are $HH$ the second player must win.
Thus the second player has probability $3/4$ of winning.
Similarly the first player should not choose $TT$.

If the first player chooses $HT$ then the second player
should not choose $TT$. Suppose the second player 
chooses $HH$. Let $q_{XY}$ be the probability
that the second player wins starting from $XY$.
We have
\begin{align*}
q_{HH}&=1\\
q_{HT}&=0\\
q_{TT}&=\tfrac{1}{2}q_{TT}+\tfrac{1}{2}q_{TH}\\
q_{TH}&=\tfrac{1}{2}q_{HT}+\tfrac{1}{2}q_{HH}=\tfrac{1}{2}
\end{align*}
so $q_{HH}=0$, $q_{HT}=1$, $q_{TH}=\tfrac{1}{2}$, $q_{TT}=q_{TH}=\tfrac{1}{2}$
and the probability of the second player winning is
\[\frac{q_{HH}+q_{HT}+q_{TH}+q_{TT}}{4}=\frac{1}{2}.\]
By symmetry if the second player 
chooses $TH$ her probability of winning is also $1/2$.

Thus $HT$ and $TH$ are sensible choices for the first player.

If one player chooses $TH$ and the other $HT$
then if the first throw is $T$ the first player must win
and if  the first throw is $H$ the second player must win.
\newpage\section*{Exercise~\ref{E;better triple}}
(i) This is just the statement
\[\Pr(A^{c})=1-\Pr(A).\]

(ii) We have perfect symmetry between heads and tails.

(iii) In order to obtain $XYH$ we must first throw $XY$
but once we have done so we have equal probability of throwing
heads or tails.

\vspace{2\baselineskip}

There is no particular benefit in performing the calculations but 
but here they are.

\emph{Probability $HHH$ beats $HTH$}
We write $P_{XY}$ for the probability that we reach
$HHH$ before $HTH$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(1+p_{HT}),\ \ p_{HT}=\frac{1}{2}(0+p_{TT})\\
P_{TH}=\frac{1}{2}(p_{HT}+p_{HH}),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
Thus
\[p_{TH}=P_{TT},\ p_{HT}=\frac{1}{2}p_{TT},
\ p_{TT}=\frac{1}{4}\left(p_{TT}+\left(1+\frac{1}{2}p_{TT}\right)\right)\]
and so
\[p_{TH}=p_{TT}=\frac{2}{5},\ p_{HT}=\frac{1}{5},\ P_{HH}=\frac{3}{5}\]
and
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{2}{5}.\]

\emph{Probability $HHH$ beats $HTT$}
We write $P_{XY}$ for the probability that we reach
$HHH$ before $HTT$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(1+p_{HT}),\ \ p_{HT}=\frac{1}{2}(0+p_{TT})\\
P_{TH}=\frac{1}{2}(p_{HT}+p_{HH}),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
These are the equations of the previous paragraph.
\[\Pr(\text{I win})=\frac{2}{5}.\]

\emph{Probability $HHH$ beats $THT$}
We write $P_{XY}$ for the probability that we reach
$HHH$ before $THT$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(1+p_{HT}),\ \ p_{HT}=\frac{1}{2}(p_{TH}+p_{TT})\\
P_{TH}=\frac{1}{2}(1+p_{HH}),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
Thus
\[p_{HT}=P_{TT}=p_{TH}=\frac{1}{2}p_{HH},
\ p_{HH}=\frac{1}{2}\left(1+\frac{1}{2}p_{HH}\right)\]
and so
\[p_{HH}=\frac{2}{3},\ p_{HT}=P_{TT}=p_{TH}=\frac{1}{3}\]
and
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{5}{12}.\]

\emph{Probability $HHH$ beats $TTH$}
We write $P_{XY}$ for the probability that we reach
$HHH$ before $TTH$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(1+p_{HT}),\ \ p_{HT}=\frac{1}{2}(p_{TH}+p_{TT})\\
p_{TH}=\frac{1}{2}(p_{HT}+p_{HH}),\ \ p_{TT}=\frac{1}{2}(0+p_{TT}).
\end{gather*}
Thus 
\[p_{TT}=0,\ p_{HT}=\frac{1}{3}p_{HH},\ p_{TH}=\frac{2}{3}p_{HH},
\ p_{HH}=\frac{3}{5}\]
and so
\[p_{TT}=0,\ p_{HT}=\frac{1}{5},\ p_{TH}=\frac{2}{5}p_{HH},
\ p_{HH}=\frac{3}{5}\]

and
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{3}{10}.\]

\emph{Probability $HHT$ beats $HTT$}
We write $P_{XY}$ for the probability that we reach
$HHT$ before $HTT$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(1+p_{HH}),\ \ p_{HT}=\frac{1}{2}(0+p_{TH})\\
p_{TH}=\frac{1}{2}(p_{HT}+p_{HH}),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
Thus 
\[p_{HT}=\frac{1}{2}p_{TH},\ p_{TT}=p_{TH},\ p_{HH}=1,
\ p_{TH}=\frac{2}{3}\]
and so
\[p_{TT}=p_{TH}=\frac{2}{3},\ p_{HT}=\frac{1}{3},
\ p_{HH}=1\]
and
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{2}{3}.\]

\emph{Probability $HHT$ beats $THT$}
We write $P_{XY}$ for the probability that we reach
$HHT$ before $THT$ if the last two throws have been
$XY$ and the game is not settled.
\begin{gather*}
p_{HH}=\frac{1}{2}(1+p_{HH}),\ \ p_{HT}=\frac{1}{2}(p_{TH}+p_{HT})\\
p_{TH}=\frac{1}{2}(p_{HH}+0),\ \ p_{TT}=\frac{1}{2}(p_{TH}+p_{TT}).
\end{gather*}
Thus 
\[p_{HH}=1,\ p_{TT}=p_{TH}=p_{TH}=\frac{1}{2}p_{HH}=\frac{1}{2}\]
and so
\[\Pr(\text{I win})=\frac{1}{4}(p_{HH}+p_{HT}+p_{TH}+p_{TT})=\frac{5}{8}.\]

\emph{Probability $HTH$ beats $TTH$}
The match will be decided if at least throws have been made
and the last two throws were $TH$. It is equally likely
that the throw before the last two was heads or tails
so the probability that $HTH$ beats $TTH$ is $1/2$.

The remaining entries have already been calculated or may be 
found by applying rules (i), (ii) and (iii).

\newpage\section*{Exercise~\ref{E;best three}}
We do not need to do as many checks as these but it is comforting to observe
that
\begin{align*}
\text{Expected value our strategy against $HHH$}&=\frac{1}{4}>0\\
\text{Expected value our strategy against $HHT$}&=\frac{1}{12}>0\\
\text{Expected value our strategy against $HTH$}&=0\\
\text{Expected value our strategy against $HTT$}&=0\\
\text{Expected value our strategy against $THH$}&=0\\
\text{Expected value our strategy against $THT$}&=0\\
\text{Expected value our strategy against $TTH$}&=\frac{1}{12}>0\\
\text{Expected value our strategy against $TTT$}&=\frac{1}{4}>0
\end{align*}
By symmetry our expected value against best play is $0$
so this is an optimum strategy.

If my opponent just plays one triple $XYZ$,
I will have strictly positive expected winnings
against $HHH$, $TTT$, $HHT$ and $THH$.

If my opponent promises to
choose either $HTH$ or $THT$,
then inspection of Table~\ref{F;triplet expectations}
shows that I should play some combination
of $HHT$ and $THH$ and a little thought (or explicit
calculation) shows that if he uses best play (subject to his original
foolish decision), I should play each option with probability $1/2$
and my expected winnings are $7/24$.
\newpage\section*{Exercise~\ref{E;Opera}}
The new game is obtained from the old by adding $3$ units to the value
of each outcome.

Whatever Little Bonaparte chooses, Spats can do better 
for himself by pressing. Thus Spats should press.
By exactly the same argument Little Bonaparte
will press. They get $1$ each.

If Bonaparte and Spats could trust each other
they could agree not to press and get $2$ each.
\newpage\section*{Exercise~\ref{E;Travellers}}
The travellers may not be the most agreeable conversationalists
but they are acute reasoners.
If there is exactly $1$ bore then he knows immediately
who he is (since he knows no bores) and resigns on the first evening.
If there is more than $1$ no one can know for certain
that he is a bore.
If there are exactly $2$ bores then on the first morning
each knows that there must be at least $2$ bores but
is acquainted with only $1$ bore. They therefore know that they
are bores and resign. If there is more than 
$2$ no one can know for certain that he is a bore.
The argument proceeds inductively and shows
that if there are exactly $k$ bores they will resign
on the $k$th evening and their resignation will be announced
on the $k$th morning after the announcement.
Since there are no resignations on the first $49$ mornings
everybody must be a bore and they resign en masse
and a smirking secretary posts their names
on the $50$th morning.

\newpage\section*{Exercise~\ref{E;equations tat}}
We have
\begin{gather*}
B(I,P)=3+pB(A,P)\\
B(I,N)=2+pB(I,N)\\
B(I,S)=2+pB(I,S)\\
B(I,0)=3+pB(A,O)\\
B(A,P)=1+pB(A,P)\\
B(A,N)=0+pB(I,N)\\
B(A,S)=0+pB(A,S)\\
B(A,0)=0+pB(I,O)
\end{gather*}
Thus 
\[B(I,N)=\frac{2}{1-p},\ B(I,S)=\frac{2}{1-p},\ B(A,P)=\frac{1}{1-p},
\ B(A,S)=0\]
so
\[B(I,P)=3+\frac{p}{1-p},\ B(A,N)=\frac{2p}{1-p}.\]
Also
\[B(I,0)=3+pB(A,O)=3+p^{2}B(I,O)\]
so
\[B(I,0)=\frac{3}{1-p^{2}},\ B(A,0)=\frac{3p}{1-p^{2}}.\]
\newpage\section*{Exercise~\ref{E;geometric tat}}
We have
\begin{gather*}
B(I,P)=3+p+p^{2}+p^{3}+\dots=3+\frac{p}{1-p}\\
B(I,N)=2+2p+2p^{2}+2p^{3}+\dots=\frac{2}{1-p}\\
B(I,S)=2+2p+2p^{2}+2p^{3}+\dots=\frac{2}{1-p}\\
B(I,O)=3+0p+3p^{2}+0p^{3}+3p^{4}+\dots=\frac{3}{1-p^{2}}\\
B(A,P)=1+p+p^{2}+p^{3}+\dots=\frac{1}{1-p}\\
B(A,N)=0+2p+2p^{2}+2p^{3}+\dots=\frac{2p}{1-p}\\
B(A,S)=1+p+p^{2}+p^{3}+\dots=\frac{1}{1-p}\\
B(A,O)=0+3p+0p^{2}+3p^{3}+0p^{4}\dots=\frac{3p}{1-p^{2}}
\end{gather*}
\newpage\section*{Exercise~\ref{E;Sonia}}
If it is very likely that there will be another
game our best choice is to obtain a system where
neither press and we share equally a sum which is greater
than the total available by non-cooperation.

If it is less likely that there will be another game
we take the maximum possible by pressing. If there
is a second game we sacrifice a small sum to
restablish good relations which we can exploit if there
is another round. 

If the probability of another game is even smaller
then at each round we take the maximum available
on that round by pressing.
\newpage\section*{Exercise~\ref{E;Sonia again}}
We have $B(A,P)=B(A,S)$ and
\begin{gather*}
B(A,P)-B(A,N)=\frac{1-2p}{1-p}\\
B(A,P)-B(A,O)=\frac{1-2p}{1-p^{2}}\\
B(A,N)-B(A,O)=\frac{p(2p-1)}{1-p^{2}}.
\end{gather*}
Thus
\[B(A,P)> B(A,N),B(A,O)\]
for $0\leq p< 1/2$ and
\[B(A,N)>B(A,O)>B(A,P)\]
for $1/2<p\leq 1$
whilst
\[B(A,N)=B(A,O)=B(A,P)\]
if $p=1/2$.

Sonia should play never press if $p>1/2$ and always press
if $p<1/2$. If $p=1/2$ all strategies have the same expected
pay-off.

\newpage\section*{Exercise~\ref{E;tit alternate}}
Using the same notation as before
we have
\begin{gather*}
B(I,P)=6+p+p^{2}+p^{3}+\dots=6+\frac{p}{1-p}\\
B(I,N)=2+2p+2p^{2}+2p^{3}+\dots=\frac{2}{1-p}\\
B(I,S)=2+2p+2p^{2}+2p^{3}+\dots=\frac{2}{1-p}\\
B(I,O)=6+0p+6p^{2}+0p^{3}+6p^{4}+\dots=\frac{6}{1-p^{2}}.
\end{gather*}
Thus $B(I,N)=B(I,S)$ and
\begin{gather*}
B(I,N)-B(I,P)=\frac{2-p}{1-p}-3=\frac{2p-1}{1-p},\\
B(I,N)-B(I,O)=\frac{2(1+p)-6}{1-p^{2}}=\frac{2p-4}{1-p^{2}},\\
B(I,P)-B(I,O)=\frac{p}{1+p}-\frac{6p^{2}}{1-p^{2}}
=\frac{p(1-7p)}{1-p^{2}}.
\end{gather*}
Thus
\begin{gather*}
B(I,N)>B(I,P)\ \text{for $p>1/2$},
\ B(I,P)>B(I,N)\ \text{for $1/2>p$},\\
B(I,O)>B(I,N)\ \text{for all $p$},\\
B(I,O)>B(I,P))\ \text{for $p>1/7$},
\ B(I,P)> B(I,O)\ \text{for $1/7>p$}.
\end{gather*}
and Sonia should do the opposite of Tania if $p>1/7$
and always press if $p<1/7$. She can follow either tactic if $p=1/7$.

The total prize available if one presses and the other does
not, is greater
than for any other. If the probability of many further
games is high the strategies of Tania and Sonia more or less
share this total prize.
\newpage\section*{Exercise~\ref{E;alternative tat}}
If $p$ is large tactics by which the players always
hit on the maximum total pay out and arrange to share
more or less equally are optimal.

If $2c>d$ and $p$ is large enough
always play the same, if $2c<d$
and $p$ is large enough always play the opposite.
\newpage\section*{Exercise~\ref{E;tat with draws}}
There is no mathematical argument available but
since tit for tats do well in the other type of contest
and draw with each other it seems to me that tit for tat
remains a good choice.

\newpage\section*{Exercise~\ref{E;flocks of tats}}
(i) Any program is much more likely to meet
a `tit for tat' than an `always press'. Since `tit for tats'
do better than `always press' against `tit for tats'
the `tit for tats' will gain more points than the
`always presses' and the population of
`always presses' will decline.

(ii) Any program is much more likely to meet
an `always press' than a `tit for tats'. Since `tit for tats'
do worse than `always presses' against `always presses'
the `tit for tats' will gain fewer points than the
`always presses' and the population of
`tit for tats' will decline.

(iii) Any program is much more likely to meet
an `never press' than an `always press'.
Since `always presses' do better than `always presses' against
`never presses' than an `always press' the proportion
of `always presses' will increase. The question of what will happen
when there is a large proportion of `always preses'
depends on how we fix the reward and breeding structure.

If we have a mixed flock of `never presses' and `tit for tats'
then the behaviour of the two types of program in an
encounter is the  same. There is no tendency for the
proportion of `tit for tats' to grow or decline.
(This is not the same as saying that the proportion
will stay the same, simply that there is no preferred direction of change.)
\newpage\section*{Exercise~\ref{E;uncountable three heads}}
Consider the map
\[\theta:\{0,1\}^{\mathbb N}\rightarrow\{H,T\}^{\mathbb N}\]
from sequences of $0$'s and $1$'s to sequences of heads and tails.
Define
\[\theta({\mathbf x})_{2k}
=\begin{cases}
H&\text{if $x_{k}=0$}\\
T&\text{if $x_{k}=1$}
\end{cases}
\]
and
\[\theta({\mathbf x})_{2k+1}
=\begin{cases}
T&\text{if $x_{k}=0$}\\
H&\text{if $x_{k}=1$}
\end{cases}
\]
Thus the $2k$ and $2k+1$ th throws are $HT$ if the $k$th entry
of ${\mathbf x}$ is $0$ and $TH$ if the $k$th entry
of ${\mathbf x}$ is $1$ $[0\leq k]$.

$\theta({\mathbf x})$ contains no sequence $HHH$ or $TTT$
and $\theta$ is injective. Since $\{0,1\}^{\mathbb N}$
is uncountable there uncountably many
different sequences for which the game goes on for ever.
\newpage\section*{Exercise~\ref{E;fruit}}
Observe that if the machine spins all wheels the probability
of three letters being the same is $3/27=1/9$,
of no letters being the same is $6/27=2/9$ and two the same
is $18/27=2/3$.

The game will certainly end if hold fails to
light up and the machine the produces three distinct letters.
The probability of this is $(1/2)\times(2/9)=8/9$
so the probability the game ends on a particular round is at least $1/9$.
Thus he probability that she plays an $n$ th
round is no greater than $(8/9)^{n-1}$.

If she must stop on round $N$ her expected
number of rounds 
\[r_{N}\leq \sum_{n=1}^{N}\left(\frac{8}{9}\right)^{n-1}
\leq 9\]
Since $r_{N}$ is increasing bounded above it tends to a limit
so the expected number of rounds that she plays
is finite. Since her winnings and losses on each round are bounded by $3$
her expected winnings are finite. (A more sophisticated
approach is to use the comparison test.)

Let $e_{1}$ be her expected winnings starting with
all windows different, $e_{2}$ her expected winnings starting with
two windows the same and
$e_{3}$ her expected winnings starting with
three windows the same.
\begin{align*}
e_{1}&=-10+\frac{2}{3}e_{2}+\frac{1}{9}(30+e_{3})\\
e_{2}&=-10+\frac{1}{2}\left(\frac{2}{3}e_{2}+\frac{1}{9}(30+e_{3})\right)
+\frac{1}{2}\left(\frac{2}{3}e_{2}+\frac{1}{3}(30+e_{3})\right)\\
e_{3}&=-10+\frac{1}{2}\left(\frac{2}{3}e_{2}+\frac{1}{9}(30+e_{3})\right)
+\frac{1}{2}(30+e_{3})
\end{align*}

Subtracting the second equation from the third gives
\[e_{3}-e_{2}=\frac{1}{2}(30+e_{3})-
\frac{1}{2}\left(\frac{2}{3}e_{2}+\frac{1}{3}(30+e_{3})\right)\]
so $e_{3}=e_{2}+15$. Substituting back, $e_{3}=15$, $e_{2}=0$
and $e_{1}=-5$.

The bettors  expected loss is 5 pence.
\newpage\section*{Exercise~\ref{E;oaks}}
(i) Observe that
\begin{align*}
{\mathbb E}X&=\sum_{j=1}^{N}j\Pr(X=j)\\
&=\sum_{j=1}^{N}\sum_{k=1}^{j}\Pr(X=j)\\
&=\sum_{1\leq k\leq j\leq N}\Pr(X=j)\\
&=\sum_{k=1}^{N}\sum_{j=k}^{N}\Pr(X=j)\\
&=\sum_{k=1}^{N}\Pr(X\geq k)
\end{align*}

If $Y_{N}=\min(X,N)$
\[{\mathbb E}Y_{N}=\sum_{k=1}^{N}\Pr(Y_{N}\geq k)
=\sum_{j=1}^{N}\Pr(X\geq k)
\rightarrow \sum_{r=1}^{\infty}\Pr(X\geq r)\]
as $N\rightarrow\infty$.

(ii) Let $X$ be the number of shots $A$ fires.
We have
\[\Pr(X\geq m)=\Pr(\text{$m-1$ misses in a row})=(1-a)^{m-1}\]
so
\[{\mathbb E}\min(N,X)=\sum_{m=1}^{N}(1-a)^{m-1}
=\frac{1-(1-a)^{n+1}}{a}-(1-a)^{n}\]
and
\[{\mathbb E}X=\sum_{m=1}^{\infty}(1-a)^{m-1}=\frac{1}{a}.\]

(iii) Let $B_{j,r}$ be the probability that the $j$th
spot where an acorn is planted does not have an 
oak after $r-1$ plantings.
Then
\begin{small}
\begin{align*}
&\Pr(\text{at least $r$ plantings required})
=\Pr\left(\bigcup_{i=1}^{n}B_{i,r}\right)\\
&=\sum_{i}\Pr(B_{i,r})
-\sum_{i<j}\Pr(B_{i,r}\cap B_{j,r})
+\sum_{i<j<k}\Pr(B_{i,r}\cap B_{j,r}\cap B_{k,r})-\dots\\
&=\binom{n}{1}\Pr(B_{1,r})
-\binom{n}{2}\Pr(B_{1,r}\cap B_{2,r})
+\binom{n}{3}\Pr(B_{1,r}\cap B_{2,r}\cap B_{3,r})-\dots\\
&=\binom{n}{1}q^{r}
-\binom{n}{2}q^{2r}
+\binom{n}{3}q^{3r}-\dots
\end{align*}
\end{small}
and so
\begin{align*}
&\text{expected number of plantings}
=\sum_{r=1}^{\infty}\Pr(\text{at least $r$ plantings required})\\
&=\binom{n}{1}\frac{1}{1-q}-
\binom{n}{2}\frac{1}{1-q^{2}}+
\binom{n}{3}\frac{1}{1-q^{3}}-
\ldots+(-1)^{n-1}\binom{n}{n}\frac{1}{1-q^{n}}.
\end{align*}

\newpage\section*{Exercise~\ref{E;look every three goes}}
The game will certainly terminate if the next three throws are $HHH$
or $TTT$ (it may terminate otherwise). The probability
of three the same is $1/4$, so the probability that the game terminates
during the next three throws is at least $1/4$.
Thus
\[\Pr(\text{game lasts $3n$ tosses})\leq (3/4)^{n}\rightarrow 0\]
as $n\rightarrow\infty$.
\newpage\section*{Exercise~\ref{E;Cantor three heads}}
Let $A_{n}$ be the collection of games terminating
in $n$ goes or less. Then $A_{n}$ is finite so
countable.
Thus $\bigcup_{n=1}^{\infty}A_{n}$ is countable
(being the countable union of countable sets)
and this is the stated result.
\newpage\section*{Exercise~\ref{E;Dubrovsky}} 
\[\Pr(\text{happy end})=\Pr(\text{wins $5$ goes in succession})
=p^{5}\]

If $p=1/4$, $p^{5}\approx 0.00098$.

If $p=3/4$, $p^{5}\approx 0.237$.

\newpage\section*{Exercise~\ref{E;preliminary difference}}
If $q_{n}=q_{0}t^{n}$ then 
\[q_{n+1}=q_{n}t=q_{0}t^{n+1}\]
since $q_{0}=t^{0}q_{0}$ the result follows by induction
for $n\geq 0$.

The result is also true for $n\leq 0$. Either use simple induction
or observe that
\[q_{-(n+1)}=t^{-1}q_{-n}\]
and use the first part.
\newpage\section*{Exercise~\ref{E;happy end}}
(i) Observe that, if
\[q_{n}=A+B\left(\frac{p}{1-p}\right)^{n}\]
then
\begin{align*}
pq_{n+1}-&q_{n}+(1-p)q_{n-1}A\big(p-1+(1-p)\big)\\
&\qquad+B\left(\frac{1-p}{p}\right)^{n-1}
\left(p\left(\frac{1-p}{p}\right)^{2}
-\left(\frac{1-p}{p}\right)+(1-p)\right)\\
&=0+B\left(\frac{1-p}{p}\right)^{n-1}
\frac{(1-p)^{2}-(1-p)+p(1-p)}{p}=0
\end{align*}
as stated.

(ii) If $q_{0}=0$ then $A=-B$ so
 \[q_{n}=A\left(1-\left(\frac{p}{1-p}\right)^{n}\right).\]
If further $q_{256}=1$ then
\[A=\left(1-\left(\frac{p}{1-p}\right)^{256}\right)^{-1}\]
so
\[q_{n}=\frac{1-\left(\frac{1-p}{p}\right)^{n}}
{1-\left(\frac{1-p}{p}\right)^{256}}.\]
\newpage\section*{Exercise~\ref{E;Las Vegas}}
(i) With (a)  I gamble $1120$ dollars and have probability
$p$ of gaining my end. If I lose (which I do with probability
$1-p$) I have $320$ dollars and must win three times in a row
(probability $p^{3}$) to gain my ends.
My probability of success is
\[p+(1-p)p^{3}.\]

With (b) I must win $3$ times in row to gain my ends without
gambling my back pocket. The probability of this is $p^{4}$.
Otherwise, with probability $1-p^{4}$ I gamble my back pocket 
and have probability $p$ of winning.
My probability of success is
\[p^{3}+(1-p^{3})p=p+(1-p)p^{3}.\] 

(ii) With bold play I have probability $p$ of reaching
my goal immediately. Otherwise with probability
$1-p$ I will have $1440$ dollars and using (a) or (b)
I have probability $p_{0}=p+(1-p)p^{3}$ of winning
my ends. Thus my probability of success is
\[p+(1-p)p_{0}.\]

Alternatively I can put $1280$ dollars in my back pocket and then use
either strategy (a) or (b) (with one dollar being replaced by 
$50$ cents) to gain gain my ends without
gambling my back pocket. This has probability $p_{0}$.
If I fail (which I will with probability $1-p_{0}$)
I gamble my back pocket and have probability $p$
of gaining my ends. Thus my probability of success is
\[p_{0}+(1-p_{0})p=p+(1-p)p_{0}.\]

(See \emph{How To Gamble If You Must} by Dubins and Savage
Chapter~5, Section~4. The book is reprinted by Dover)
\newpage\section*{Exercise~\ref{E;martingale in spring}}
The expected gain on a bet of $x$ is
\[pxp^{-1}+(1-p)0-x=0.\]
If your expected gain on any game is zero then
it should be zero on any combination of games.

Thus your expected winnings are $0$. If you have probability $q$
of gained your desired prize with a particular strategy
then your expected winnings are
\[-k+ql+(1-q)0=-k+ql.\]
Thus $ql=k$ and $q=k/l$. 
\newpage\section*{Exercise~\ref{E;pension}}
(i) If $p<1/2$ she is gambling in unfavourable circumstances
and should use bold play as described in this section.

(ii) If $f$ is her fortune on retirement
then the probability she is happy is $1$ if $f\geq 1$
and zero otherwise.

We have proved the inductive hypothesis for $r=0$.
Suppose it is true for $r=m$. If we have a fortune
\[f=(k+\delta)2^{-m-1}+\delta\]
with $0\leq k\leq 2^{m+1}$ an integer 
then if we gamble
$(u+\eta)2^{-m-1}$ with $0\leq u\leq k$ an integer 
and $0\leq \eta\leq \delta$
our new fortune will either be
$(k+u+\eta+\delta)2^{-m-1}$
or $(k-u-\eta+\delta)$ and by the inductive hypothesis
the probability of ultimate success
will either be that if we start from
\[2^{-m}[(k+u+\eta+\delta)/2]=2^{-m}[(k+u)/2]\]
or if we start from
\[2^{-m}[(k-u+\eta-\delta)/2]=2^{-m}[(k-u)/2]\]
(here $[a]$ is the integer part of $a$)
at year $m$ independent of $\eta$ and $\delta$.
The result thus follows by induction.

(iii) If $k$ is even she should bet $(2r)2^{-m-1}$
with $0\leq 2r\leq k$ and the probability
of ultimate success if she then plays correctly
is
\[e(2r,k,m+1)=
\frac{p\big(((k+2r)/2,m\big)+p\big(((k-2r)/2,m\big)}{2}\]
She should choose $r=r^{*}$ to maximise $e(2r,k,m+1)$
and then $p(k,m+1)=e(2r^{*},k,m+1)$.

If $k$ is odd she should bet $(2r+1)2^{-m-1}$
with $0\leq 2r+1\leq k$ and the probability
of ultimate success if she then plays correctly
is
\[e(2r+1,k,m+1)=
\frac{p\big(((k+2r+1)/2,m\big)+p\big(((k-2r-1)/2,m\big)}{2}\]
She should choose $r=r^{*}$ to maximise $e(2r+1,k,m+1)$
and then $p(k,m+1)=e(2r^{*}+1,k,m+1)$.

(iv) If $n$ is large we are almost back to
the circumstances described in this section
and should gamble slowly. She will stake a small 
proportion of her fortune.

If $n$ is small, small bets can not produce the required outcome.
She will bet a relatively large proportion
of her fortune.

\newpage\section*{Exercise~\ref{E;variance roulette}}
(a) The expected return is
\[\Pr(\text{win})\times 32=\frac{32}{33}.\]
The probability of winning with bold play is $1/33\approx 0.0303$.

(b) The expected return is
\[\Pr(\text{win})\times 2=\frac{16}{33}\times 2=\frac{32}{33}.\]
To win with bold play you need to win $5$ times in a row.
The probability of winning is 
\[\left(\frac{16}{33}\right)^{5}\approx 0.0268.\]

\vspace{2\baselineskip}
\begin{center}
\begin{verse}
Take my advice--  when deep in debt,\\
Set up a bank and play Roulette!\\
At once distrust you surely lull,\\
And rook the pigeon and the gull.\\
The bird will stake his every franc\\
In wild attempt to break the bank--\\
But you may stake your life and limb\\
The bank will end by breaking him!
\end{verse}
(Gilbert and Sullivan \emph{The Grand Duke})
\end{center}
\newpage\section*{Exercise~\ref{E;which game?}}
(i) Game A has expected value $2^{-10}2^{8}=2^{-2}$
and variance 
\[2^{-10}2^{16}-(2^{-2})^{2}=2^{6}-2^{-4}\]
for an investment of one dollar.
The probability of winning your desired sum by bold play
in game A is $2^{-10}$.

Game B has expected value $2^{-3}2^{2}=2^{-1}$
and variance 
\[2^{-3}2^{4}-(2^{-1})^{2}=1/4.\]
The probability of winning your desired sum by bold play
in game B is the probability of winning four times in succession
that is to say $(2^{-3})^{4}=10^{-12}$.

Game C has expected value $2^{80}2^{-120}=2^{-40}$
and variance
\[2^{-120}2^{160}-(2^{-40})=2^{40}-2^{-80}\]
for an investment of one dollar.
Bold play in C will involve betting at least
$2^{-71}$ dollars (actually rather more) each go
so you will run out of money after at most
$2^{71}$ throws unless you win a throw.
The probability of winning in $2^{71}$ throws
is
\[1-\Pr(\text{losing $2^{71}$ throws})=1-(1-2^{-120})^{2^{71}}\]
which is tiny (either by direct calculation or using the
binomial expansion and bounding terms).

(ii) The expected value of game D is
\[2^{-10}2^{8}+2^{80}2^{-120}=2^{-2}+2^{-40}\]
and its variance is greater than
\[2^{-120}\times 2^{160}-(2^{-2}+2^{-40})^{2}>2^{39}.\]
If we intend to try and play a few games then
the game looks very much like game B which is substantially
worse than game A. If we play many games with many small stakes
then the law of large numbers says that in practice
we are betting in game C with a bet of $k/2$,
returning $2^{40}k$ with probability $2^{-80}$
and the same kind of estimates as before show
that our chances of succeeding are negligible.
\newpage\section*{Exercise~\ref{E;bet tiny}}
We have
\[{\mathbb E}X=p\times kp^{-1}+(1-p)\times 0=k\]
and
\begin{align*}
\var X&={\mathbb E}X^{2}-({\mathbb E}X)^{2}\\
&=p\times (kp^{-1})^{2}+(1-p)\times 0-k^{2}\\
&=k^{2}(p^{-1}-1)
\end{align*}

Thus $\var X\rightarrow k^{2}(1-1)=0$ as $p\rightarrow 1-$
and $\var X\rightarrow\infty$ as $p\rightarrow 0+$.
\newpage\section*{Exercise~\ref{E;unreasonable strategy}}
You are broke if you lose. You have $1$ if you win.
The probability of success is thus $k{\mathcal F}<k$.
\newpage\section*{Exercise~\ref{E;lots of small bets}}
(i) You have $(n-r){\mathcal F}$ fortune remaining
so you need to win 
\[1-(n-r)n^{-1}{\mathcal F}\]
to leave.
Thus you take $p_{r}$ so that
\[\frac{\mathcal F}{n}kp_{r}^{-1}=1-(n-r)n^{-1}{\mathcal F}\]
or, rearranging,
\[p_{r}=\frac{k{\mathcal F}}{n(1-{\mathcal F})+r{\mathcal F}}.\]

(ii) You will fail if each of your $n$ bets fail so with 
probability
\[q_{n}=\prod_{r=1}^{n}\Pr(\text{$r$th bet fails})=
\prod_{r=1}^{n}(1-p_{r})\]
so taking logarithms,
\[\log q_{n}=\sum_{r=1}^{n}\log(1-p_{r}).\]

(iii) Observe that
\[p_{r}=\frac{k{\mathcal F}}{n(1-{\mathcal F})}
\leq {\mathcal F}(1-{\mathcal F})^{-1}.\]
\newpage\section*{Exercise~\ref{E;rigour logarithm}}
(i) We have
\[g'(x)=1+2x-\frac{1}{1-x}=\frac{x-2x^{2}}{1-x}
=\frac{x(1-2x)}{1-x}\geq 0\]
for $0\leq x\leq 1/2$ so $g$ is increasing and
\[0=g(0)\leq g(x)=x+x^{2}+\log(1-x)\]
ie
\[x+x^{2}\geq -\log(1-x)\]
for $0\leq x\leq 1/2$.

On the other hand, setting $f(x)=x+\log(1-x)$, we have
\[f'(x)=1-\frac{1}{1-x}\leq 0\]
for $0\leq x<1$ so $f$ is decreasing and
\[0=f(0)\geq f(x)=x+\log(1-x)\]
ie
\[x\leq -\log(1-x)\]
for $0\leq x<1$.

(ii) Set $A={\mathcal F}(1-{\mathcal F})^{-1}$.
Provided that $n>2A$, part~(iii) of
Exercise~\ref{E;lots of small bets} tells us that $0<p_{n}<1/2$
so
\[p_{r}\leq -\log(1-p_{r})\leq p_{r}+p_{r}^{2}\leq p_{r}
+\frac{A^{2}}{n^{2}}\]
whence
\[\sum_{r=1}^{n}p_{r}\leq -\log q_{n}
\leq \sum_{r=1}^{n}p_{r}+\frac{A^{2}}{n}\]
and
\[\log q_{n}+\sum_{r=1}^{n}p_{r}\rightarrow 0\]
as $n\rightarrow\infty$.

We know that if $G:[0,1]\rightarrow{\mathbb R}$ is continuous
then
\[\frac{1}{n}\sum_{r=1}^{n}G(r/n)
\rightarrow \int_{0}^{1}G(t)\,dt.\]
Taking 
\[G(t)=\frac{1}{(1-{\mathcal F})+t{\mathcal F}}\]
we obtain
\begin{align*}
\sum_{r=1}^{n}p_{r}&=k{\mathcal F}\times
\frac{1}{n}\sum_{r=1}^{n}
\frac{1}{(1-{\mathcal F})+\tfrac{r}{n}{\mathcal F}}\\
&\rightarrow k{\mathcal F}
\int_{0}^{1}
\frac{dt}{(1-{\mathcal F})+t{\mathcal F}}\\
&==-k\lbrack\log\big((1-{\mathcal F})+t{\mathcal F}\big)\rbrack_{0}^{1}\\
&=-k\log (1-{\mathcal F})
\end{align*}
as $n\rightarrow \infty$.

Thus
\[\log q_{n}\rightarrow k\log (1-{\mathcal F})\]
and so
\[q_{n}\rightarrow (1-{\mathcal F})^{k}\]
as $n\rightarrow \infty$.
\newpage\section*{Exercise~\ref{E;divide better than bold}}
(i) We have
\[g(x)=k(1-x)^{k-1}-k=k\big((1-x)^{k-1}-1\big)>0\]
for $0<x<1$, so $g$ is strictly increasing in this range
and
\[g(x)>g(0)=0\]
ie
\[1-kx>(1-x)^{k}\]
for $0<x<1$.

The probability of failure with the simple bold strategy
is $1-k{\mathcal F}$. The probability of failure with the division
strategy can be made as close to $(1-{\mathcal F})^{k}$ as we wish.
Thus the division strategy
(with $n$ sufficiently large) is always better
than our simple bold strategy.

(ii) By the definition of the derivative
\[\frac{1-(1-x)^{k}}{kx}=\frac{1}{k}\times\frac{h(x)-h(0)}{x}
\rightarrow \frac{h'(0)}{k}=1,\]
so when ${\mathcal F}$ is small
the ratio of the probabilities of success
\[\frac{1-(1-{\mathcal F})^{k}}{k{\mathcal F}}\]
is close to $1$ and our division strategy
not much better better
than the simple bold strategy.
\newpage\section*{Exercise~\ref{E;ordinary or odd?}}
You must win $5$ times in secession so you want
\[p^{5}\geq 1/33\]
so $p\geq .497$ (approximately) 
If we take $p=.497$ the Casino's expectation is about $0.006$
(In the game (a) it is about $0.03$.)

\vspace{2\baselineskip}
\section*{Exercise~\ref{E;fool's gold}$^{*}$}
\newpage\section*{Exercise~\ref{E;martingales}}
(i) The expected return is $2\,560\,000$
which is what we should expect from a fair game.
We expect to get out (on average)
what we put in.

(ii) [Corrected version] If $p=.495$ our expected return is
\[10,000\times.505^{-8}\approx 2\,364\,117.\]
\newpage\section*{Exercise~\ref{E;Leeson}}
This just a particularly wild modification
of unlimited double or quits.
If you own $a'$ (with $a'<b$) you  you announce a bet of 
$(b'-a)/u$ dollars. If you win, you walk away with $b$.
If you lose you repeat the process.

Since you walk away at the first win and since no strategy
will allow you to walk away before you have had at least one win
this is a best strategy.

The expected time to your first win is $p^{-1}$
(see the one sided duel) which is independent of
$a$, $b$ and $u$.

Useful theorems on probability must exclude wild
games like this.
\newpage\section*{Exercise~\ref{E;begin differential}}
\begin{align*} 
aw''+bw'+cw&=a(kv+u)''+b(kv+u)'+c(kv+u)\\
&=a(kv''+u'')+b(kv'+u')+c(kv+u)\\
&=k(av''+bv'+cv)+(au''+bu'+cu)\\
&=k0+f=f.
\end{align*}

If
\[au'(x)+bu(x)=f(x)\]
and
\[av'(x)+bv(x)=0,\]
then, if $k$ is constant and $w=kv+u$,
\begin{align*}
aw'+bw&=a(kv+u)'+b(kv+u)\\
&=a(kv'+u')+b(kv+u)\\
&=k(av'+bv)+(au'+bu)\\
&=k0+f=f.
\end{align*}
\newpage\section*{Exercise~\ref{E;continue differential}}
(i) Observe that
\begin{align*}
(D-aI)(D-bI)u&=(D-aI)(u'-bu)=(u'-bu)'-a(u'-bu)\\
&=u''-bu'-au'+abu=(D^{2}-(a+b)D+abI)u.
\end{align*}

(ii) If $u'-au=f$ then
\begin{align*}
\frac{d\ }{dx}(e^{-ax}u(x))&=-ae^{-ax}u(x)+e^{-ax}u'(x)\\
&=e^{-ax}(u'(x)-au(x))=e^{-ax}f(x)
\end{align*}
so integrating
\[\bigl[ e^{-as}u(s)\bigr]_{0}^{x}=\int_{0}^{x}e^{-as}f(s)\,ds\]
so
\[e^{-ax}u(x)-u(0)=\int_{0}^{x}e^{-as}f(s)\,ds\]
and 
\[u(x)=u(0)e^{ax}+e^{ax}\int_{0}^{x}e^{-as}f(s)\,ds.\]


(iii) Set $v=(D-bI)u$. Then
\[v'(x)-a v(x)=0\]
and, by (ii) with $f(x)=0$,
\[v(x)=v(0)e^{ax}+e^{ax}\int_{0}^{x}e^{-as}0\,ds=v(0)e^{ax}.\]
Now
\[u'(x)-bu(x)=v(x)=v(0)+e^{ax}\]
so, by (ii),
\begin{align*}
u(x)&=u(0)e^{bx}+e^{bx}\int_{0}^{x}v(0)e^{(a-b)s}\,ds\\
&=u(0)e^{bx}+\frac{v(0)}{a-b}(e^{ax}-e^{bx})=Ae^{ax}+Be^{bx}.
\end{align*}

Thus the only possible solutions are
\[u(x)=Ae^{ax}+Be^{bx}\]
for some pair constants $A$ and $B$. 
By inspection every pair of constants give a solution.

To prove the last statement, either examine he argument above carefully
or note that we have a solution if and only if
\begin{align*}
u_{0}&=A+B\\
u_{1}&=aA+bB
\end{align*}
and, since $a\neq b$, these equations have a unique solution.

(iv) Set $v=(D-aI)u$. Then, as in~(iii),
\[v(x)=v(0)e^{ax}\]
so, by (ii), with $f(x)=e^{ax}$
\begin{align*}
u(x)&=u(0)e^{ax}+e^{ax}\int_{0}^{x}v(0)\,ds\\
&=u(0)e^{ax}+v(0)xe^{ax}
\end{align*}
Thus the only possible solutions are
\[u(x)=(A+Bx)e^{ax}\]
for some pair constants $A$ and $B$. 
By inspection every pair of constants give a solution.

he prove the last statement either examine he argument above carefully
or note that we have a solution if and only if
\begin{align*}
u_{0}&=A\\
u_{1}&=aA+B
\end{align*}
and these equations have a unique solution.

(v) Set $v=(D-aI)u$. Then $v(0)=u_{1}-au_{0}$
and, by (ii), 
\[v(x)=v(0)e^{ax}+e^{ax}\int_{0}^{x}e^{-as}f(s)\,ds,\]
and, using (ii) again
\[u(x)=u(0)e^{bx}+e^{bx}\int_{0}^{x}e^{-bs}v(s)\,ds.\]
Thus our system has exactly one solution.

(vi) Use part~(i) and parts~(iii) and~(iv).


\newpage\section*{Exercise~\ref{E;continue differential 2}}
(i) We have
\[\frac{d\ }{dx}e^{-ax}u(x)=Ke^{(c-a)x}\]
so
\[e^{-ax}u(x)=A+K\frac{e^{(c-a)x}}{c-a}\]
and
\[u(x)=Ae^{ax}+\frac{K}{c-a}e^{cx}\]
for some constant $A$.

(ii) We have
\[\frac{d\ }{dx}e^{-ax}u(x)=K\]
so
\[e^{-ax}u(x)=A+Kx\]
and
\[u(x)=(A+Kx)e^{ax}\]
for some constant $A$.

(iii) Set $v(x)=u'(x)-au(x)$. Then
\[v'(x)-bv(x)=Ke^{cx}\]
and
\[v(x)=Ce^{bx}+\frac{K}{c-b}e^{cx}\]
so
\[u(x)-au(x)=Ce^{bx}+\frac{K}{c-b}e^{cx}\]
and using linearity or repeating the argument of~(i)
\[u(x)=Ae^{ax}+Be^{bx}+\frac{K}{(c-a)(c-b)}e^{cx}\]
for some constants $A$ and $B$.

(iv) Set $v(x)=u'(x)-au(x)$. As in~(iii)
\[u(x)-au(x)=Ce^{bx}+\frac{K}{a-b}e^{ax}\]
so using linearity or repeating the argument of~(ii)
\[u(x)=Ae^{ax}+Be^{bx}+\frac{K}{a-b}xe^{ax}\]
for some constants $A$ and $B$.

(v) Set $v(x)=u'(x)-au(x)$. Then
\[v'(x)-av(x)=Ke^{ax}\]
and
\[v(x)=Ce^{ax}+Kxe^{ax}\]
so
\[\frac{d\ }{dx}e^{-ax}u(x)=B+Kx\]
whence
\[e^{-ax}u(x)=A+Bx+\frac{K}{2}x^{2}\]
and
\[u(x)=\left(A+Bx+\frac{K}{2}x^{2}\right)e^{-ax}\]
for some constants $A$ and $B$.

\newpage\section*{Exercise~\ref{E;difference 1}}
(i) If $u_{n}$ is defined uniquely for some $n\geq 0$,
then $u_{n+1}=y_{n+1}+au_{n}$ is uniquely defined.
Since $u_{0}$ is uniquely defined, it follows, by induction
that $u_{n}$ is defined uniquely for all $n\geq 0$.

If $u_{-n}$ is defined uniquely for some $n\geq 0$,
then $u_{-n-1}=a^{-1}(u_{-n}-y_{-n-1}$ is uniquely defined.
Since $u_{0}$ is uniquely defined, it follows, by induction
that $u_{-n}$ is defined uniquely for all $n\geq 0$.
Thus $u_{n}$ is defined uniquely for all $n$.

(ii) If $u_{n}$ and $u_{n+1}$
are defined uniquely for some $n\geq 0$,
then $u_{n+1}$ and $u_{n+2}=z_{n}-au_{n+1}-bu_{n}$
are uniquely defined.
Since $u_{0}$ and $u_{1}$
are uniquely defined, it follows, by induction
that $u_{n}$ is defined uniquely for all $n\geq 0$.

If $u_{-n}$ and $u_{-n-1}$
are defined uniquely for some $n\geq 0$,
then $u_{-n-1}$ and $u_{-n-2}=b^{-1}(z_{-n-2}-au_{-n-1}-u_{-n})$
are uniquely defined.
Since $u_{0}$ and $u_{-1}=b^{-1}(z_{1}-a\tilde{u}_{0}-\tilde{u}_{1})$
are uniquely defined, it follows, by induction
that $u_{n}$ is defined uniquely for all $n\leq 0$.
Thus $u_{n}$ is defined uniquely for all $n$.
\newpage\section*{Exercise~\ref{E;difference 2}}
Observe that
\begin{align*}
a&w_{n+2}+bw_{n+1}+cw_{n}\\&
=a(kv_{n+2}+u_{n+2})
+b(kv_{n+1}+u_{n+1})+c(kv_{n}+u_{n})\\
&=k(av_{n+2}+bv_{n+1}+cv_{n})+(au_{n+2}+bu_{n+1}+cu_{n})\\
&=k0+y_{n}=y_{n}.
\end{align*}

Suppose that
\[au_{n+1}+bu_{n}=y_{n}\]
and
\[av_{n+1}+bv_{n}=0.\]
If $k$ is constant and $w_{n}=kv_{n}+u_{n}$, then
\begin{align*}
aw_{n+1}+bw_{n}&=a(kv_{n+1}+u_{n+1})
+b(kv_{n}+u_{n})\\
&=k(av_{n+1}+bv_{n})+(au_{n+1}+bu_{n})\\
&=k0+y_{n}=y_{n}.
\end{align*}
\newpage\section*{Exercise~\ref{E;difference 3}}
(i) We have 
\begin{align*}
(E-aI)(E-bI)u_{n}&=(E-aI)u_{n+1}-bu_{n}\\
&=u_{n+2}-bu_{n+1}-au_{n+1}+abu_{n}\\
&=u_{n+2}-(a+b)u_{n+1}+abu_{n}\\
&=(E^{2}-(a+b)E+abI)u_{n}.
\end{align*}

(ii)  We have
\[(E-aI)v_{n}=v_{n+1}-av_{n}=a^{n+1}u_{n+1}-a^{n}u_{n}
=a^{n}(u_{n+1}-u_{n})=a^{n}w_{n}.\]

(iii) We have
\[u_{j+1}-u_{j}=y_{j}\]
so
\[u_{n+1}-u_{0}=\sum_{j=0}^{n}(u_{j+1}-u_{j})=\sum_{j=0}^{n}y_{j}.\]
for all $n\geq 0$,
ie 
\[u_{n}=u_{0}+\sum_{j=0}^{n-1}y_{j}\]
for $n\geq 1$.

Also
\[u_{-(j+1)}-u_{-j}=-y_{-j-1}\]
so, by what we have just shown,
\[u_{-n}=u_{0}-\sum_{j=0}^{n}y_{-j-1}\]
ie
\[u_{n}=u_{0}-\sum_{j=1}^{-n}y_{-j}\]
for $n\leq -1$.

\newpage\section*{Exercise~\ref{E;difference 4}}

(i) By Exercise~\ref{E;difference 3}~(iii),
\[u_{n}=1\]
for all $n$.

(ii) By Exercise~\ref{E;difference 3}~(iii),
\[u_{n}=\frac{b^{n}-1}{b-1}\]
for all $n$.

(iii) By Exercise~\ref{E;difference 3}~(iii),
\[u_{n}=n\]
for all $n$.

(iv) Since $\sum_{j=1}^{n}j=n(n+1)/2$, it follows from
Exercise~\ref{E;difference 3}~(iii)
that
\[u_{n}=n(n+1)/2\]

We now use Exercise~\ref{E;difference 3}~(ii) on each of the previous 
four parts in turn to get.

(v) $u_{n}=a^{n}$.

(vi) ${\displaystyle u_{n}=\frac{b^{n}}{b-a}}$

(vii) $u_{n}=na^{n}$

(viii) $u_{n}=n(n+1)a^{n}/2$.

Finally using linearity and parts~(v) and~(vi).

The general solution of $(E-aI)u_{n}=0$
is $u_{n}=Aa^{n}$.

The general solution of $(E-aI)u_{n}=b^{n}$
with $b\neq a$ is $u_{n}=Ab^{n}$.

\newpage\section*{Exercise~\ref{E;complement}}
(i) If
\[v_{n+2}-(a+b)v_{n+1}+abv_{n}=0,\]
then, setting $u_{n}=v_{n+1}-av_{n}$
we get
\[u_{n+1}-bu_{n}=0\]
so $u_{n}=Cb^{n}$
and
\[v_{n+1}-av_{n}=Cb^{n}\]
and by Exercises~\ref{E;difference 4}~(ix) and~(v)
and linearity
\[v_{n}=Aa^{n}+Bb^{n}.\]
Thus using Exercises~\ref{E;difference 1} and~~\ref{E;difference 2}
we have
\[u_{n}=Aa^{n}+Bb^{n}+v_{n},\]
where $A$ and $B$ are freely chosen constants.

(ii) If $a\neq 0$ and 

\[v_{n+2}-2av_{n+1}+a^{2}v_{n}=0,\]
then, arguing as before,
\[v_{n+1}-av_{n}=Aa^{n}\]
so
\[u_{n}=(A+Bn)a^{n}+v_{n},\]
where $A$ and $B$ are freely chosen constants.
\newpage\section*{Exercise~\ref{E;complement two}}
(i) Write $v_{n}=(E-aI)u_{n}$. Then
\[v_{n+1}-bv_{n}=Cx^{n}\]
so
\[v_{n}=Kb^{n}+\frac{C}{x-b}x^{n}\]
for some constant $K$.
Thus
\[u_{n+1}-u_{n}=Kb^{n}+\frac{C}{x-b}x^{n}\]
and
\[u_{n}=Aa^{n}+Bb^{n}+\frac{C}{(x-a)(x-b)}x^{n}
=Aa^{n}+Bb^{n}+\frac{C}{x^{2}-(a+b)x+ab}x^{n}\]
for some constants $A$ and $B$.

(ii) Write $v_{n}=(E-aI)u_{n}$. Then
\[v_{n+1}-bv_{n}=Ca^{n}\]
so
\[v_{n}=Kb^{n}+\frac{C}{a-b}a^{n}\]
for some constant $K$.
Thus
\[u_{n+1}-u_{n}=Kb^{n}+\frac{C}{a-b}a^{n}\]
and
\[u_{n}=Aa^{n}+Bb^{n}+\frac{C}{b-a}na^{n}.\]

(iii) We have
\[(E-I)^{2}u_{n}=C\]
so
\[(E-I)u_{n}=B+Cn\]
and
\[u_{n}=A+Bn+\tfrac{1}{2}Cn^{2}\]
for some constants $A$ and $B$.
\newpage\section*{Exercise~\ref{E;complement conjugate}}
We have
\[\alpha^{2}+b\alpha+a=0\]
so taking complex conjugates
\[\bar{0}=\overline{\alpha^{2}+b\alpha+c}=\bar{\alpha}^{2}+b\bar{\alpha}+c.\]
Thus $\bar{\alpha}$ is root.  Since $\bar{\alpha}\neq\alpha$
we have $\beta=\bar{\alpha}$. 

Since $A+B=A\alpha^{0}+B\bar{\alpha}^{0}$ is real we know that
\[\Im A=-\Im B.\]
Let $\alpha=u+iv$ with $u$ and $v$ real. Then
\[A\alpha+B\bar{\alpha}=(\Re A+i\Im A)(u+iv)+(\Re B+i\Im B)(u-iv)\]
is real so
\[u(\Im A+\Im B)+v(\Re A-\Re B)=v(\Re A-\Re B)\]
is real so, since $v\neq 0$, $\Re A=\Re B$ and $B=\bar{A}$.

Conversely if  $B=\bar{A}$ then
\[A\alpha^{n}+B\bar{\alpha}^{n}=A\alpha^{n}+\bar{A}\bar{\alpha}^{n}
=\overline{A\alpha^{n}+\bar{A}\bar{\alpha}^{n}}\]
so $A\alpha^{n}+B\bar{\alpha}^{n}$ is real.

(i) If $u_{j}$ and $u_{j+1}$ are real then $u_{j+1}$ 
$u_{j+2}=-bu_{j+1}-cu_{j}=0$ are real. Since $u_{0}$ and $u_{1}$
are real $u_{j}$ is real for all $j\geq 0$. To show that
$u_{j}$ is real for $j\leq 0$ consider the equation
\[u_{-(n+2)}+c^{-1}bu_{-(n+1)}+c^{-1}au_{-n}=0.\]

(ii) We have 
\begin{align*}
u_{0}&=A+B\\
u_{1}&=A\alpha+B\bar{\alpha}
\end{align*}
so
\[
(u_{1}-\bar{\alpha}u_{0})=A(\alpha-\bar{\alpha})
\]
and
\[A=\frac{u_{1}-\bar{\alpha}u_{0}}{\alpha-\bar{\alpha}}\]
Similarly
\[B=\frac{u_{1}-\alpha u_{0}}{\bar{\alpha}-\alpha}
=\bar{A}\]
so $u_{n}$ is real for all $n$.

\newpage\section*{Exercise~\ref{E;multiple roots}}
(i) We have
\begin{align*}
(E-I)\binom{n}{r}&=\binom{n+1}{r}-\binom{n}{r}\\
&=\frac{1}{r!}n(n-1)\dots(n-r+2)\big((n+1)-(n-r+1)\big)\\
&=\frac{1}{(r-1)!}n(n-1)\dots(n-r+2)=\binom{n}{r-1}.
\end{align*}

(ii) Using the particular solution of of (i)
and the known complementary solution we have
\[u_{n}=A+\binom{n}{r}\]
for some constant $A$.

(iii) We use induction on $k$. If the result is true
for $k=m$ then
\begin{align*}
(E-I)^{m+1}u_{n}=0&\Leftrightarrow (E-I)u_{n}=v_{n}
\ \text{with}\ (E-I)^{m}v_{n}=0\\
&\Leftrightarrow (E-I)u_{n}=\sum_{j=0}^{m-1}A_{m-1-j}\binom{n}{j}\\
&\Leftrightarrow u_{n}=\sum_{j=0}^{m}A_{m-j}\binom{n}{j}
\end{align*}
with $A_{j}$ arbitrary. The result holds for $k=1$
so it holds for all $k$ by induction.

(iv) By inspection or by using Exercise~\ref{E;difference 3},
\[u_{n}=\sum_{j=0}^{k-1}A_{k-1-j}\binom{n}{j}a^{j}.\]

(v) By inspection or using induction on $k$
\[u_{n}=\binom{n}{r+k}\]
is a solution so the general solution
is
\[u_{n}=\binom{n}{r+k}+\sum_{j=0}^{k-1}A_{k-1-j}\binom{n}{j}.\]
\newpage\section*{Exercise~\ref{E;cubic difference}}
Let
\[t^{3}+at^{2}+bt+c=0\]
have roots $\alpha$, $\beta$ and $\gamma$
(repeated roots repeated appropriately). Note that since
$c\neq 0$ no root is zero.

(i) If $\alpha$, $\beta$, $\gamma$ are distinct,
\begin{align*}
(E^{3}+aE^{2}+bE+cI)u_{n}=0
&\Leftrightarrow \big(E-\beta I)((E-\gamma I)\big)(E-\alpha I)u_{n}=0\\
&\Leftrightarrow (E-\alpha I)u_{n}=B'\beta^{n}+C'\gamma^{n}\\
&\Leftrightarrow u_{n}=A\alpha^{n}+B\beta^{n}+C\gamma^{n}
\end{align*}
for general constants $B'$, $C'$, $A$, $B$, $C$.

(ii) If $\alpha$ and $\beta$ are distinct but $\gamma=\alpha$,
\begin{align*}
(E^{3}+aE^{2}+bE+cI)u_{n}=0
&\Leftrightarrow \big(E-\alpha I)((E-\beta I)\big)(E-\alpha I)u_{n}=0\\
&\Leftrightarrow (E-\alpha I)u_{n}=A'\alpha^{n}+B'\beta^{n}\\
&\Leftrightarrow u_{n}=(A+A'n)\alpha^{n}+B\beta^{n}
\end{align*}
for general constants $B'$, $A'$, $A$, $B$.

(iii) If If $\alpha=\beta=\gamma$,
\begin{align*}
(E^{3}+aE^{2}+bE+cI)u_{n}=0
&\Leftrightarrow \big(E-\alpha I)((E-\alpha I)\big)(E-\alpha I)u_{n}=0\\
&\Leftrightarrow (E-\alpha I)u_{n}=A'+A'''\alpha^{n}\\
&\Leftrightarrow u_{n}=(A+A'n+A''n^{2})\alpha^{n}
\end{align*}
for general constants $A$, $A'$, $A''$, $A'''$.
\newpage\section*{Exercise~\ref{E;flea}}
(i) Just before the $n$th minute the flea will be
on the black dog with probability $1-p_{n-1}$
and jump to the white dog with probability $w$
or it will be on the white dog with probability $p_{n-1}$
and stay on the white dog with probability $1-b$.
Thus
\[p_{n}=(1-p_{n-1})w+p_{n-1}(1-b)=w+(1-b-w)p_{n-1}\]
for $n\geq 1$ and
\[(E-(1-b-w)I)p_{n}=w\]
for $n\geq 0$.

We seek a particular solution $p_{n}=c$, obtaining
\[(b+w)c=w\]
and the general solution
\[p_{n}=\frac{w}{b+w}+A(1-b-w)^{n}.\]
Since $p_{0}=1$, we have $A=b/(b+w)$ so
\[p_{n}=\frac{w}{b+w}+\frac{b}{w+b}(1-b-w)^{n}.\]
Since $0<b+w<2$ we have $|1-b-w|<1$ so $(1-b-w)^{n}\rightarrow 0$
and
\[p_{n}\rightarrow\frac{w}{b+w}\]
as $n\rightarrow\infty$.

(ii) As before
\[q_{n}=\frac{w}{b+w}+B(1-b-w)^{n}\]
for some constant $B$. Since $q_{0}=0$, $B=-w/(b+w)$
and
\[q_{n}=\frac{w}{b+w}-\frac{w}{w+b}(1-b-w)^{n}
\rightarrow\frac{w}{b+w}\]
as $n\rightarrow\infty$.

(The process gradually forgets how it starts.)

(iii) If $b+w=0$ then $b=w=0$ and the flea stays on
the dog it starts on.

If $b+w=2$ then $b=w=1$ and after an even number
of seconds it it will be on its starting dog
and after an odd number on the the other.

(In neither case does the process forget how it started.)


\newpage\section*{Exercise~\ref{E;drunk}}
We have
\[u_{n}=\tfrac{1}{2}u_{n+1}+\tfrac{1}{2}u_{n-1}\]
so
\[(E-I)^{2}u_{n}=0\]
and
\[u_{n}=A+Bn\]
We have $u_{0}=0$ so $A=0$ and $u_{N}=1$ so $b=1/N$
and
\[u_{n}=u_{N}(n)=\frac{n}{N}.\]
\newpage\section*{Exercise~\ref{E;casino set aside}}
If the casino has a fortune of $n$, then at the next
bet it has a probability of $p$ of gaining $1$ so
its probability of going bankrupt is now $u_{n+1}$,
a probability of $r$ of neither losing nor gaining so
its probability of going bankrupt is now $u_{n}$,
and  probability of $q$ of neither losing $1$ so
its probability of going bankrupt is now $u_{n-1}$.
Thus
\[u_{n}=pu_{n-1}+ru_{n}+qu_{n+1}\]
for $1\leq n\leq N-1$. If $n=0$ it is bankrupt so $u_{0}=0$.
If $n=N$ it stops so $u_{N}=1$.

(ii) We have
\[(qE^{2}-(p+q)E+pI))u_{n}=0\]
so
\[(E-I)(E-(p/q))u_{n}=0\]
whence
\[u_{n}=A+B\left(\frac{p}{q}\right)^{n}.\]
Since $u_{0}=0$ we have $A=-B$ and since, $u_{N}=1$,
$A=(1-(p/q)^{N})^{-1}$. Thus
\[u_{n}=\frac{1-\left(\frac{p}{q}\right)^{n}}
{1-\left(\frac{p}{q}\right)^{N}}.\]

(iii) If $p=q$ we get
\[(pE^{2}-2pE+pI))u_{n}=0\]
so $(E^{2}-E+I))u_{n}=0$ and, exactly as in Exercise~\ref{E;drunk},
\[u_{n}=u_{N}(n)=\frac{n}{N}.\]

(iv) Allowing $N\rightarrow\infty$ in (ii) and (iii)
we see that bankruptcy is certain if $p\geq q$.
If $p<q$ the probability of bankruptcy
starting with a fortune $n$ is
\[1-\left(\frac{p}{q}\right)^{n}\]
which may be made as small as we wish by taking $n$ large enough.
\newpage\section*{Exercise~\ref{E;explain ruin equation}}
Suppose that the casino has $N$ units.
If it takes a bet, then
with probability $p$ it will 
lose, have a new fortune of $N-1$
and expect to survive a further $e_{N-1}$ bets.
With probability $1-p$ it will win, pay its owners $1$ 
so have a new fortune of $N$
and expect to survive a further $e_{N}$ bets.
Thus
\[e_{n}=1+pe_{N-1}+(1-p)e_{N}.\]
\newpage\section*{Exercise~\ref{E;repeated ruin}}
Suppose that the casino has $n$ units with $1\leq n\leq N-1$.
If it takes a bet, then
with probability $p$ it will 
lose, have a new fortune of $n-1$
and expect to pay out a further $f_{n-1}$ to its owners.
With probability $1-p$ it will win, 
have a new fortune of $n+1$
and expect to pay out a further $f_{n+1}$ to its owners.
Thus
\[f_{n}=pf_{n-1}+(1-p)f_{n+1}.\]
Suppose that the casino has $N$ units.
If it takes a bet, then
with probability $p$ it will 
lose, have a new fortune of $N-1$
and expect to pay out a further $f_{N-1}$ to its owners
With probability $1-p$ it will win, pay its owners $1$ 
so have a new fortune of $N$
and expect to pay out a further $f_{N}$.
Thus
\[\tag*{$\bigstar$} f_{N}=pf_{N-1}+(1-p)(1+f_{N}).\]
If the casino has fortune $0$ it is bankrupt so $f_{0}=0$.

Our standard calculation shows that
\[f_{n}=A\left(1-\left(\frac{1-p}{p}\right)^{n}\right)\]
Equation $\bigstar$ now gives
\[p(f_{N}-f_{N-1})=1-p\]
and
\[A=\frac{1}{1-2p}\left(\frac{1-p}{p}\right)^{N}\]
whence
\[f_{n}=\frac{1}{1-2p}\left(\frac{1-p}{p}\right)^{N}
\left(1-\left(\frac{1-p}{p}\right)^{n}\right)\]
and, so in particular,
\[f_{N}=\frac{1}{1-2p}
\left(\left(\frac{1-p}{p}\right)^{N}-1\right).\]
\newpage\section*{Exercise~\ref{E;repeated half ruin}}
Since the game is fair, the expected return to investors
is precisely what they put in. Thus $f_{n}=n$.
\newpage\section*{Exercise~\ref{E;combined ruin}}
The expected time to bankruptcy $e_{n}$ satisfies
\[e_{n}=1+pe_{n-1}+qe_{n+1}+re_{n}\]
for $1\leq n\leq N-1$ while $e_{0}=0$
and
\[e_{N}=1+pe_{N-1}+(q+r)e_{N}.\]

Thus
\[(qE^{2}-(p+q)E+p)e_{n}=1\]
or
\[(qE-p)(E-1)e_{n}=1\]
We try a particular solution $e_{n}=Kn$ obtaining $K=(q-p)^{-1}$
and a general solution
\[e_{n}=A+B\left(\frac{p}{q}\right)^{n}+\frac{n}{q-p}\]
Since $e_{0}=0$, $B=-A$ and
\[e_{n}=A\left(1-\left(\frac{p}{q}\right)^{n}\right)+\frac{n}{q-p}.\]
The condition $e_{N}=1+pe_{N-1}+(q+r)e_{N}$
gives
\[e_{N}-e_{N-1}=p^{-1}\]
so
\[A\left(\left(\frac{p}{q}\right)^{N}
-\left(\frac{p}{q}\right)^{N-1}\right)=\frac{1}{q-p}-\frac{1}{p}\]
whence we obtain $A$ and $e_{N}$.

The expected sum withdrawn  $f_{n}$ if the casino starts with $n$ 
satisfies
\[f_{n}=pf_{n-1}+rf_{n}+qf_{n+1}\]
if $1\leq n\leq N-1$
and $f_{0}=0$, 
\[f_{N}=pf_{N-1}+rf_{N}+q(1+f_{N})=q+(1-p)f_{N})+pf_{N-1}\]
so
\[pf_{N}=q+pf_{N-1}.\]

We have
\[(qE-p)(E-1)f_{n}=1\]
so
\[f_{n}=A+B\left(\frac{p}{q}\right)^{n}\]
and since $f_{0}=0$, $B=-A$ and
\[f_{n}=A\left(1-\left(\frac{p}{q}\right)^{n}\right).\]
Applying the other end condition
\[A\left(\frac{p}{q}\right)^{N-1}
\left(1-\frac{p}{q}\right)=\frac{q}{p}\]
whence we obtain $A$ and $f_{N}$.
\newpage\section*{Exercise~\ref{E;drunkard}}
$Y_{n}(r)$ is my fortune if I play fair heads and tails
for $n$ goes starting with a fortune of $r$
and I am not stopped by bankruptcy.
The first value of $n$, if any, with
$Y_{n}(r)=0$ corresponds to bankruptcy.
  
If  I start with $n$ and avoid bankruptcy by reaching $N$
then my probability of escaping bankruptcy is $n/N$.
Allowing $N\rightarrow\infty$ we see that if
I play indefinitely the probability of bankruptcy is $1$. 

If I have a fortune of $N-1\geq n\geq 1$ then at the next
bet I have a probability of $1/2$ of gaining $1$ so
I will have lasted one further turn
and my expected survival time will be $e_{r+1}$
and a probability of $1/2$ of gaining $1$ so
I will have lasted one further turn
and my expected survival time will be $e_{r-1}$.
Thus
\[\tag*{$\bigstar$}e_{n}=1+\tfrac{1}{2}(e_{n+1}+e_{n-1})\]
for $N-1\geq n\geq 1$. Since I stop at $0$ and at $N$
we have $e_{0}=e_{N}=0$.

$\bigstar$ gives $e_{n+1}-2e_{n}+e_{n-1}=-2$.
We seek a solution of the form $Cn^{2}$ obtaining
\[C(2n^{2}+2-2n^{2})=-2\]
when $C=1$. Since
$u_{n+1}-2u_{n}+u_{n-1}=0$ has the general solution $A+bN$
we have
\[e_{n}=-n^{2}+Bn+A\]
Since  $e_{0}=e_{N}=0$, $a=0$ and $B=-N$ whence
\[e_{n}=e_{n}(N)=n(N-n).\]

If $n$ is fixed
\[e_{n}(N)=n(N-n)=nN-n^{2}\rightarrow\infty\]
as $N\rightarrow\infty$.
\newpage\section*{Exercise~\ref{E;double cube}}
(i) We note that the position of the players is symmetric
and that in each case, if the double is accepted,
the player who doubles moves from a player who can double at
will to a player who cannot double
facing an opponent who can double at will.
Thus the decision is always the same.

(ii) Suppose the players are at $M$. Let $p$ be the
probability that the first player wins
if doubling is prohibited and $q$ the
probability that the players will reach $-M$ before the game ends
(again doubling being prohibited).
\begin{align*}
p&=\Pr(\text{players never pass through $-M$})\\
&\qquad+\Pr(\text{players pass through $-M$ and first player wins})\\
&=(1-q)+q(1-p)=1-qp
\end{align*}
Thus, assuming that this is the first double
and the second player accepts,
we know that there is a probability
$1-q$ that the first player will win
(so the game will have value $-2$ to the second player) without
passing through $-M$ and a probability $1-q$ that the game
will pass through $-M$, at which point the game
will have value $-2$ to the first player and so value $2$
the second. Thus
\begin{align*}
-1&=\text{expected value for the second player if accepts}\\
&=-2(1-q)+2q
\end{align*}
Thus $q=1/4$ and $p=4/5$.

(iii) Observe that the players are playing a standard heads
tails, so if $p_{r}$ is the probability that the first
player wins from the point $r$ we have
\[p_{r}=\tfrac{1}{2}p_{r-1}+\tfrac{1}{2}p_{r+1}\]
and $p_{N}=1$, $p_{-N}=0$ and by standard calculations
\[p_{r+1}=\frac{r+N}{2N}\]
so, if $N$ is divisible by $5$ we have critical value
$M=3N/5$.
\newpage\section*{Exercise~\ref{E;Hamlet}}
(i) Write $M$ for the total number of coins involved. 
Let $e_{r}$ be the expected time to the end if
Rosencrantz has fortune $r$. With probability
$1/2$ his fortune is $r$ after one throw,
With probability
$1/4$ his fortune is $r-1$ after one throw
and with probability
$1/4$ his fortune is $r+1$ $[1\leq r\leq M-1]$.
Thus
\[e_{r}=1+\frac{1}{4}(e_{r-1}+2e_{r}+e_{r+1})\]
ie
\[e_{r+1}-2e_{r}+e_{r-1}=4.\]
A particular solution is $e_{r}=Ar^{2}$ with
$A=2$. Thus
\[e_{r}=Br+C+2r^{2}.\]
Since $e_{0}=e_{M}=0$ we have
$C=0$ and $B=-2M$. Thus
\[e_{r}=2(r^{2}-Mr)=2rg.\]

(ii) The probability that any man wins a round is the probability
that the other two throw the opposite ie $1/4$. Thus 
we have
\[e_{hrg}=1+\frac{1}{4}(e_{(h+2)(r-1)(g-1)}+e_{(h-1)(r+2)(g-1)}
+e_{(h-1)(r-1)(g+2)}+e_{hrg}\]
so
\[\tag*{$\bigstar$}4=e_{(h+2)(r-1)(g-1)}+e_{(h-1)(r+2)(g-1)}
+e_{(h-1)(r-1)(g+2)}-3e_{hrg}\big).\]
Further $e_{0uv}=e_{u0v}=e_{uv0}=0$.

We try
\[e_{hrg}=Ahrg\]
which certainly satisfies the boundary conditions.

The equation $\bigstar$ is satisfied if and only if
\begin{align*}
4&=-A\big((h+2)(r-1)(g-1)+(h-1)(r+2)(g-1)\\
&\qquad\qquad+(h-1)(r-1)(g+2)
-3hrg\big)\\
&=A\big(3(h+r+g)-6\big)\\
\end{align*}
ie
\[A=\frac{4}{3N-6}\]
where $N=h+r+g$.

Since $\bigstar$ has at most one solution satisfing the boundary
condition
and we have found a solution, this must be the unique soltion.
We have
\[e_{hrg}=hrg\frac{4}{3N-6}.\]

If they start with $100$ coins each they
are likely to reach England before they finish the game.

\newpage\section*{Exercise~\ref{E;Cow}}
(i) Jack will be paid $j$ with probability $p_{j}$ if $j\geq m$.
With probability $\sum_{j=1}^{m-1}p_{j}$ he will take the cow
home and with probability $q$ the cow will not die
and he will be in exactly the same position with expected gain 
$e_{m}$.
Thus
\[e_{m}=\sum_{j=m}^{n}jp_{j}+\left(\sum_{j=1}^{m-1}p_{j}\right)qe_{m}\]
so
\[\left(1-q \sum_{j=1}^{m-1}p_{j}\right)e_{m}=\sum_{j=m}^{n}jp_{j}\]
as stated.

We claim that $e_{m}$ increases and then decreases.
Matthew Towers gives the following argument.
Observe that this statement is equivalent to saying
that $e_{m+1} \leq e_m$ implies $e_{m+2} \leq e_{m+1}$
and this is equivalent to saying that
\begin{gather*}
p_m\left(m-q\left(m\sum_{j=0}^mp_j + \sum_{j=m+1}^n jp_j\right)\right)
\geq 0 \\
m-q\left(m\sum_{j=0}^mp_j + \sum_{j=m+1}^n jp_j\right)\geq 0
\end{gather*}
implies
\begin{equation*}                              
  m+1 - q\left(\sum_{j=0}^m p_j + m \sum_{j=0}^mp_j + \sum_{j=m+1}^n
    jp_j\right)\geqslant 0
\end{equation*}
and this implication follows from the fact that
\[q\sum_{j=0}^m p_j \leq 1.\]

Let us write $A_{m}=\sum_{j=m}^{n}jp_{j}$ and
$B_{m}=1-q \sum_{j=1}^{m-1}p_{j}$. Then
\begin{align*}
e_{m+1}-e_{m}&=\frac{A_{m+1}}{B_{m+1}}-\frac{A_{m}}{B_{m}}\\
&=\frac{A_{m}-mp_{m}}{B_{m}-qp_{m}}-\frac{A_{m}}{B_{m}}\\
&=\frac{(qA_{m}-mB_{m})p_{m}}{(B_{m}-qp_{m})B_{m}}.
\end{align*}
Thus $e_{m+1}-e_{m}\geq 0$ if $qA_{m}-mB_{m}\geq 0$
and $e_{m+1}-e_{m}\leq 0$ if $qA_{m}-mB_{m}\leq 0$.

But $qA_{m}$ is a decreasing and $mB_{m}$ is an increasing
sequence so $e_{m+1}-e_{m}$ is a decreasing sequence
and the result follows. 

Jack should choose $m=m_{0}$.

(ii) If he has to take his cow home he incurs an extra cost of $k$
so his expected gain $e_{m}$ is now
\[e_{m}=\sum_{j=m}^{n}jp_{j}+\left(\sum_{j=1}^{m-1}p_{j}\right)(-k+qe_{m})\]
so
\[e_{m}=\frac{\sum_{j=m}^{n} jp_{j}-k\sum_{j=1}^{m-1}p_{j}}
{1-q\sum_{j=1}^{m-1}p_{j}}.\]

Let us write $A_{m}=\sum_{j=m}^{n}jp_{j}-k\sum_{j=1}^{m-1}p_{j}$ and
$B_{m}=1-q \sum_{j=1}^{m-1}p_{j}$.
Then
\begin{align*}
e_{m+1}-e_{m}&=\frac{A_{m+1}}{B_{m+1}}-\frac{A_{m}}{B_{m}}\\
&=\frac{A_{m}-(m+k)p_{m}}{B_{m}-qp_{m}}-\frac{A_{m}}{B_{m}}\\
&=\frac{(qA_{m}-(m+k)B_{m})p_{m}}{(B_{m}-qp_{m})B_{m}}.
\end{align*}

But $qA_{m}$ is a decreasing and $(m+k)B_{m}$ is an increasing
sequence so $e_{m+1}-e_{m}$ is a decreasing sequence.
Thus
there is an integer $m_{0}$ with $0\leq m_{0}\leq n$
such that $e_{m-1}\leq e_{m}$ when $1\leq m\leq m_{0}$
and $e_{m}\leq e_{m+1}$ when $m_{0}\leq m\leq n-1$.

Note that in case~(i) (except in the trivial cases
$p_{0}=1$ or $q=1$) Jack will have $m_{0}\geq 1$
but in case~(ii) Jack may be happy to give the cow away
(this is obvious if $k>n$). We have assumed that beans
are traded in integral multiples but the ideas clearly
work more generally.
\newpage\section*{Exercise~\ref{E;Car}}
The computation of $V_{0}$ is essentially that
of the onesided duel.
\[V_{0}=\sum_{j=0}^{\infty}j\Pr(\text{$A_{-j}$ first unoccupied space})\]
so
\[V_{0}=q(1+V_{0})\]
and $V_{0}=q/p$.

If I use my plan with $m=n$ then, with probability $q$, the $n$th state
is free and I walk $n$ units and with probability $p$ it
is occupied and my expected walk is that obtained by taking $m=n-1$.
Thus
\[V_{n}=pn+qV_{n-1}.\]

If we look for a solution of
\[u_{n}=pn+qu_{n-1}\]
with $u_{n}=Bn+C$, we obtain
\[Bn+C=pn+qB(n-1)+qC\]
so $B=1$, $C=-q/p$. By inspection $u_{n}=n-q/p$ is indeed a 
particular solution. Thus, the general
solution is
\[u_{n}=Aq^{n}+n-\frac{q}{p}.\]

We now know that
\[V_{n}=Aq^{n}+n-\frac{q}{p}\]
for some constant $A$. Since $V_{0}=q/p$
$A=(2q/p)$ so
\[V_{n}=n+\frac{(2q^{n}-1)q}{p}\]
for $n\geq 0$ as stated.

Thus
\[V_{n-1}-V_{n}=-1+2q\frac{q^{n-1}-q^{n}}{p}=2q^{n}-1\]
and
\[V_{n}-V_{n-1}
\begin{cases}
\geq 0&\text{if $2q^{n}-1\geq 0$}\\
\leq 0&\text{if $2q^{n}-1\leq 0$}
\end{cases}
\]
so $V_{n}$ is minimised when $n$ takes its largest value with
\[n\leq \frac{\log(1/2)}{\log q}.\]
\newpage\section*{Exercise~\ref{E;John Law}}
(i) We have
\begin{align*}
\Pr(\text{Law loses})
&=\Pr(\text{double six on a particular throw})^{6}\\
&=\left(\frac{1}{36}\right)^{2}\approx 4.6\times 10^{-10}.
\end{align*}

(ii) About $2.2\times 10^{9}$ seconds.

(iii) He has paid $1$ shilling for a bet worth approximately
\[ 4.6\times 10^{-10}\times 10^{3}\times 20
=9.2 \times 10^{-4}\approx 10^{-3}\]
shillings.

(iv) No. The Kelly criterion deals with the long run
and even if we bet every second of a lifetime we will
not have made enough bets for the appropriate Tchebychev
inequality to give any information.
\newpage\section*{Exercise~\ref{E;national lottery}}
The probability of getting the right numbers in some fixed order
is
\[\frac{1}{49}\times \frac{1}{48}\times\frac{1}{47}\times \frac{1}{46}
\times\frac{1}{45}\times \frac{1}{44}\]
and there are $6!$ ways of obtaining the right numbers 
in any order so the probability of winning is
\begin{align*}
6!\times\frac{1}{49}\times 
\frac{1}{48}\times\frac{1}{47}\times \frac{1}{46}
\times\frac{1}{45}\times \frac{1}{44}
&=\frac{1}{49}\times\frac{1}{47}\times \frac{1}{46}
\times\frac{1}{3}\times \frac{1}{44}\\
&=\frac{1}{13983816}.
\end{align*}
\newpage\section*{Exercise~\ref{E;calculus lottery}}
Observe that
\[\frac{d\ }{da}ae^{-a}=e^{-a}-ae^{-a}=(1-a)e^{-a}\]
so $ae^{-a}$ increases with $a$ until $a=1$ and then
decreases. Thus
$ae^{-a}$ is maximised by taking
$a=1$.
\newpage\section*{Exercise~\ref{E;exact number winners}}
Assuming that $N$ is so large that we may take
\[\Pr(\text{exactly $m$ winners})=\frac{1}{m!}a^{m}e^{-a},\]
we must seek to maximise $f(a)=a^{m}e^{-a}$.

Now
\[f'(a)=(m-a)a^{m-1}e^{-a}\]
so $f$ increases as $a$ increases from $0$ to $m$
and then decreases. We should take $a=m$.
\newpage\section*{Exercise~\ref{E;half lottery}}
Let $X_{j}$ be the sum paid out to the $j$th participant
The expected value of the total sum paid out is
\begin{align*}
{\mathbb E}\sum_{j=1}^{N}X_{j}&=\sum_{j=1}^{N}{\mathbb E}X_{j}
=N{\mathbb E}X_{1}\\
&=N\times \frac{N}{2m}=\frac{N}{2}.
\end{align*}
\newpage\section*{Exercise~\ref{E;lottery escape}}
Since
\[\sum_{r=2m+1}^{\infty}\frac{m^{r}}{r!}\leq  2u_{m+1}\]
it is sufficient to find a $k$ so that
\[\sum_{r=2m+k+1}^{\infty}\frac{m^{r}}{r!}
\leq \frac{u_{m+1}}{200}.\]
But arguing as in Lemma~\ref{L;bound exponential remainder},
we have
\[\sum_{r=2m+k+1}^{\infty}\frac{m^{r}}{r!}
\leq u_{2m+1}\sum_{r=k+1}^{\infty} 2^{-r}=2^{-k}u_{2m+1}\]
so $k=8$ will certainly do.
\newpage\section*{Exercise~\ref{E;unsafe}}
\[e^{-5}\frac{5^{11}}{11!}\approx 0.0082\]
\[e^{-10}\frac{10^{21}}{21!}\approx 0.00089\]
\newpage\section*{Exercise~\ref{E;birthday}}
(i) We did the case $-1/2<x\leq 0$
in Exercise~\ref{E;rigour logarithm}.
Now we consider $0\leq x<1/2$.

If $g(x)=x-\log(1+x)$, then 
\[g'(x)=1-\frac{1}{1+x}>0\]
for $0\leq x$ so $g(x)\geq g(0)=0$ and
\[\log(1+x)\leq x\]
for all $x\geq 0$.

If $f(x)=x^{2}+\log(1+x)-x$, then
\[f'(x)=2x-1+\frac{1}{1+x}=\frac{2x^{2}+x}{1+x}>0\]
for $0\leq x$ so $f(x)\geq f(0)=0$ and
\[\log(1+x)\geq x-x^{2}\]
for all $x\geq 0$.

The result follows.

(ii) By (i) we know that If $n\geq 2|a|^{-1}$
\[\left|\frac{a}{n}-\log\left(1+\frac{a}{n}\right)\right|
\leq \left(\frac{a}{n}\right)^{2}\]
so
\[\left|a-n\log\left(1+\frac{a}{n}\right)\right|
\leq \frac{a^{2}}{n}\rightarrow 0\]
as $n\rightarrow\infty$.

We have shown that 
\[n\log\left(1+\frac{a}{n}\right)\rightarrow\log a\]
so taking exponentials
\[\left(1+\frac{a}{n}\right)^{n}\rightarrow e^{a}\]
as $n\rightarrow\infty$.

(iii) If
\[\sum_{r=1}^{n-1}r^{2}\leq \frac{n^{3}}{3}\]
then
\begin{align*}
\sum_{r=1}^{n}r^{2}&\leq \frac{n^{3}}{3}+n^{2}\\
&\leq\frac{1}{3}(n^{3}+3n^{2})\\
&\leq \frac{1}{3}(n^{3}+3n^{2}+3n+1)\\
&=\frac{(n+1)^{3}}{3}
\end{align*}
so, since
\[\sum_{r=1}^{1}r^{2}=1\leq \frac{8}{3}=\frac{(1+1)^{3}}{3},\]
the result follows by induction.

[Or we could use known formulae for $\sum_{r=1}^{n}r^{2}$.]

(iv) Provided that $n$ is so large that $N(n)|a|/n<1/2$,
we have
\[\left|\frac{ra}{n}-\log\left(1+\frac{ra}{n}\right)\right|
\leq \left(\frac{ra}{n}\right)^{2}\]
for all $1\leq r\leq N(n)$ and so
\[\left|\sum_{r=1}^{N(n)}\frac{ra}{n}-
\sum_{r=1}^{N(n)}\log\left(1+\frac{ra}{n}\right)\right|
\leq \sum_{r=1}^{N(n)}\left(\frac{ra}{n}\right)^{2}\]
so
\[\left|\frac{N(n)(N(n)+1)a}{2n}-
\sum_{r=1}^{N(n)}\log\left(1+\frac{ra}{n}\right)\right|
\leq \frac{(N(n)+1)^{3}a^{2}}{3n^{2}}
\leq \frac{N(n)^{3}a^{2}}{n^{2}}.\]
Thus
\begin{align*}
\left|(1+N(n)^{-1})a-\frac{2}{N(n)^{2}}
\sum_{r=1}^{N(n)}\log\left(1+\frac{ra}{n}\right)\right|
&\leq \frac{(N(n)+1)^{3}a^{2}}{3n^{2}}\\
&\leq \frac{2N(n)a^{2}}{n}\rightarrow 0.
\end{align*}
as $n\rightarrow\infty$
and so
\[\frac{2}{N(n)^{2}}
\sum_{r=1}^{N(n)}\log\left(1+\frac{ra}{n}\right)\rightarrow a\]
as $n\rightarrow\infty$.
Taking exponentials we deduce that
\[\left[\prod_{r=1}^{N(n)}\left(1+\frac{ra}{n}\right)\right]^{2/N(n)^{2}}
\rightarrow e^{a}.\]

(v) We have
\begin{align*}
\Pr(\text{some common birthday}&=1-\Pr(\text{no common birthday})\\
&=1-\prod_{r=1}^{m}\left(1-\frac{r}{365}\right).
\end{align*}
If $m$ is not large, then taking $a=-1$, $n=365$, $N(n)=m$ 
in (iv) we have 
\[\Pr(\text{some common birthday})
\approx
1-e^{aN(n)^{2}/2}=1-e^{-m^{2}/365}.\]

(vi) Thus the approximate number required for the probability
of joint birthdays to be at least $1/2$ is given by
\[m^{2}/(2\times 365)=\log 2\]
so $m\approx 22.49$. This suggests $23$ people are required.

Exact calculation shows that with $22$ people the probability of
coincidence is about $.48$ (and certainly less than $1/2$)
and with $23$ people the probability of
coincidence is about $.51$ (and certainly more than $1/2$).

(vii) We take a $365$ day year. \begin{align*}
\Pr(\text{some common birth-hour})&=1-\Pr(\text{no common birth-hour})\\
&=1-\prod_{r=1}^{m}\left(1-\frac{r}{365\times 24}\right).
\end{align*}
Proceeding as in (vi) and (vii)
with $a=-1$, $n=365\times 24$, $N(n)=m$ we see that
the approximate number required for the probability
of joint birth-hours to be at least $1/2$ is given by
\[m^{2}/(2\times 365\times 24)=\log 2\]
so $m\approx 110.19$. This suggests $111$ people are required.

(viii) This is just the birthday problem again. The probability
of two people getting the same password is approximately
$1-e^{-m^{2}/2n}$ and to make this small we need $m^{2}/2n$ very small.
\newpage\section*{Exercise~\ref{E;rough birthday}}
(i) This is just the basic case of the AM/GM inequality.
A direct proof is as follows.
\[\left(\frac{x+y}{2}\right)^{2}-xy
=\left(\frac{x-y}{2}\right)^{2}\geq 0\]
with equality if and only if $x=y$.

(ii) If we specify who is to have which birthday
the probability is $p_{j(1)}p_{j(2)}\dots p_{j(n)}$.
But there are $n!$ ways of assigning birthdays in this pattern so
\begin{align*}
\Pr(\text{together the $n$ people have birthdays on}&
\ \text{days $j(1)$, $j(2)$, \dots, $j(n)$})\\
&=n!p_{j(1)}p_{j(2)}\dots p_{j(n)}.
\end{align*}
and summing over all sets of $n$ distinct birthdays
\begin{align*}
\Pr(\text{the $n$ people do not}&\ \text{share birthdays})\\
&=n!\sum_{1\leq j(1)<j(2)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}.
\end{align*}

(iii) Thus collecting terms
\begin{align*}
\sum_{1\leq j(1)<j(2)<\dots<j(n)\leq N}&p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&=
p_{1}p_{2}\sum_{3\leq j(3)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&+(p_{1}+p_{2})
\sum_{3\leq j(2)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&+\sum_{3\leq j(1)<j(2)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}.
\end{align*}

(iv) If $q_{j}$ and $p_{j}$ are as specified
\begin{align*}
\sum_{1\leq j(1)<j(2)<\dots<j(n)\leq N}&p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&=
p_{1}p_{2}\sum_{3\leq j(3)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&+(p_{1}+p_{2})
\sum_{3\leq j(2)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&+\sum_{3\leq j(1)<j(2)<\dots<j(n)\leq N}p_{j(1)}p_{j(2)}\dots p_{j(n)}\\
&=p_{1}p_{2}\sum_{3\leq j(3)<\dots<j(n)\leq N}q_{j(1)}q_{j(2)}\dots q_{j(n)}\\
&+(p_{1}+p_{2})
\sum_{3\leq j(2)<\dots<j(n)\leq N}p_{j(1)}q_{j(2)}\dots q_{j(n)}\\
&+\sum_{3\leq j(1)<j(2)<\dots<j(n)\leq N}q_{j(1)}q_{j(2)}\dots q_{j(n)}\\
&\leq
q_{1}q_{2}\sum_{3\leq j(3)<\dots<j(n)\leq N}q_{j(1)}q_{j(2)}\dots q_{j(n)}\\
&+(q_{1}+q_{2})
\sum_{3\leq j(2)<\dots<j(n)\leq N}q_{j(1)}q_{j(2)}\dots q_{j(n)}\\
&=
\sum_{1\leq j(1)<j(2)<\dots<j(n)\leq N}q_{j(1)}q_{j(2)}\dots q_{j(n)}
\end{align*}
with equality if and only if $p_{1}=p_{2}$.

This gives the required result.

(v) If it is not true that $p_{j}=1/n$ for all $j$ then we can find
$r\neq s$ with $p_{r}\neq p_{s}$. Applying (iv) we can find
another
set of birthday probabilities such that coincidences are  
strictly less probable.

Thus if there is a set of probabilities
which minimises the probability of coincidence,
this must be $p(j)=1/N$ for all $j$.
\newpage\section*{Exercise~\ref{E;El Supremo}}
If $k$ is small and we book $500+k$ people the probability
that there will be $j$ cancellations (with $j$ also small) is
approximately
\[\frac{1}{j!}\left(\frac{500+k}{500}\right)^{j}
\exp\left(-\frac{500+k}{500}\right)
\approx \frac{1}{j!}e^{-1}.\]

Thus our expected extra profit if we overbook by $k$
is approximately.
\begin{align*}
u_{k}&=100k-200\sum_{r=0}^{k}(k-r)\Pr(\text{$r$ cancellations})\\
&=100k-200\sum_{r=0}^{k}\frac{1}{r!}(k-r)e^{-1}
\end{align*}
Now
\[u_{k}-u_{k-1}=100-200\sum_{r=0}^{k}\frac{1}{r!}e^{-1}=v_{k}\]
say. We observe that
$v_{k+1}-v_{k}<0$ and $v_{k}\rightarrow -100$
as $k\rightarrow \infty$.
Thus $u_{k}$ increases to a maximum and then decreases.
Now
\[u_{1}-u_{0}=100-200e^{-1}\approx 26.4>0\]
and
\[u_{2}-u_{1}=100-200\times 2e^{-1}\approx -47.1\]
so we should make $501$ bookings.
\newpage\section*{Exercise~\ref{E;national lottery two}}
The probability that a random combination
will not contain $1$ to $5$ is
\[\frac{44}{49}\times\frac{43}{48}\times\frac{42}{47}
\frac{41}{46}\times\frac{40}{45}\times\frac{38}{44}\approx .49\]
so about half the combinations are used.
In about half the draws a `forbidden number will turn up'
and no one will get a prize. In about half the draws
there will be no forbidden draws and the result will
be those of lottery in which the number of possible out comes has 
been more or less halved.

In the notation used in this section instead of the chance 
of any single participant winning being $m/N$
then (in non-forbidden weeks) the chance 
of any  single participant winning being $2m/n$.
\[\frac{\Pr(\text{$r$ winners in  non-forbidden week})}
{\Pr(\text{$r$ winners in old scheme})}
=\frac{\big((2m)^{r}/r!\big)e^{-2m}}{\big(m^{r}/r!\big)e^{-m}}
=2^{r}e^{-m}\]
and, as one would expect there is a much higher chance of multiple
prize winners.

In cases (C) and (D) the actions of others do not
influence the prize. Whatever you do you have
the same expectation of about half a pound.

Now look at (A) and (B). In this case if
you do (b) or (c) you are guaranteed to be
sole winner so you are better off than
the others. Cases (b) and (c) offer the same chance of winning.
(If there were other smaller prizes offered you
might be better under (b) but that is a different question.)

In case (d) you have the same chance of winning
with $k$ others $[k=0,1,2,\dots]$ as everybody else.
If you do (a) you have probability about $1/2$ of ending up
in a case like (b) or (c) and a
probability about $1/2$ of ending up
in a case like (d). You are better off than under (d)
but worse off than under (b) or (c).

However, in case (A) if you choose (d)
and if there is then a probability $p$ that you will win,
it will then be the case that
the probability that you will win and not share
is not far from $6p/7$. Thus although you are better off
doing (b) or (c) you are not much better off.
If you do (b) or (c)  you have
expectation of about half a pound.

In case (B) it is clear that (b) and (c) are much better than
(d). The twenty eight million other players have bought
tickets in a lottery where with probability about $1/2$
there is one prize (shared if necessary) of fourteen million
pounds. Each of their tickets is worth $1/4$ pounds.
You have bought one ticket with probability about
one in fourteen million you get a prize of fourteen million.
Your ticket is worth one pound. If there is no roll over
of prize money the organisers are delighted since
they have been given twenty eight million
and have probability about $1/2$ of having to disburse
fourteen million.

The value of your ticket if you do (a) is $5/8$ pounds since
you have probability $1/2$ of gaining a ticket worth $1$
and probability $1/2$ of gaining a ticket worth $1/4$.
\vspace{2\baselineskip}
\section*{Exercise~\ref{E;bottom line 1}$^{*}$}
\section*{Exercise~\ref{E;bottom line 2}$^{*}$}
\section*{Exercise~\ref{E;do your own Poisson}$^{*}$}
\newpage\section*{Exercise~\ref{E;lots of heads}}
(i) I toss $r$ coins. The probability that they all come down heads
is $2^{-r}$ and I stop, otherwise my expected time from then
on is $u_{r}$.
Thus
\[u_{r}=r+(1-2^{-r})u_{r}\]
so 
\[2^{-r}u_{r}=r\]
and
\[u_{r}=r2^{-r}.\]

(ii) This is similar to (i) except that the probability that 
they come down all heads or all tails is
is $2^{-r}+2^{-r}=2^{-r+1}$ and the argument as before
gives $v_{r}=r2^{-r+1}$.

(iii) $e_{1}=u_{1}$ so $e_{1}=1+2^{-1}e_{1}$ and $e_{1}=2=2^{1+1}-2$.
The expected time to reach $r$ heads is $e_{r}$. Once I am at
$r$ heads then after one further throw with probability $1/2$
I reach $r+1$ heads or with  probability $1/2$
I must start again and expect to take $e_{r+1}$ to reach $r+1$
heads.
Thus
\[e_{r+1}=e_{r}+1+\tfrac{1}{2}e_{r+1}\]
and
\[e_{r+1}-2e_{r}=2.\]
Using induction or solving the difference equation
we get $e_{r}=2^{r+1}-2$.

(iii) Let $g_{r}$ be the expected time to throw
$r$ heads or tails starting from one head.
Observe that by symmetry $g_{r}$ is the expected time to throw
$r$ heads or tails starting from one tail.
Further $f_{r}=1+g_{r}$ (since we must throw heads
or tails in our first throw) and $g_{1}=0$.
The expected time to reach $r$  starting from 
one head is $g_{r}$. Once I am at
$r$, then after one further throw with probability $1/2$
I reach $r+1$ same or with  probability $1/2$
I must start again with one coin already thrown
so my expected time from then to $r+1$ is
$g_{r+1}$.
Thus
\[g_{r+1}=g_{r}+1+\tfrac{1}{2}g_{r+1}\]
and
\[g_{r+1}-2g_{r}=2.\]
Solving the difference equation we get
\[g_{r}=A2^{r}-2.\]
Since $g_{1}=0$ we have $A=1$, $g_{r}=2^{r}-2$
and $f_{r}=2^{r}-1$.

[Or we could argue that half are
all heads and half all tails so $e_{r}=2f_{r}$.]

(iv) In (i) if a tails appears you have to go on throwing
until you have done a full $r$ tosses before you start again
looking for $r$ in a row.
In (iii) you start again immediately after the next throw.
\section*{Exercise~\ref{E;trust me}$^{*}$}
\newpage\section*{Exercise~\ref{E;double tests}}
\begin{tiny}
\[
\begin{array}{lccccccccc}
\text{number of heads out of $20$}&0&1&2&3&4&5&6&7\\
\text{probability if $p=1/20$}&.122&.270&.285&.190&.090&.032
&.009&.002
\end{array}
\]
\[
\begin{array}{lccccccccc}
\text{number of heads out of $20$}&0&1&2&3&4&5&6&7\\
\text{probability if $p=1/2$}&.000&.000&.000&.001&.005&.012
&.029&.058
\end{array}
\]
\end{tiny}
If we reject on $5$ heads or less we will reject good coins
with probability about $.02$ and accept bad coins with probability
about $.01$. (But we might choose differently if we wished
to have very small probability of rejecting good coins
or if   we wished
to have very small probability of accepting bad coins.)
\newpage\section*{Exercise~\ref{E;bit of Hoeffding}}
Completing the square,
\[ns^{2}-as=n(s^{2}-n^{-1}as)=n\left(s-\frac{a}{2n}\right)^{2}
-\frac{a^{2}}{4n}\]
which is minimised by taking $s=a/(2n)$.
\newpage\section*{Exercise~\ref{E;Hoeffding}}
(i) We have
\begin{align*}
\frac{e^{t}+e^{-t}}{2}&=\frac{1}{2}\left(
\sum_{r=0}^{\infty}\frac{t^{r}}{r!}+
\sum_{r=0}^{\infty}(-1)^{r}\frac{t^{r}}{r!}\right)\\
&\sum_{r=0}^{\infty}\frac{t^{2r}}{(2r)!}\geq 1
\end{align*}
and
\begin{align*}
\frac{e^{t}+e^{-t}}{2}&=\sum_{r=0}^{\infty}\frac{t^{2r}}{(2r)!}\\
&\leq \sum_{r=0}^{\infty}\frac{t^{2r}}{2^{r}(r!)}\\
&=e^{t^{2}/2}.
\end{align*}

(ii) If $f(x)=-e^{sx}$ then $f''(x)=-s^{2}e^{sx}<0$ for all $x$
so by concavity
\[f(x)=f\left(\frac{1-x}{2}\times (-1)+\frac{1+x}{2}\times 1\right)
\geq \frac{1-x}{2}f(-1)+\frac{1-x}{2}f(1)\]
that is to say
 \[e^{sx}\leq \frac{1-x}{2}e^{-s}+\frac{1+x}{2}e^{s}\]
for all $s$ and all $|x|\leq 1$.

(iii) Using~(ii), we have, since $|Y|\leq 1$,
\[e^{sY}\leq \frac{1-Y}{2}e^{-s}+\frac{1+Y}{2}e^{s}\]
so taking expectations,
\begin{align*}
{\mathbb E}e^{sY}&\leq  
\frac{1-{\mathbb E}Y}{2}e^{-s}+\frac{1+{\mathbb E}Y}{2}e^{s}\\
&=\frac{e^{s}+e^{-s}}{2}\leq e^{-s^{2}/2}.
\end{align*}

(iv) If $a=0$ the result is trivial. If $a>0$
set $Y=X/a$ so $|Y|\leq 1$ and
\[{\mathbb E}e^{tY}\leq e^{-t^{2}/2}.\]
Now set $t=sa$ to recover
\[{\mathbb E}e^{sX}\leq e^{a^{2}s^{2}/2}.\]

(v) Since the $X_{j}$ are independent, so are the $e^{sX_{j}}$
and, using (iv),
\[
{\mathbb E}e^{s\sum_{j=1}^{n}X_{j}}=
{\mathbb E}\prod_{j=1}^{n}e^{sX_{j}}=
\prod_{j=1}^{n}{\mathbb E}e^{sX_{j}}\leq 
\prod_{j=1}^{n}{\mathbb E}e^{a_{j}^{2}s^{2}/2}
={As^{2}/2}.
\]

(vi) Set $Y= \sum_{j=1}^{n}X_{j}$.
If $s>0$ so $y\mapsto e^{ys}$ is increasing, we have
\[\Pr(Y\geq y)\leq \frac{{\mathbb E}e^{s\Pr(Y\geq y)}}{e^{sy}}
\leq \exp\left(\frac{As^{2}}{2}-sy\right)\]
and setting $s=A/y$ we obtain
\[\Pr(Y\geq y)\leq\exp\left(-\frac{y^{2}}{2A}\right).\]
Replacing $X_{j}$ by $-X_{j}$ or repeating the argument
we have
\[\Pr(Y\leq -y)\leq\exp\left(-\frac{y^{2}}{2A}\right)\]
and so, combining our two results
\[\Pr(|Y|\leq y)\leq2\exp\left(\frac{y^{2}}{2A}\right).\]

(vii) Set $Z_{j}=1$ if the $j$th toss is heads
and $Z_{j}=0$ if the $j$th toss is tails.
If we set
\[X_{j}=Z_{j}-p\]
then ${\mathbb E}X_{j}=0$ and $|X_{j}|\leq p$
so
\begin{align*}
\Pr(|Y_{n}-np|\geq Kn^{1/2})&
=\Pr\left(\left|\sum_{j=1}^{n}X_{j}\right|\leq Kn^{1/2}\right)\\
&\leq 2\exp\left(-\frac{(Kn^{1/2})^{2}}{2np^{2}}\right)\\
&\leq 2\exp\left(-\frac{K^{2}}{2p^{2}}\right)
\end{align*}
for all $K>0$.

If $1/2\geq p\geq 0$ then since
\[Y_{n}-np=-\big((n-Y_{n})-n(1-p)\big)\]
we can reverse the roles of heads and tails to get
\[\Pr(|Y_{n}-np|\geq Kn^{1/2})
\leq 2\exp\left(-\frac{K^{2}}{2(1-p)^{2}}\right).\]
\newpage\section*{Exercise~\ref{E;test too good}}
We have
\begin{align*}
\Pr\big(|Y_{n}-nq|\leq n\epsilon\big)
&\leq  \Pr\big(|Y_{n}-np|\geq n\epsilon\big)\\
&\leq 2\exp\big(-n\epsilon^{2}/2).
\end{align*}
\newpage\section*{Exercise~\ref{E;use Hoeffding}}
The symmetry of our demands suggest we try for $n$ odd
and accept the drug if number of successes
exceeds $0$ and reject if number of successes
less than $0$.

In the notation of Exercise~\ref{E;Hoeffding}~(vii)
with $p=.55$ we want
\[\Pr(Y_{n}-.5n<0)\leq .05\]
ie
\[\Pr(Y_{n}-.55n<-.05n)\leq .05\]
so setting, $K=.05n^{1/2}$ ,we see that the result
of Exercise~\ref{E;Hoeffding}~(vii) guarantees this
if 
\[\exp\left(-\frac{(.05n^{1/2})^{2}}{2(.55)^{2}}\right)\leq .05\]
ie if
\[\exp(-n/(2\times 11^{2}),\leq .05\]
ie
\[n\geq 2\times 11^{2}\log 20\]
so taking $n=725$ will give the desired outcome.
\newpage\section*{Exercise~\ref{E;how large stop}}
If we have an excess of $r$ with $-a+1\leq r\leq a-1$
and make a further throw then with probability $p$
we will then have an excess $r+1$ and the probability
of acceptance will be $u_{r+1}$ and with probability $q$
we will then have an excess $r-1$ and the probability
of acceptance will be $u_{r-1}$. Thus
\[u_{r}=qu_{r-1}+pu_{r+1}.\]
If $r=a$ then we accept so $u_{a}=1$. If $r=-a$
we reject so $u_{-a}=0$.

We have
\[(pE^{2}-E+qI)u_{r}=0\]
so
\[(E-I)(pE-qI)u_{r}=0\]
and 
\[u_{r}=A+B\left(\frac{q}{p}\right)^{r}\]
for some $A$ and $B$. Setting $r=a$ and $r=-a$ we get
\begin{align*}
1&=A+B\left(\frac{q}{p}\right)^{a}\\
0&=A+B\left(\frac{q}{p}\right)^{-a}
\end{align*}
so subtracting we have
\[1=B\left(\left(\frac{q}{p}\right)^{a}
-\left(\frac{q}{p}\right)^{-a}\right).\]
Thus
\[u_{r}=\frac{\left(\frac{q}{p}\right)^{r}
-\left(\frac{q}{p}\right)^{-a}}
{\left(\frac{q}{p}\right)^{a}
-\left(\frac{q}{p}\right)^{-a}}\]
Setting $r=0$ we see that the probability of
acceptance is
\begin{align*}
u_{0}&=\frac{1-\left(\frac{q}{p}\right)^{-a}}
{\left(\frac{q}{p}\right)^{a}
-\left(\frac{q}{p}\right)^{-a}}\\
&=\frac{1}{\left(\frac{q}{p}\right)^{a}}
\frac{1}{1+
\left(\frac{q}{p}\right)^{-a}}\\
&\frac{1}{1+\left(\frac{q}{p}\right)^{a}}
\end{align*}
The probability of acceptance increases as $p$
increase so
the
probability of rejection
is smaller than $0.05$ for $p\geq .55$ is
given by
\[\frac{1}{1+\left(\frac{.45}{.55}\right)^{a}}\geq .95\]
that is to say
\[1+\left(\frac{9}{11}\right)^{a}\leq \frac{20}{19}\]
ie
\[\left(\frac{9}{11}\right)^{a}\leq \frac{1}{19}\]
ie
\[a\geq \frac{\log 19}{\log(11/9)}\approx 14.7\]
We should take $a=15$. By symmetry this will also
ensure that the probability of acceptance is less
than  $0.05$ if $p\leq.45$.

If $a=b$ then fixing $a$
to give a certain  probability of acceptance
for given $p=p'$
also fixes the probability of rejection.         
for given $p=p''$. If we can chose $b$ as well
we can choose both probabilities.

\newpage\section*{Exercise~\ref{E;longest fair trial}}
If the excess is $r$ then, if $a-1\geq r\geq 1-a$,
making one further
trial there is a probability $1/2$ we throw a head,
so we now expect to wait $e_{r+1}$ to the end of the trial,
and a probability $1/2$ we throw a tail,
so we now expect to wait $e_{r-1}$ to the end of the trial.
If $r=-a$ or $r=a$, the number of further throws required is $0$ so
$e_{a}=e_{-a}=0$. Thus
\[e_{r}=1+\tfrac{1}{2}e_{r-1}+\tfrac{1}{2}e_{r+1} 
\ \text{for $-a+1\leq r\leq a-1$},\]
and $e_{a}=e_{-a}=0$.

A complementary solution of our difference equation
\[(E-I)^{2}u_{r}=-1\]
is $u_{r}=Cr^{2}$ with
\[C\big((r+1)^{2}-2r^{2}+(r-1)^{2}\big)=-2\]
ie $C=-1$. Thus
\[e_{r}=A+Br-r^{2}.\]
Since $e_{a}=u_{-a}$, $B=0$. Since $u_{a}=0$ $A=a^{2}$.
Thus
 \[e_{r}=a^{2}-r^{2}\]
and the expected number of trials when we start is $a^{2}$.

If $a=15$ this gives $225$ expected trials. 
\newpage\section*{Exercise~\ref{E;end trial}}
(i) Write $e_{r}=e_{r}(p)$.
If $-a+1\leq r\leq a-1$, then if the excess of successes
is $r$ then, after $1$ further trial, with with probability $p$ 
we will have an excess $r+1$ and the expected number
of trials remaining will be $e_{r+1}$ while
with probability $q$ we will have an excess $r-1$ and the expected number
of trials remaining will be $e_{r-1}$.
Thus
\[e_{r}=1+qe_{r-1}+pe_{r+1}\]
If the excess is $a$ or $-a$, no further trials are required
so $e_{a}=e_{-a}$.

We have
\[(pE^{2}-E+qI)e_{r}=1\]
or
\[(pE-q)(E-1)e_{r}=1.\]
We seek a particular solution of the for $e_{r}=Kr$ obtaining
$K=(p-q)^{-1}$. Thus
\[e_{r}=A+B\frac{q}{p}^{r}+\frac{r}{p-q}.\]
Setting $r=a$ and $r=-a$ we obtain
\begin{align*}
0&=A+B\frac{q}{p}^{a}+\frac{a}{p-q}\\
0&=A+B\frac{q}{p}^{-a}-\frac{a}{p-q}
\end{align*}
Thus
\[e_{r}(p)=\frac{2a}{p-q}
\left(\frac{1-\left(\frac{q}{p}\right)^{r+a}}
{\left(1-\left(\frac{q}{p}\right)^{2a}\right)}\right)
-\frac{r+a}{p-q}.\]

Setting $r=0$ we see that the expected number of trials
required by our test is
\begin{align*}
e_{0}&=\frac{2a}{p-q}
\left(\frac{1-\left(\frac{q}{p}\right)^{a}}
{\left(1-\left(\frac{q}{p}\right)^{2a}\right)}\right)
-\frac{a}{p-q}\\
&=\frac{a}{p-q}\left(
\left(\frac{2}
{\left(1+\left(\frac{q}{p}\right)^{a}\right)}\right)
-1\right)\\
&=\frac{a}{p-q}
\left(\frac{1-\left(\frac{q}{p}\right)^{a}}
{1+\left(\frac{q}{p}\right)^{a}}\right).
\end{align*}

(ii) If
\[f(x)=\left(\frac{\tfrac{1}{2}-x}{\tfrac{1}{2}+x}\right)^{a}\]
then
\[f'(x)=a\left(\frac{\tfrac{1}{2}-x}{\tfrac{1}{2}+x}\right)^{a-1}
\left(-\frac{1}{\tfrac{1}{2}+x}-
\frac{\tfrac{1}{2}-x}{(\tfrac{1}{2}+x)^{2}}\right)\]
and
\[f'(0)=-4a\]
Thus setting $p=\tfrac{1}{2}+\delta$ so $q=\tfrac{1}{2}-\delta$
\[\frac{a}{p-q}\left(1-\left(\frac{q}{p}\right)^{a}\right)
=\frac{a}{2\delta}\big(f(0)-f(\delta)\big)\rightarrow  
-\frac{a}{2}f'(0)=2a^{2}\]
and
\[R(p,a)\rightarrow\frac{2a^{2}}{2}=a^{2}=R(\tfrac{1}{2},a)\]
as $p\rightarrow 0$.

(iii) We have
\[a^{1}R(p,a)=\frac{1}{p-q}
\left(\frac{1-\left(\frac{q}{p}\right)^{a}}
{1+\left(\frac{q}{p}\right)^{a}}\right)
\rightarrow \frac{1}{p-q}\frac{1-0}{1+0}=\frac{1}{p-q}\]
as $a\rightarrow\infty$.
By the law of large numbers, we expect that if we have
a large number of trials $N$ (which we must have if $a$ is large),
then roughly $Np$ will be success and $Nq$ failures (with high
probability) so if we finish after $N$ trials
\[a\approx Np-Nq\]
and we expect $N\approx a(p-q)^{-1}$.

If $p<1/2$
\[a^{-1}R(p,a)\rightarrow\frac{1}{q-p}\]
as $a\rightarrow\infty$.

(iii) We have $a=15$, $p=2/3$, $q=1/3$ so
\[R(p,a)=\frac{15}{1/3}
\frac{2^{15}-1}{2^{15}+1}\approx 45.\]
 


\newpage\section*{Exercise~\ref{E;satisfy economists}}
If $A\geq 0$ then setting $u=1$, $v=0$ we see that the economists'
condition fails. Thus the economists' condition
implies $A<0$.  
Similarly the economists' condition
implies $C<0$.
If $A,\,C<0$
\[Av^{2}-2Buv+Cu^{2}=A(v-uBA^{-1})^{2}+(C-B^{2}A^{-1})u^{2}.\]
Setting $u=1$, $v=BA^{-1}$ we see that the economists'
condition implies $C-B^{2}A^{-1}<0$, ie $CA-B^{2}>0$
so $CA>B^{2}$.

Conversely, if $A,\,C<0$ and $CA>B^{2}$ then
\[Av^{2}-2Buv+Cu^{2}\geq 0\]
implies
\[A(v-uBA^{-1})^{2}+(C-B^{2}A^{-1})u^{2}\geq 0\]
so $v-uBA^{-1}=0$ and $u=0$ whence $u=v=0$.
Thus the economists' condition holds.
\newpage\section*{Exercise~\ref{E;Marshall can}}
We require $x_{0}=y_{0}>0$, $a,b>0$, $u,v>0$, $B^{2}<AC$, $av-bu=0$,
$A,C<0$. We could take $a=b=x_{0}=y_{0}=u=v=1$, $A=C=-2$ $B=1$.
\newpage\section*{Exercise~\ref{E;mite}}
We have
\[\tag*{$\bigstar$} u\triangle x+v\triangle y=\triangle  c\]
and
\[\tilde{a}v-\tilde{b}u=0\]
where
\[\tilde{a}=a+A\triangle x+B\triangle y,
\ \text{and}\ \tilde{b}=b+B\triangle x+C\triangle y.\]
Thus
\[(a+A\triangle x+B\triangle y)v
-(b+B\triangle x+C\triangle y)u=0.\]
But $au-bv=0$
so
\[(Av-Bu)\triangle x-(Bv-Cu)\triangle y=0\]
Using $\bigstar$, this gives
\[(Av+Bu)(\triangle c-v\triangle y)-u(Bv+Cu)\triangle y=0\]
so
\[(Av^{2}-2Buv+Cu^{2})\triangle y=(Av+Bu)\triangle c\]
ie
\[\triangle y=\frac{Av+Bu}{Av^{2}-2Buv+Cu^{2}}{\triangle c}.\]
$y$ will decrease as $c$ increases if $Av+Bu>0$.
\newpage\section*{Exercise~\ref{E;A1}}
(ii) Rescale $y$ axis by $a$ and $x$ axis by $a^{-1}$.
If $f(x)=1/x$ the graph is unchanged.

(iii) Make the change of variable $s=a^{-1}x$ to obtain
\[\int_{a}^{b}\frac{1}{x}\,dx=\int_{1}^{b/a}\frac{1}{as}\,ads
=\int_{1}^{b/a}\frac{1}{s}\,ds.\]

(iv) We have, using (iii),
\begin{align*}
\log uv&=\int_{1}^{uv}\frac{1}{x}\,dx\\
&=\int_{1}^{u}\frac{1}{x}\,dx
+\int_{u}^{uv}\frac{1}{x}\,dx\\
&=\int_{1}^{u}\frac{1}{x}\,dx
+\int_{1}^{v}\frac{1}{x}\,dx\\
&=\log u+\log v.
\end {align*}

\newpage\section*{Exercise~\ref{E;A2}}
(ii) By the fundamental theorem of the calculus (looked at in (i))
$\log$ is differentiable and
\[\log'(t)=\frac{d\ }{dt}\int_{1}^{t}\frac{1}{x}\,dx=\frac{1}{t}.\]
\newpage\section*{Exercise~\ref{E;A3}}
(i) Since $\log'(t)=1/t>0$, $\log$ is a strictly increasing function.

(ii) Observe that
\[\log 1=\int_{1}^{1}\frac{1}{x}\,dx=0.\]

(iii) Since $2>1$, we have $\log 2>\log 1=0$ so
\[\log 2^{n}=n\log 2\rightarrow \infty.\]

(iv) Since $\log$ is increasing (iii) tells us that
\[\log x\rightarrow \infty\]
as $x\rightarrow\infty$.

(v) Since $1/x \rightarrow \infty$ as $x\rightarrow 0+$
\[\log x=-\log(1/x)\rightarrow -\infty\]
as $x\rightarrow\infty$.

(vi) We have
\[\frac{d^{2}\ }{dx^{2}}\log x=\frac{d\ }{dx}\frac{1}{x}
=\frac{-1}{x^{2}}<0.\]
 
\newpage\section*{Exercise~\ref{E;A4}}
(iii) By part~(ii), $\exp$ is differentiable with
\[\frac{d\ }{dx}\exp x=\frac{d\ }{dx}\log^{-1}x
=\frac{1}{\log' x}=\frac{1}{x^{-1}}=x.\]

(iv) An appropriate answer is that $\log$ is defined only on the 
strictly positive reals. But there are other ways of looking at this.

\newpage\section*{Exercise~\ref{E;A5}}
(i) We have
\[\log\big((\exp x)(\exp y)\big)
=\log\exp x+\log \exp y=x+y,\]
so applying $\exp$ to both sides yields
\[(\exp x)(\exp y)=\exp (x+y).\]

(ii) Observe that $\exp' x=\exp x>0$.

(iii) $\log \exp x=x\rightarrow\infty$ as $x\rightarrow\infty$
so $\exp x=x\rightarrow\infty$ as $x\rightarrow\infty$.

(iv) $\exp x=1/(\exp -x)\rightarrow 0$ as $x\rightarrow-\infty$.

\newpage\section*{Exercise~\ref{E;A6}}
(i) $\exp n\log x=\exp\log x^{n}=x^{n}$.
(If you need a more detailed proof, use induction.)

(ii) If $n=0$, $\exp 0\log x=\exp 0=1$.
If $n<0$, 
\[x^{-n}(\exp n\log x)=\exp(-n\log x)\exp(n\log x)=\exp 0=1\]
so $\exp n\log x=x^{n}$.

(iii) We have
\[\left(\exp\left(\frac{m}{n}\log x\right)\right)^{n}
=\exp n\left(\frac{m}{n}\log x\right)
=\exp m\log x=x^{m}\]
and so
\[\exp\left(\frac{m}{n}\log x\right)=x^{m/n}\]
where $x^{m/n}$ has its standard elementary meaning.

(iv) We have
\[e^{x}=\exp(a\log e)=\exp(a\log\exp 1)=\exp(a\times 1)=\exp a.\]

\newpage\section*{Exercise~\ref{E;A7}}
(i) Observe that
\begin{align*}
(xy)^{a}&=\exp(a\log xy)=\exp\big(a(\log x+\log y)\big)\\
&=\exp(a\log x+a\log y)=(\exp a\log x)(\exp a\log y)=x^{a}y^{a}.
\end{align*}

(ii) Observe that
\begin{align*}
x^{a+b}&=\exp\big((a+b)\log x\big)=\exp(a\log x+b\log x)\\
&=\exp(a\log x)\exp(b\log x)=x^{a}x^{b}.
\end{align*}

(iii) Observe that
\begin{align*}
x^{ab}&=\exp (ab\log x)=\exp\big(a(b\log x)\big)
&=\exp\big(a\log(x^{b})\big)=(x^{b})^{a}.
\end{align*}
Thus
\[x^{ab}=x^{ba}=(x^{a})^{b}.\]

\newpage\section*{Exercise~\ref{E;A8}}

(i) We have
\[\frac{\log(1+h)}{h}=\frac{\log(1+h)-\log 1}{h}
\rightarrow\log' 1=1\]
as $h\rightarrow 0$.

(ii) Taking $h=a/n$ in (i), we get
\[\frac{\log(1+a/n)}{a/n}\rightarrow 1\]
as $n\rightarrow\infty$.

(iii) Multiplying through by $a$ and simplifying, we get
\[n\log(1+a/n)\rightarrow a\]
as $n\rightarrow\infty$.

(iv) Taking the exponential of both sides
we get
\[\left(1+\frac{a}{n}\right)^{n}\rightarrow e^{a}\]
as $n\rightarrow\infty$.

(v) We want
\[\left(1+\frac{x}{100}\right)^{n}=2\]
so
\[n\log\left(1+\frac{x}{100}\right)=\log 2.\]
If $x$ is small, part~(i) gives
\[\frac{x}{100}\approx \log 2\]
so 
\[n\approx \frac{100\times \log 2}{x}\approx\frac{69}{n}
\approx\frac{72}{n}\]
(note that $72$ has many small factors).

As an example suppose $x=4$. The rule of $72$ gives
a doubling time of $72/4=18$ years. In fact
\[\left(1+\frac{4}{100}\right)^{18}\approx 2.03\]
which is not bad.

If we take $x=8$ we have
\[\left(1+\frac{8}{100}\right)^{9}\approx 2.\]

If we take $x=24$ (a rate more often on the lips of
snake oil salesmen than respectable bankers), then
\[\left(1+\frac{24}{100}\right)^{3}\approx 1.91.\]

\newpage\section*{Exercise~\ref{E;A9}}
(i) Observe that
\[(1-t)(1+t+t^{2}+\dots+t^{n})=1-t^{n+1}\]
so, dividing by $(1-t)$ and rearranging,
we get
\[\frac{1}{1-t}=1+t+\dots+t^{n}+\frac{t^{n+1}}{1-t}.\]
Integrating both sides, gives
\begin{align*}
\int_{0}^{x}\frac{1}{1-t}\,dt&=\int_{0}^{x}
\left(1+t+\dots+t^{n}+\frac{t^{n+1}}{1-t}\right)\,dt\\
&x+\frac{x^{2}}{2}+\dots+\frac{x^{n}}{n}+R_{n}(x)
\end{align*}
where
\[R_{n}(x)=\int_{0}^{x}\frac{t^{n+1}}{1-t}\,dt.\]
But making the substitution $s=1-t$ gives
\[\int_{0}^{x}\frac{1}{1-t}\,dt
=-\int_{1}^{1-x}\frac{1}{s}\,ds=-\log(1-x),\]
so
\[-\log(1-x)=x+\frac{x^{2}}{2}+\dots+\frac{x^{n}}{n}
+R_{n}(x).\]

(ii) If $|t|\leq |x|<1$, then $|1-t|\geq 1-|t|\geq 1-|x|$ so
\[\left|\frac{t^{n+1}}{1-t}\right|\leq \frac{|x|^{n+1}}{|1-t|}
\leq \frac{|x|^{n+1}}{1-|x|}\]
and so
\[
|R_{n}(x)|\leq \left|\int_{0}^{x}\frac{|x|^{n+1}}{1-|x|}\,dt\right|\\
\leq \frac{|x|^{n+2}}{1-|x|}\rightarrow 0\]
as $n\rightarrow\infty$.

(iii) Combining (i) and (ii),
\[x+\frac{x^{2}}{2}+\dots+\frac{x^{n}}{n}=-\log(1-x)-R_{n}(x)
\rightarrow -\log(1-x)\]
as $n\rightarrow\infty$. In other words,
\[-\log(1-x)=x+\frac{x^{2}}{2}+\dots+\frac{x^{n}}{n}+\dots\]
for all $|x|<1$.

Setting $x=-y$, we obtain
\[\log(1+y)=y-\frac{y^{2}}{2}+\dots+\frac{(-1)^{n+1}y^{n}}{n}+\dots\]
for all $|y|<1$.

\newpage\section*{Exercise~\ref{E;A10}}
(i) Set 
\[h_{+}(x)=
\begin{cases}
h(x)&\text{if $h(x)\geq 0$,}\\
0&\text{otherwise,}
\end{cases}
\]
and
\[h_{-}(x)=
\begin{cases}
h(x)&\text{if $h(x)\leq 0$,}\\
0&\text{otherwise.}
\end{cases}
\]
Then
\begin{align*}
\left|\int_{a}^{b}h(x)\,dx\right|&
=\left|\int_{a}^{b}h_{+}(x)+h_{-}(x)\,dx\right|\\
&=\left|\int_{a}^{b}h_{+}(x)\,dx+\int_{a}^{b}h_{-}(x)\,dx\right|\\
&\leq \max\left(\int_{a}^{b}h_{+}(x)\,dx,-\int_{a}^{b}h_{-}(x)\,dx\right)\\
&= \max\left(\int_{a}^{b}h_{+}(x)\,dx,
\int_{a}^{b}\big(-h_{-}(x)\big)\,dx\right).
\end{align*}
But
\[0\leq -h_{-}(x)\leq g(x)\]
so
\[\int_{a}^{b}\big(-h_{-}(x)\big)\,dx\leq\int_{a}^{b}g(x)\,dx.\]
Similarly
\[\int_{a}^{b}h_{+}(x)\,dx\leq\int_{a}^{b}g(x)\,dx\]
so
\[\left|\int_{a}^{b}h(x)\,dx\right|\leq\int_{a}^{b}g(x)\,dx.\]

(ii) If $1\leq r\leq n$ and 
\[f^{(r)}(x)\leq A\frac{|x|^{n-r}}{(n-r)!}\]
then, using part~(i),
\begin{align*}
|f^{(r-1)}(x)|&= \left|\int_{0}^{x}f^{(r)}(t)\,dt\right|\\
&\leq \left|\int_{0}^{x}A\frac{|x|^{n-r}}{(n-r)!}\,dt\right|\\
&=\int_{0}^{|x|}A\frac{x^{n-r}}{(n-r)!}\,dt\\
&=A\frac{|x|^{n-r+1}}{(n-r+1)!}.
\end{align*}
Thus, by induction,
\[|f(x)|\leq A\frac{|x|^{n}}{n!}\]
for all  $|x|\leq X$.

(iii) Since $\exp$ is increasing
\[0<\exp x\leq \exp X\]
for all $x\leq X$.

Now set
\[f(x)=\exp x-
\left(1+x+\frac{x^{2}}{2}+\dots+\frac{x^{n-1}}{(n-1)!}\right).\]
By induction
\[f^{(r)}(x)=\exp x-
\left(1+x+\frac{x^{2}}{2}+\dots+\frac{x^{n-r-1}}{(n-r-1)!}\right)\]
for $0\leq r\leq n-1$ and
\[f^{(n)}(x)=\exp x.\]

Thus $|f^{(n)}(x)|\leq \exp X$ for all $|x|\leq X$
and $f(0)=f'(0)=f''(0)=\dots=f^{(n-1)}(0)=0$.
By part~(ii)
\[|f(x)|\leq \exp X\frac{|x|^{n}}{n!}\]
for all $|x|\leq X$.

(iv) Thus
\[
\left|\exp x-
\left(1+x+\frac{x^{2}}{2}+\dots+\frac{x^{n-1}}{(n-1)!}\right)
\right|
\leq e^{X}\frac{|x|^{n}}{n!}\rightarrow 0\]
for all $|x|\leq X$. But $X$ was arbitrary so
\[
\left|\exp x-
\left(1+x+\frac{x^{2}}{2}+\dots+\frac{x^{n-1}}{(n-1)!}\right)\right|
\rightarrow 0\]
as $n\rightarrow\infty$ and this is the required result.

\newpage\section*{Exercise~\ref{E;A11}} We use the following form
of Taylor's theorem, obtained by integrating by parts
and true if $f$ is $n+1$ times continuously differentiable.
\[f(x)=\sum_{j=0}^{n}\frac{f^{(j)}(0)x^{j}}{j!}+R_{n}(f,x)\]
where
\[R_{n}(f,x)=\frac{1}{n!}\int_{0}^{x}f^{(n+1)}(t)(x-t)^{n}\,dt.\]

If $f(x)=\exp(x)$ then $f^{(r)}(x)=\exp x$ so
\[\exp x=\sum_{j=0}^{n}\frac{x^{j}}{j!}+R_{n}(x)\]
where
\[|R_{n}(x)|=\left|\frac{1}{n!}\int_{0}^{x}\exp(t)(x-t)^{n}\,dt\right|
\leq \frac{1}{n!}|x|^{n}\exp(|x|)\rightarrow 0\]
(observe $(|x|^{n+1}/(n+1)!)/(|x|^{n}/n!)=|x|/(n+1)\rightarrow 0$.
Thus
\[\exp x=\sum_{j=0}^{\infty}\frac{x^{j}}{j!}.\]

If $f(x)=\log(1-x)$ then $f'(x)=-(1-x)^{-1}$ for $|x|<1$
and, by induction,
\[f^{(r)}(x)=-\frac{(r-1)!}{(1-x)^{r}}\]
for all $r\geq 1$. Thus if $|x|<1$
\[\log(1-x)=-\sum_{j=0}^{n}\frac{x^{j}}{j}+R_{n}(x)\]
where
\[|R_{n}(x)|=\left|\int_{0}^{x}\frac{(x-t)^{n}}{1-t)^{n+1}}\,dt\right|.\]
Now, if $0\leq t\leq x$,
\[0\leq\frac{x-t}{1-t}=1-\frac{1-x}{1-t}\leq 1-(1-x)=x=|x|\]
and, if $x\leq t\leq 0$,
\[\left|\frac{x-t}{1-t}\right|\leq \frac{|x|-|t|}{1-|t|}\leq |x|.\]
Thus
\[|R_{n}(x)|\leq \int_{0}^{|x|}|x|^{n}\frac{1}{1-|x|}\,dt
\leq \frac{|x|^{n+1}}{1-|x|}\rightarrow 0\]
as $n\rightarrow\infty$.
Thus
\[\log(1-x)=-\sum_{j=0}^{\infty}\frac{x^{j}}{j!}\]
for $|x|<1$.

\newpage\section*{Exercise~\ref{E;A12}}
(i) We have
\[a^{\log_{a}x}=\exp\left(\log a\times\frac{\log x}{\log a}\right)
=\exp \log x=x.\]

(ii) We have
\[\log_{a}xy=\frac{\log xy}{\log a}=\frac{\log x+\log y}{\log a}
=\frac{\log x}{\log a}+\frac{\log y}{\log a}=\log_{a}x+\log_{a}y.\]

(iii) We have
\[\log_{a}x^{k}=\frac{\log x^{k}}{\log a}=k\frac{\log x}{\log a}
=k\log_{a}x.\]

(iv) We have
\[\log_{e}x=\frac{\log x}{\log e}=\frac{\log x}{1}=\log x.\]

(v) We have
\[\log_{a}b\log_{b}a=\frac{\log b}{\log a}\times\frac{\log a}{\log b}
=1.\]

\newpage\section*{Exercise~\ref{E;A13}}
(i) We have
\[\log_{10}5=\log_{10}10-\log_{10}2\approx 1-0.301029996\approx .699\]
\[\log_{10}6=\log_{10}3+\log_{10}2\approx
0.477121255+0.301029996\approx .778\]
correct to three decimal places.

Now
\[\log_{10} (3^{100}/10^{47})=100\log_{10}3-47\approx .712\]
correct to three decimal places so
\[\log_{10}5<\log_{10} (3^{100}/10^{47})<\log_{10}6\]
whence, since $\log_{10}$ is increasing,
\[5<3^{100}/10^{47}<6.\]
Thus 
\[5\times 10^{47}<3^{100}<6\times 10^{47}.\]
and the first digit of $3^{100}$ is $5$.

(ii) We have
\[\log_{10} 2^{1000}=301+.029\]
correct to three decimal places so
\[10^{301}<2^{1000}<2\times 10^{301}\]
and the first digit of $2^{1000}$ is $1$.

We have
\[\log_{10} 2^{10\,000}<3010+.300<3010+\log_{10}2\]
so 
\[10^{3010}<2^{10\,000}<2\times 10^{3010}\]
so the first digit of $2^{10\,000}$ is $1$.

We have
\[30103>\log_{10} 2^{100\,000}>30102+999
>30102+2\log_{10}3=30102+\log_{10}9\]
so
\[10^{30103}>2^{100\,000}>9\times 10^{30102}\]
and the first digit of $2^{100\,000}$ is $9$.

(iii) We have
\[2^{100\,000}\equiv (2^{10})^{5}\equiv 4^{5}=\equiv 2^{10}=4\mod{10}\]
so the last digit of $2^{100\,000}$ is $4$.

We have
\[3^{100}\equiv(3^{2})^{50}\equiv (-1)^{50}=\equiv 1\mod{10}\]
so the last digit of $3^{100}$ is $1$.
\newpage\section*{Exercise~\ref{E;B1}}
\begin{align*}
\Pr(\text{at least one shows 1})&=1-\Pr(\text{none show 1})\\
&=1-\Pr(\text{single die does not show $1$})^{3}\\
&=1-\left(\frac{5}{6}\right)^{3}=\frac{91}{216}
\end{align*}

\newpage\section*{Exercise~\ref{E;B2}}
(i) If $y=x+d$ then $x=y-d$ and
\begin{align*}
x^{n}+a_{1}x^{n-1}+\dots+a_{0}&=
(y-d)^{n}+a_{1}(y-d)^{n-1}+\dots+a_{0}\\
&y^{n}+(a_{1}-dn)y^{n-1}+b_{2}y^{n-2}+b_{3}y^{n-3}
+\dots+b_{n}
\end{align*}
for appropriate $b_{j}$. 

Taking $d=a_{1}/n$ we have
\[x^{n}+a_{1}x^{n-1}+\dots+a_{0}=
y^{n}+b_{2}y^{n-2}+b_{3}y^{3}
+\dots+b_{n}\]
so $x^{n}+a_{1}x^{n-1}+\dots+a_{n}=0$
if and only if $y^{n}+b_{2}y^{n-2}+\dots+b_{n}=0$.

Suppose 
\[x^{3}+ax^{2}+bx+c=0.\]
Setting $y=x-a/3$ we obtain
\[y^{3}+Bx+C=0.\]
If $\alpha$ is a root of the new equation 
(which we can solve) then $\alpha+a/3$ 
is a root of the old and vice-versa.

(ii) By long division (or you can establish the
result by induction on $n$ if you prefer).

\[x^{n}+a_{1}x^{n-1}+\dots+a_{n}=
(x-\alpha)(x^{n-1}+b_{1}x^{n-2}+\dots+b_{0})+R\]
for some $b_{j}$ and some $R$.
Write
\[P(x)=x^{n}+a_{1}x^{n-1}+\dots+a_{n},
\ Q(x)=x^{n-1}+b_{1}x^{n-2}+\dots+b_{0}.\]

Since
\[P(x)=(x-\alpha)Q(x)+R\]
it follows that if $\alpha$ is a root of $P$,
\[0=0+R\]
so $R=0$ and
\[P(x)=(x-\alpha)Q(x)\]
Thus
\begin{align*}
\text{$\beta$ is a root of $P$}
&\Leftrightarrow P(\beta)=0\\
&\Leftrightarrow Q(\beta)=0\ \text{and/or}\ \beta=\alpha\\
&\Leftrightarrow\text{$\beta$ is a root of $Q$ and/or $\beta=\alpha$}.
\end{align*}

(iii) By the arguments of~(ii)
\[x^{n}+a_{1}x^{n-1}+\dots+a_{n}=\prod_{j=1}^{n}(x-\alpha_{j})\]
where the $\alpha_{j}$ are the roots.
Thus
\[x^{n}+a_{1}x^{n-1}+\dots+a_{n}=x^{n}-\sum_{j=1}^{n}\alpha_{j}x^{n-1}
+\dots+(-1)^{n}\prod_{j=1}^{n}\alpha_{j}\]
so, equating coefficients,
\[a_{1}=-\sum_{j=1}^{n}\alpha_{j},
\ a_{n}=(-1)^{n}\prod_{j=1}^{n}\alpha_{j}.\]


\newpage\section*{Exercise~\ref{E;B3}}
We wish to find $x$ and $y$ such that $x+y=10$ and
$xy=40$.

The first equation yields $y=10-x$ so substituting in the second
we have
\[10x-x^{2}=40\]
or
\[x^{2}-10x+40=0\]
so, using the standard formula
\[x=\frac{10\pm\sqrt 100-400}{2}=5(1\pm 3^{1/2}i)\]
and
\[y=10-x=5(1\pm 3^{1/2}i).\]
Thus either $x=5(1+3^{1/2}i)$, $y=5(1-3^{1/2}i)$
or $x=5(1-3^{1/2}i)$, $y=5(1+3^{1/2}i)$.
By inspection these are solutions.

\newpage\section*{Exercise~\ref{E;B4}}
By Exercise~\ref{E;B1}, the probability of getting at
least one $1$
on any particular throw is $91/216$. Thus, by independence,
the probability of getting least one $1$ on each of
three throws is
\[\left(\frac{91}{216}\right)^{3}\approx \frac{1}{13.373}\]
so the probability is a little less than $1/13$ and
the odds a little greater than $12$ to $1$.

\newpage\section*{Exercise~\ref{E;Galileo}}
If we consider the 216 ways in which three dice can land 
we see that nine can be produced by the following
combinations of dice in any order
\begin{align*}
1,\,2,\,6\,&\text{appearing in 6 ways}\\
1,\,3,\,5\,&\text{appearing in 6 ways}\\
1,\,4,\,4\,&\text{appearing in 3 ways}\\
2,\,2,\,5\,&\text{appearing in 3 ways}\\
2,\,3,\,4\,&\text{appearing in 6 ways}\\
3,\,3,\,3\,&\text{appearing in 1 ways}
\end{align*}
so that nine can appear in $25$ ways.

On the other hand ten can be produced by the following
combinations of dice in any order
\begin{align*}
1,\,3,\,6\,&\text{appearing in 6 ways}\\
1,\,4,\,5\,&\text{appearing in 6 ways}\\
2,\,2,\,6\,&\text{appearing in 3 ways}\\
2,\,3,\,5\,&\text{appearing in 6 ways}\\
2,\,4,\,4\,&\text{appearing in 3 ways}\\
3,\,3,\,4\,&\text{appearing in 3 ways}
\end{align*}
so that ten can appear in $27$ ways.

Thus nine has probability $p=25/216$ and ten $q=27/216$.

If we throw dice until either $9$ or $10$ comes up
then the mathematics of the one-sided duel shows that
the bettor on $10$ has a probability
\[\frac{q}{p+q}\approx0.519\]
so an expected return on a stake of $1$ unit of $.038$.
Again I wonder if the query arose directly from play.
(It seems to me more likely that people knew that
`numbers closer to the average are thrown more often'.) 


\newpage\section*{Exercise~\ref{E;B5}}
(i) If $f(x)=x^{3}+ax-b$ then $f'(x)=3x^{2}+a\geq a>0$ for
all $x$ so $f$ is strictly increasing. Since 
$f(x)\rightarrow -\infty$ as $x\rightarrow -\infty$
and $f(x)\rightarrow \infty$ as $x\rightarrow \infty$,
the function $f$ has exactly one real zero.

(ii) If we set $x=u^{1/3}+v^{1/3}$, then
\begin{align*}
x^{3}+ax&=u+v+3u^{1/3}v^{2/3}+3u^{2/3}v^{1/3}+au^{1/3}+av^{1/3}\\
&=u+v+(3u^{1/3}v^{1/3}+a)(u^{1/3}+v^{1/3}).
\end{align*}

(iii) If 
\begin{align*}
uv&=-\frac{a^{3}}{27}\\
u+v&=b.
\end{align*}
then
\[x^{3}+ax=b+0\times(u^{1/3}+v^{1/3})=b.\]

(iv) Observe that, if $u$ and $v$ are as stated, $u=v-b$
and
\[-\frac{a^{3}}{27}=uv=v(v-b)=v^{2}-bv\]
so $v$ and (by symmetry $u$) are the of roots
\[t^{2}-bt-\frac{a^{3}}{27}=0.\]
Since $u\neq v$ they are the distinct roots.

(v) Solving the quadratic of (iv), we get roots
\[\frac{b\pm\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\]
so $x^{3}+ax=b$ has the root
\[\left(\frac{b+\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3}
+\left(\frac{b-\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3}.\]

(vi) Note that $uv$ must be real. Thus the only allowable possibilities
are
\begin{gather*}
\left(\frac{b+\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3}
+\left(\frac{b-\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3},\\
\omega\left(\frac{b+\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3}
+\omega^{2}\left(\frac{b-\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3},\\
\omega^{2}\left(\frac{b+\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3}
+\omega\left(\frac{b-\sqrt{b^{2}+\frac{4a^{3}}{27}}}{2}\right)^{1/3}.
\end{gather*}
It is easy to check directly (or by looking at $u+v$)
that these are all solutions.

(vi) By Exercise~\ref{E;B2} it suffices to solve
\[z^{3}+az=b.\]
Our earlier manipulations remain valid (though we must be careful
about taking cube roots).

(vii) and (viii) See for example Ian Stewart's excellent
\emph{Galois Theory}.

\newpage\section*{Exercise~\ref{E;C1}}
(i) We have
\begin{align*}
\Pr(\text{at least one six in four tosses})
&=1- \Pr(\text{no six in four tosses})\\
&=1-\Pr(\text{no six in one toss})^{4}\\
&=1-\left(\frac{5}{6}\right)^{4}\approx .5177
\end{align*}
His expected winnings if he stakes one unit is about
$.035$. This is a house advantage of $3\frac{1}{2}$\%.
A casino would certainly be happy to run such a game
but I think it would be very hard work for an individual
to make it pay whilst retaining the appearance of a gentleman.

(ii) We have
\begin{align*}
\Pr(\text{at least one double}&\ \text{six in $24$ tosses})\\
&=1- \Pr(\text{no double six in $24$ tosses})\\
&=1-\Pr(\text{no double six in one toss})^{24}\\
&=1-\left(\frac{35}{36}\right)^{24}\approx 0.4914
\end{align*}
If you stake one unit at evens
against a double six appearing your expected winnings
are about $.017$. Of course, it would be possible for an individual
to lose or make a fortune making this bet, just as it
is possible for an individual
to lose or make a fortune betting heads and tails,
but it would take a very long run of games and very
accurate record keeping to detect the house advantage.

(iii) We have
\begin{align*}
\Pr(\text{at least one double six}&\ \text{in $24$ tosses})\\
&=1- \Pr(\text{no double six in $24$ tosses})\\
&=1-\Pr(\text{no double six in one toss})^{24}\\
&=1-\left(\frac{35}{36}\right)^{25}\approx 0.5055
\end{align*}
The house advantage is about $1$\%.

\newpage\section*{Exercise~\ref{E;C2}}
Writing $N=N(p)$, we want
\begin{align*}
\frac{1}{2}&\approx\Pr(\text{at least one in $N$ goes})\\
&=1-Pr(\text{none in $N$ goes})\\
&=1-Pr(\text{not in $1$ go})^{N}\\
&=1-(1-p)^{N}
\end{align*}
so $(1-p)^{N}\approx 1/2$, Taking logarithms and  using the standard
approximation of Exercise~\ref{E;A8}, we get
\[-\log 2=\log\frac{1}{2}=N\log (1-p)\approx-Np\]
so 
\[N(p)\approx \frac{\log 2}{\log p}.\]
As $p$ gets smaller all our approximations improve.

Thus if $p$ and $q$ are small.
Using the results of Exercise~\ref{E;C1} (and the observation
that $1-(5/6)^{3}\leq .42<1/2$) we know that
$N(1/6)=4$ and $N(1/36)=25$

Now
\[\frac{\log 2}{1/6}\approx 4.159\]
and
\[\frac{\log 2}{1/36}\approx 24.953\]
so the estimates are good.

\newpage\section*{Exercise~\ref{E;C3}}
(i) We have
\begin{align*}
\Pr(&\text{second side wins stake})\\
&=\Pr(\text{second side wins innings three times in a row})\\
&=(1/2)^{3}=1/8.
\end{align*}
Thus the expected winnings of the second team are $22/8$
ducats.

(ii) Suppose team $A$ wins an innings with probability $p$
and team $B$ wins an innings with probability $q$
where $p+q=1$.
Team $A$ wins if they win $r+1$ innings before player
$B$ wins $s+1$ innings. Otherwise team $B$ wins. If the winner
gets $K$ what are the expected winnings of $A$?

We answer as follows.
\begin{align*}
&\Pr(\text{$A$ wins stake})\\
&=\sum_{j=1}^{s}
\Pr(\text{$A$ wins $r$ ins and $B$ wins $j$ ins, then $A$ 
wins an in})\\
&=\sum_{j=0}^{s}\Pr(\text{$A$ wins $r$ ins and $B$ wins $j$ ins})
\Pr(\text{$A$ wins an in})\\
&=p^{r+1}\sum_{j=0}^{s}\binom{r+j}{j}q^{j}
\end{align*}
Thus $A$ has expected winnings
\[Kp^{r+1}\sum_{j=0}^{s}\binom{r+j}{j}q^{j}.\]

\newpage\section*{Exercise~\ref{E;C4}}
(i) The probability of $A$ winning in a single throw
is $r=5/36$. The probability of $A$ winning in two throws
is
\[p=1-\Pr(\text{A loses both})=1-\left(\frac{31}{36}\right)^{2}
=\frac{335}{1296}.\]
The probability of $B$ winning in a single throw
is $r=6/36$. The probability of $A$ winning in two throws
is
\[q=1-\Pr(\text{B loses both})=1-\left(\frac{30}{36}\right)^{2}
=\frac{396}{1296}.\]

If $A$ fails to win on his first throw we have a two sided
duel with $B$ starting so $B$ has probability of winning
\[\frac{q}{q+p-qp}\]
and $B$'s probability of winning the game is
\begin{align*}
(1-r)\frac{q}{q+p-qp}&=\frac{31}{36}\times
\frac{396\times 1296}{(335+396)\times 1296-(335\times396)}\\
&=\frac{31\times 396}{(335+396)\times 36-(335\times 11)}\\
&=\frac{12276}{22631}
\end{align*}
so $A$'s probability of winning is
\[1-\frac{12276}{22631}=\frac{10355}{22631}\]
and the ratio is as stated. (In those days
men were men when it came to arithmetic.)

(ii) (1) We observe
that

\begin{align*}
\Pr(\text{$A$ wins})&=\Pr(\text{$A$ wins on $1$st draw})\\
&+\Pr(\text{$A$ wins on $4$th draw})
+\Pr(\text{$A$ wins on $7$th draw})\\
&=\frac{4}{12}
\ +\frac{8}{12}\times\frac{7}{11}\times\frac{6}{10}
\times\frac{4}{9}\\
&\qquad\qquad+\frac{8}{12}\times\frac{7}{11}\times\frac{6}{10}
\times\frac{5}{9}\times
\frac{4}{8}\times\frac{3}{7}\times\frac{4}{6}\\
&=\frac{165+56+10}{11\times5\times 9}=\frac{77}{165}
\end{align*}


\begin{align*}
\Pr(\text{B wins})&=\Pr(\text{$B$ wins on $2$nd draw})\\
&\qquad\qquad+\Pr(\text{$B$ wins on $5$th draw})\\
&\qquad\qquad+\Pr(\text{$B$ wins on $8$th draw})\\
&=\frac{8}{12}\times\frac{4}{11}
+\frac{8}{12}\times\frac{7}{11}\times\frac{6}{10}
\times\frac{5}{9}\times\frac{4}{8}\\
&\qquad+\frac{8}{12}\times\frac{7}{11}\times\frac{6}{10}\times\frac{5}{9}\\
&\qquad+\frac{4}{8}\times\frac{3}{7}\times{2}{6}\times\frac{4}{5}\\
&=\frac{120+35+4}{11\times5\times 9}=\frac{53}{165}
\end{align*}

Thus the ratio of probabilities is $77:53:35$.

(2) Each player has probability $1/3$ of winning a go.
If $p_{A}$ is the probability of $A$ winning, $p_{B}$
of $B$ and  $p_{C}$
of $C$ then considering the result of the first trial
\begin{align*}
p_{A}&=\tfrac{1}{3}+\tfrac{2}{3}p_{C}\\  
p_{B}&=\tfrac{2}{3}p_{A}\\
p_{C}&=\tfrac{2}{3}p_{B}
\end{align*}
Thus $p_{A}=\tfrac{1}{3}+(\tfrac{2}{3})^{3}p_{A}$
and
\[27p_{A}=9+8p_{A}.\]
If follows that $p_{A}=9/19$, $p_{B}=6/19$ and $p_{C}=4/19$.

Thus the ratio of probabilities is $9:6:4$.

(3) We say that the game goes to the $k$th round
if $A$, $B$ and $C$ have each drawn $k-1$ counters.
The $k$th round consists of the draws then made by $A$ 
and then (if $A$ fails) by $B$ and then by $C$ if
$B$ fails.

We observe that if we reach the $k$th round
$A$ has probability 
\[p_{A}(k)=\frac{4}{13-k}\]
of winning in that round, $B$ has probability
\[p_{B}(k)=(1-p_{A}(k))\frac{4}{13-k}=\frac{9-k}{13-k}\frac{4}{13-k}\]
of wiining that round and 
$C$ has probability
\[p_{C}(k)=(1-p_{A}(k))(1-p_{B}(k))\frac{4}{13-k}
=\left(\frac{9-k}{13-k}\right)^{2}\frac{4}{13-k}\]
and the probability that we go to the next round is
\[P_{X}(k)=\left(\frac{9-k}{13-k}\right)^{3}.\]
We note that $p_{A}(9)=1$, $p_{B}(9)=p_{C}(9)=0$.


The probability that we reach the $k$th round is
thus given by $P_{Y}(k)$ where $P_{Y}(1)=1$ and
\[P_{Y}(k)=\prod_{j=1}^{k-1}P_{X}(k)
=\left(\prod_{j=1}^{k-1}\frac{9-k}{13-k}\right)^{3}.\]
The probability of $A$ winning is
\[\sum_{k=1}^{9}P_{Y}(k)\frac{4}{13-k},\]
the probability of $B$ winning is
\[\sum_{k=1}^{8}P_{Y}(k)\frac{9-k}{13-k}\frac{4}{13-k},\]
and the probability of $C$ winning is
\[\sum_{k=1}^{8}P_{Y}(k)
\left(\frac{9-k}{13-k}\right)^{2}\frac{4}{13-k}.\]



(iii) The probability of a particular correct hand
is
\[p=\frac{40}{40}\times\frac{30}{39}\times\frac{20}{38}\times\frac{10}{37}
=\frac{1000}{13\times19\times 37}=\frac{1000}{9139}\]
so the proportion of their chances is
\[\frac{p_{A}}{1-p_{A}}=\frac{1000}{8139}.\]

(iv) The probability of any particular arrangement
such as 
\[BWBWBWB\] 
is
\[q=\frac{8}{12}\times\frac{7}{11}\times\frac{6}{10}
\times\frac{5}{9}
\times\frac{4}{8}\times\frac{3}{7}\times\frac{2}{6}\]
There are
\[\binom{7}{3}=35\]
different arrangements so the probability of $A$ winning
is
\[35q=35\times\times\frac{1}{11}
\times\frac{1}{9}=\frac{35}{99}.\]
The proportion of chances is $35$ to $64$.

If we allow $A$ to win if he gets $3$ or more white
then we must consider the probability that he gets
$4$ white. The probability of a particular $4$ white hand
is
\[p=\frac{4}{12}\times\frac{3}{11}\times\frac{2}{10}
\times\frac{1}{9}=\frac{1}{11}\times\frac{1}{5}\times\frac{1}{9}\]
and there are
\[\binom{7}{3}=35\]
different arrangements so the probability of $A$ winning
with $4$ white pieces
\[35q=\frac{7}{99}.\]
Thus $A$'s probability of winning with three or more white
counters is
\[\frac{35}{99}+\frac{7}{99}=\frac{42}{99}\]
and the proportion of chances is $42$ to $57$ ie $14$ to $19$.

(v) Enumerating we can throw $11$ by throwing

$1$, $4$, $6$ in some order ($6$ ways) 

$1$, $5$, $5$ in some order ($3$ ways)

$2$, $3$, $6$ in some order ($6$ ways)

$2$, $4$, $5$ in some order ($6$ ways)

$3$, $3$, $5$ in some order ($3$ ways)

$3$, $4$, $4$ in some order ($3$ ways).

Thus we have probability $p=(6+3+6+6+3+3)\times 6^{-3}=27\times 6^{-3}$
of throwing $11$.

Enumerating we can throw $14$ by throwing

$2$, $6$, $6$ in some order ($3$ ways) 

$3$, $5$, $6$ in some order ($6$ ways)

$4$, $4$, $6$ in some order ($3$ ways)

$4$, $5$, $5$ in some order ($3$ ways)

Thus we have probability $q=(3+6+3+3)\times 6^{-3}=15\times 6^{-3}$
of throwing $11$.


If $u_{n}$ is the probability that $A$ will win if he has
$n$ pieces of money then $u_{24}=1$, $u_{0}=0$
and by considering the effect of one throw
\[u_{n}=pu_{n+1}+(1-p-q)u_{n}+qu_{n-1}\]
for $1\leq n\leq 23$. Thus
\[pu_{n+1}-(p+q)u_{n}+qu_{n-1}=0.\]
Now we solve our difference equation by observing that
\[pm^{2}-(p+q)m+q=(m-1)(pm-q)\]
so
\[u_{n}=A+B(q/p)^{n}\]
for some constants $A$ and $B$. 

Since $u_{0}=0$, $B=-A$ so
\[u_{n}=A(1-(p/q)^{n})\]
and, using the fact that $u_{24}=1$.
\[u_{n}=\frac{(1-(p/q)^{n}}{(1-(p/q)^{24}}\]
In particular 
\[u_{12}=\frac{1}{1+(p/q)^{12}}.\]

Thus $A$ probability of winning is
\[\frac{15^{12}}{15^{12}+27^{12}}\]
and the ratio of $A$'s chance to $B$'s chances
is
\[\left(\frac{15}{27}\right)^{12}=\left(\frac{5}{9}\right)^{12}
=\frac{244140625}{282429536481}.\]

\newpage\section*{Exercise~\ref{E;C5}}
(i) Take $X_{j}=1$ (heads)
if $Y_{j}$ is even, $X_{j}=-1$ (tails) 
if $Y_{j}$ is odd.

(iii) The expected time to return to zero is infinite.

(v) The Kelly method is scale invariant
(if you double your fortune, you double your bet)
so the bumpiness is unaffected by the size of 
your fortune.  

If $\alpha>1$ then there will be an $\alpha'<1$
which gives the same long term expected rate
of increase. The ride with $\alpha'$ is less bumpy
than the ride with $\alpha$.
\end{document}
