\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{amsmath}

\title{Chapter 1\\Mathematical Preliminaries}
\author{solutions by Hikari}
\date{June 2021}

\begin{document}

\maketitle

\section*{1.1 Infinite Series}

\paragraph{1.1.1}
(a) If $A>0$, $\lim_{n\to \infty}n^p u_n=A$, so $|n^p u_n-A|< \frac{A}{2}$ when $n\geq N$ for some N. Then $0<\frac{A}{2}\frac{1}{n^p}<u_n<\frac{3A}{2}\frac{1}{n^p}$. $\sum_{n=1}^{\infty}\frac{3A}{2}\frac{1}{n^p}$ converges when $p>1$ by Cauchy integral test, so $\sum_{n=1}^{\infty}u_n$ converges by comparison test.

If $A<0$, then $\lim_{n\to \infty}n^p(-u_n)=-A$, $-A>0$. From above $\sum_1^\infty(-u_n)$ converges, so $\sum_1^\infty(u_n)$ converges.

If $A=0$, $|n^p u_n|< 1$ when $n\geq N$ for some N. Then $-\frac{1}{n^p}<u_n<\frac{1}{n^p}$, so $|u_n|<\frac{1}{n^p}$ for sufficiently large n. $\sum_{n=1}^\infty \frac{1}{n^p}$ converges by Cauchy integral test, so $\sum_{n=1}^{\infty}u_n$ converges by comparison test.
\medskip

(b) $\lim_{n\to\infty}nu_n=A$, so $A-\frac{A}{2}<nu_n<A+\frac{A}{2}$ when $n\geq N$ for some N. So $u_n>\frac{A}{2}\frac{1}{n}$ for sufficiently large n. The harmonic series $\sum_{n=1}^\infty\frac{1}{n}$ diverges, so $\sum_{n=1}^\infty u_n$ diverges.

\paragraph{1.1.2}
Let $b_n'=\frac{b_n}{2K}$, then $\lim_{n\to\infty}\frac{b_n'}{a_n}=\frac{1}{2}$, so for sufficiently large n, $\frac{1}{2}-\frac{1}{2}=0<\frac{b_n'}{a_n}<1=\frac{1}{2}+\frac{1}{2}$. Then $0<b_n'<a_n$ or $0>b_n'>a_n$, so $\sum a_n$ converges implies $\sum b_n'$ converges by comparison test\footnotemark, and therefore $\sum b_n$ converges.

Let $b_n''=\frac{2b_n}{KK}$, then $\lim_{n\to\infty}\frac{b_n''}{a_n}=2$, so for sufficiently large n $2+1=3>\frac{b_n''}{a_n}>1=2-1$.Then $3a_n>b_n''>a_n$ or $3a_n<b_n''<a_n$,  so $\sum a_n$ diverges implies $\sum b_n''$ diverges by comparison test\footnotemark[\value{footnote}], and therefore $\sum b_n$ diverges.

\footnotetext{It's different with the comparison test in the text, but I guess it is right}

\paragraph{1.1.3}
$\int_2^\infty \frac{1}{x(\ln x)^2}dx=-\frac{1}{\ln x}\bigr |_2^\infty=\frac{1}{\ln 2}$, so by Cauchy integral test $\sum_{n=2}^\infty \frac{1}{n(\ln n)^2}$ converges.

\paragraph{1.1.4}
\[\frac{u_n}{u_{n+1}}=1+\frac{(a_1-b_1)n+(a_0-b_0))}{n^2+b_1n+b_0}=1+\frac{a_1-b_1}{n}+\frac{B(n)}{n^2}\] where $B(n)$ is bounded for large n (It can be verified by binomial theorem, that each term in $B(n)$ has negative or zero power of n. By Gauss' test, $\sum_{n=1}^\infty u_n$ converges if $a_1-b_1>1$ and diverges if $a_1-b_1\leq 1$.

\paragraph{1.1.5}
(a) $\ln n<n$, so $\frac{1}{\ln n}>\frac{1}{n}>0$ for all positive integers n, and the harmonic series $\sum_{n=1}^\infty \frac{1}{n}$ diverges implies $\sum_{n=2}^\infty \frac{1}{\ln n}$ diverges.
\medskip

(b) $\frac{(n+1)!}{10^{n+1}}/\frac{n!}{10^n}=\frac{n+1}{10}\geq 1$ for $n\geq 9$, so $\sum_{n=1}^\infty \frac{n!}{10^n}$ diverges by ratio test.
\medskip

(c) $2n(2n+1)>(2n)^2$, so $0<\frac{1}{2n(2n+1)}<\frac{1}{(2n)^2}$.
$\sum_{n=1}^\infty \frac{1}{4n^2}$ converges by integral test, so $\sum_{n=1}^\infty \frac{1}{2n(2n+1)}$ converges by comparison test.
\medskip

(d) $\frac{1}{\sqrt{n(n+1)}}>\frac{1}{\sqrt{(n+1)^2}}=\frac{1}{n+1}>0$. $\sum_{n=1}^\infty \frac{1}{n+1}$ diverges by integral test, so $\sum_{n=1}^\infty[n(n+1)]^{-\frac{1}{2}}$ diverges.
\medskip

(e) $\int_0^\infty \frac{1}{2x+1}=\frac{1}{2}\ln (2n+1)\bigr |_0^\infty$ is infinite, so $\sum_{n=0}^\infty \frac{1}{2n+1}$ diverges by integral test.

\paragraph{1.1.6}
(a) $0<\frac{1}{n(n+1)}<\frac{1}{n^2}$. $\sum_{n=1}^\infty\frac{1}{n^2}$ converges by integral test, so $\sum_{n=1}^\infty \frac{1}{n(n+1)}$ converges by comparison test.
\medskip

(b) $\int_2^\infty \frac{1}{n\ln n}\,dx=\ln \ln n\bigr |_2^\infty$ is infinite, so $\sum_{n=2}^{\infty} \frac{1}{n\ln n}$ converges by integral test.
\medskip

(c) $\frac{1}{(n+1)2^{n+1}}/\frac{1}{n2^n}=\frac{n}{n+1}\frac{1}{2}\leq \frac{1}{2}$ for all n, so $\sum_{n=1}^\infty \frac{1}{n2^n}$ converges by retio test.
\medskip

(d) $\ln \frac{n+1}{n}=\ln (n+1)-\ln n$, so $\sum_{n=1}^\infty \ln (1+\frac{1}{n})=(\ln2-\ln1)+(\ln3-\ln2)+\cdots=\lim_{n\to\infty} \ln n$ is infinite, so $\sum_{n=1}^\infty \ln (1+\frac{1}{n})$ diverges.
\medskip

(e) $n^{\frac{1}{n}}>1$. Let $x_n=n^{\frac{1}{n}}-1$, then $(1+x_n)^n=n$, and $\frac{n(n+1)}{2}x_n^2\leq n$ by binomial theorem, so $0\leq x_n \leq \sqrt{\frac{2}{n-1}}$, and $\lim_{n\to\infty}\sqrt{\frac{2}{n-1}}=0$ implies $\lim_{n\to\infty}x_n=0$, so $\lim_{n\to\infty}n^{\frac{1}{n}}=1$.

$\lim_{n\to\infty}n^{\frac{1}{n}}=1$ implies for sufficiently large n, $0=1-1<n^{\frac{1}{n}}<1+1=2$, so $\frac{1}{n^{\frac{1}{n}}}>\frac{1}{2}$, and $\frac{1}{n\cdot n^{\frac{1}{n}}}>\frac{1}{2n}$. $\sum_{n=1}^\infty \frac{1}{2n}$ diverges by integral test, so $\sum_{n=1}^\infty \frac{1}{n\cdot n^{\frac{1}{n}}}$ diverges by comparison test.

\paragraph{1.1.7}
If $a_1\geq a_2\geq a_3 \geq \cdots \geq 0$, then $\sum_{n=1}^\infty a_n$ converges if and only if $\sum_{k=1}^\infty2^ka_{2k}$ converges\footnote{See Walter Rudin, \textit{Principles of Mathmatical Analysis}, Chapter 3, theorem 3.27}.

$\sum_{k=1}^\infty 2^k \frac{1}{(2^k)^p(\ln 2^k)^q}=2^{(1-p)k}\frac{1}{k^q}\frac{1}{(\ln2)^q}$. If $p>1$, then $\sum_{k=1}^\infty \frac{1}{(2^{p-1})^k}\frac{1}{(\ln 2)^q}$ converges by ratio test, so $\sum_{k=1}^\infty 2^k \frac{1}{(2^k)^p(\ln 2^k)^q}$ converges, and $\sum_{n=2}^\infty \frac{1}{n^p(\ln n)^q}$ converges.

If $p=1$, $\sum_{k=1}^\infty 2^k \frac{1}{(2^k)^p(\ln 2^k)^q}=\frac{1}{k^q}\frac{1}{(\ln2)^q}$, converges if $q>1$.

Therefore, if $p>1$, or $p=1$ and $q>1$, then $\sum_{n=2}^\infty \frac{1}{n^p(\ln n)^q}$ converges.

\paragraph{1.1.8}
\[\gamma=\lim_{n\to\infty}(\sum_{m=1}^n\frac{1}{m}-\ln n)=\sum_{m=1}^{1000}\frac{1}{m}+\lim_{n\to\infty}(\sum_{m=1001}^n\frac{1}{m}-\ln n)\]

\[\lim_{n\to\infty}n=\sum_{m=1001}^\infty\ln \frac{m}{m-1}-\ln 1000\]

\[\gamma=\sum_{m=1}^{1000}\frac{1}{m}-\ln{1000}+\sum_{m=1001}^\infty(\frac{1}{m}-\ln\frac{m}{m-1})\]

\[\int_{1001}^\infty(\frac{1}{x}-\ln\frac{x}{x-1})\,dx\geq\sum_{m=1001}^\infty(\frac{1}{m}-\ln\frac{m}{m-1})\geq \int_{1001}^\infty(\frac{1}{x}-\ln\frac{x}{x-1})\,dx+(\frac{1}{1001}-\ln\frac{1001}{1000})\]

\[\int_{1001}^\infty(\frac{1}{x}-\ln\frac{x}{x-1})\,dx=\ln\frac{x}{x-1}+x\ln\frac{x-1}{x}\Big |_{1001}^\infty=-0.000\,499\,667\]

\[\frac{1}{1001}-\ln\frac{1001}{1000}=-0.000\,000\,499\]

\[\sum_{m=1}^{1000}\frac{1}{m}-\ln1000=0.577\,714\,7\]

\[0.577\,715-0.000\,499>\gamma>0.577\,714-0.000\,500-0.000\,001\]

\[0.577\,213<\gamma<0.577\,216\]

\paragraph{1.1.9}
The number in each shell is proportional to $r^2$, but the solid angle of each shell is proportional to $\frac{1}{r^2}$, so the total solid angle occupied by stars in each shell is the same. Let it be $\omega_0$.

If the solid angle occupied by stars from shell 1 to n is $a_n$, then $a_{n+1}=a_n+a-a_n\cdot \frac{a}{4\pi}$, where $a_n\cdot \frac{a}{4\pi}$ is the solid angle of stars in shell $n+1$ that is blocked by stars in shell 1 to n. So $a_{n+1}-4\pi=(a_n-4\pi)(1-\frac{a}{4\pi})$, and $a_n=(a-4\pi)(1-\frac{a}{4\pi})^{n-1}+4\pi$. $1-\frac{a}{4\pi}<1$, so $\lim_{n\to\infty}a_n=4\pi$.

\paragraph{1.1.10}
\[\frac{u_n}{u_{n+1}}=\left (\frac{2n+2}{2n+1} \right)^2=1+\frac{4n+3}{4n^2+4n+1}=1+\frac{1}{n}+\frac{B(n)}{n^2}\]

where B(n) is bound for large n. By Gauss' test, \[\sum_{n=1}^\infty\left[ \frac{1\cdot3\cdot5\cdots(2n-1)}{2\cdot4\cdot6\cdots(2n)} \right]^2\]

converges.

\paragraph{1.1.11}
(a) $\frac{\ln n}{n}$ is monotonically decreasing, and $\lim_{n\to\infty}\frac{\ln n}{n}=0$, so the series converges by  Leibniz criterion. $\frac{\ln n}{n}\geq \frac{1}{n}$ when $n\geq 3$, and $\sum_{n=1}^\infty\frac{1}{n}$ diverges by integral test, so $\sum_{n=1}^\infty\frac{\ln n}{n}$ diverges by comparison test, so the series is not absolutely convergent.
\medskip

(b)  The series $\frac{1}{1}-\frac{1}{3}+\frac{1}{5}-\cdots$ converges by Leibniz criterion, and so does the series  $\frac{1}{2}-\frac{1}{4}+\frac{1}{6}-\cdots$. So the series  $\frac{1}{1}+\frac{1}{2}-\frac{1}{3}-\frac{1}{4}+\frac{1}{5}+\frac{1}{6}\cdots$ is the sum of two convergent series, and is therefore convergent.
$\sum_{n=1}^\infty\frac{1}{n}$ diverges by integral test, so the series is not absolutely convergent.
\medskip

(c)
Combine adjacent terms with same sign to form a new series $\sum_{n=1}^\infty a_n$
\[(1)-(\frac{1}{2}+\frac{1}{3})+(\frac{1}{4}+\frac{1}{5}+\frac{1}{6})-(\frac{1}{7}+\frac{1}{8}+\frac{1}{9}+\frac{1}{10})+\cdots\]

where \[a_n=\frac{1}{\frac{n^2-n}{2}+1}+\frac{1}{\frac{n^2-n}{2}+2}+\cdots+\frac{1}{\frac{n^2-n}{2}+n}\]
\[a_{n+1}=\frac{1}{\frac{n^2+n}{2}+1}+\frac{1}{\frac{n^2+n}{2}+2}+\cdots+\frac{1}{\frac{n^2+n}{2}+n}+\frac{1}{\frac{n^2+n}{2}+n+1}\]

so $a_n$ has n terms and $a_{n+1}$ has $n+1$ terms.

\[a_{n}-a_{n+1}=(\frac{1}{\frac{n^2-n}{2}+1}-\frac{1}{\frac{n^2+n}{2}+1})+(\frac{1}{\frac{n^2-n}{2}+2}-\frac{1}{\frac{n^2+n}{2}+2})+\cdots+(\frac{1}{\frac{n^2-n}{2}+n}-\frac{1}{\frac{n^2+n}{2}+n})-\frac{2}{n^2+3n+2}\]

The $k^{st}$ term (except for the last term) of $a_{n}-a_{n+1}$ is
\[\frac{1}{\frac{n^2-n}{2}+k}-\frac{1}{\frac{n^2+n}{2}+k}\geq\frac{1}{\frac{n^2-n}{2}+n}-\frac{1}{\frac{n^2+n}{2}+n}=\frac{4}{n^3+4n^2+3n}\]

so \[a_{n}-a_{n+1}\geq\frac{4}{n^3+4n^2+3n}\cdot n-\frac{2}{n^2+3n+2}=\frac{4}{n^2+4n+3}\cdot n-\frac{2}{n^2+3n+2}\geq0\]

which means the sequence $a_n$ is monotonically decreasing.
\[0\leq a_n\leq\frac{1}{\frac{n^2-n}{2}}\cdot n=\frac{2}{n-1}\]

so $\lim_{n\to\infty}a_n=0$ because $\lim_{n\to\infty}\frac{2}{n-1}=0$. Therefore the series converges by Leibniz criterion.
$\sum_{n=1}^\infty\frac{1}{n}$ diverges by integral test, so the series is not absolutely convergent.

\paragraph{1.1.12}
\[\beta(2)=1-\sum_{k=1}^\infty\frac{16k}{(16k^2-1)^2}=1-\sum_{k=1}^{40}\frac{16k}{(16k^2-1)^2}-\sum_{k=41}^\infty\frac{16k}{(16k^2-1)^2}\]

\[\int_{41}^\infty\frac{16x}{(16x^2-1)^2}\,dx\leq\sum_{k=41}^\infty\frac{16k}{(16k^2-1)^2}\leq\int_{41}^\infty\frac{16x}{(16x^2-1)^2}\,dx\,+\frac{16\cdot 41}{(16\cdot 41^2-1)^2}\]

\[1-\sum_{k=1}^{40}\frac{16k}{(16k^2-1)^2}=0.915\,984\,644\]
\[\int_{41}^\infty\frac{16x}{(16x^2-1)^2}\,dx=\frac{-1}{2(16x^2-1)}\Big|_{41}^\infty=0.000\,018\,591\]
\[\frac{16\cdot 41}{(16\cdot 41^2-1)^2}=0.000\,000\,907\]
\[0.915965146\leq\beta(2)\leq0.915966053\]

So $\beta(2)=0.915966$ (to six-digit accuracy).

\paragraph{1.1.13}
\[\zeta(2)+a\alpha_1+b\alpha_2=\sum_{n=1}^\infty(\frac{1}{n^2}+\frac{a}{n(n+1)}+\frac{b}{n(n+1)(n+2)})=\frac{(1+a)n^2+(3+2a+b)n+2}{n^2(n+1)(n+2)}\]

\[\zeta(2)-\alpha_1-\alpha_2=\frac{2}{n^2(n+1)(n+2)}\]

\paragraph{1.1.14}
\[\sum_{n=0}^\infty \frac{1}{(2n+1)^3}+\sum_{n=1}^\infty\frac{1}{(2n)^3}=\sum_{n=1}^\infty\frac{1}{n^3}\]

\[\lambda(3)=\sum_{n=1}^\infty\frac{1}{n^3}-\sum_{n=1}^\infty\frac{1}{(2n)^3}=\frac{7}{8}\sum_{n=1}^\infty\frac{1}{n^3}=\frac{7}{8}\zeta(3)\]
\[\lambda(3)=1.051800\]

to six decimal place.

\paragraph{1.1.15}
(a) \[\sum_{n=2}^\infty[\zeta(n)-1]=\sum_{n=2}^\infty(\sum_{k=1}^\infty\frac{1}{k^n}-1)=\sum_{n=2}^\infty\sum_{k=2}^\infty\frac{1}{k^n}=\sum_{k=2}^\infty\sum_{n=2}^\infty\frac{1}{k^n}=\sum_{k=2}^\infty\frac{\frac{1}{k^2}}{1-\frac{1}{k}}=\sum_{k=2}^\infty(\frac{1}{k-1}-\frac{1}{k})=1\]

(b) \[\sum_{n=2}^\infty(-1)^n[\zeta(n)-1]=\sum_{n=2}^\infty(-1)^n(\sum_{k=1}^\infty\frac{1}{k^n}-1)=\sum_{n=2}^\infty(-1)^n\sum_{k=2}^\infty\frac{1}{k^n}=\sum_{k=2}^\infty\sum_{n=2}^\infty(-1)^n\frac{1}{k^n}\]

\[=\sum_{k=2}^\infty\frac{\frac{1}{k^2}}{1-(-\frac{1}{k})}=\sum_{k=2}^\infty(\frac{1}{k}-\frac{1}{k+1})=\frac{1}{2}\]

\paragraph{1.1.16}
(a) \[\zeta(3)-\alpha_2'=1+\sum_{n=1}^\infty(\frac{1}{n^3}-\frac{1}{(n-1)n(n+1)})=1+\sum_{n=2}^\infty\frac{-1}{(n-1)n^3(n+1)}\]
\[\zeta(3)=\frac{5}{4}-\sum_{n=2}^\infty\frac{1}{n^3(n^2-1)}\]

(b) \[\zeta(3)+\alpha_4'=\frac{5}{4}-\sum_{n=2}^\infty\frac{1}{(n-1)n^3(n+1)}+\sum_{n=3}^\infty\frac{1}{(n-2)(n-1)n(n+1)(n+2)}\]
\[=\frac{29}{24}+\sum_{n=3}^\infty\frac{4}{(n-2)(n-1)n^3(n+1)(n+2)}\]
\[\zeta(3)=\frac{115}{96}+\sum_{n=3}^\infty\frac{4}{(n-2)(n-1)n^3(n+1)(n+2)}\]

(c)
\[\int_{N}^\infty\frac{1}{x^3}\,dx\leq\sum_{n=N}^\infty\frac{1}{n^3}\leq\int_{N}^\infty\frac{1}{x^3}\,dx+\frac{1}{N^3}\]

$\frac{1}{126^3}=4.999\times10^{-7}<5\times10^{-7}$, so 125 terms are required.

\[\int_{N}^\infty\frac{1}{x^3(x^2-1)}\,dx\leq\sum_{n=N}^\infty\frac{1}{n^3(n^2-1)}\leq\int_{N}^\infty\frac{1}{x^3(x^2-1)}\,dx+\frac{1}{N^3(N^2-1)}\]

$\frac{1}{19^3(19^2-1)}=4\times10^{-7}<5\times10^{-7}$, so 17 terms ($n=2$ to $n=18$) are required.

\[\int_{N}^\infty\frac{4}{x^3(x^2-1)(x^2-4)}\,dx\leq\sum_{n=N}^\infty\frac{1}{n^3(n^2-1)(n^2-4)}\leq\int_{N}^\infty\frac{4}{x^3(x^2-1)(x^2-4)}\,dx+\frac{4}{N^3(N^2-1)(N^2-4)}\]

$\frac{4}{10^3(10^2-1)(10^2-4)}=4.2\times10^{-7}<5\times10^{-7}$, so 7 terms ($n=3$ to $n=9$) are required.

\section*{1.2 Series of Functions}

\paragraph{1.2.1}
(a) When $x>0$, $\lim_{n\to\infty}\frac{(-1)^{n-1}}{n^x}=0$, and the sequence $\frac{1}{n^x}$ is monotonically decreasing, so by Leibniz criterion, $\sum_{n=1}^\infty\frac{(-1)^{n-1}}{n^x}$ converges.
When $x\leq0$, $\lim_{n\to\infty}\frac{(-1)^{n-1}}{n^x}\neq0$, so $\sum_{n=1}^\infty\frac{(-1)^{n-1}}{n^x}$ diverges.
Therefore, the series converges for $x>0$, and if the series uniformly converges in the interval $[a,b]$, then $0<a<b$.

For $x\in[a,b]$, $0<a<b$,
\[|S(x)-s_n(x)|=|\sum_{k=n+1}^\infty\frac{(-1)^{k-1}}{k^x}|\leq\frac{1}{(n+1)^x}<\frac{1}{n^x}<\frac{1}{n^a}\]

For any $\epsilon>0$, let $N=(\frac{1}{\epsilon})^{\frac{1}{a}}+1$, then
\[|S(x)-s_n(x)|<\frac{1}{n^a}<\frac{1}{N^a}=\epsilon\]
for all $n\geq N$, so the series is uniformly convergent in the range $[a,b]$ if $0<a<b$.

(b) The series converges when $x>1$ and diverges when $x\leq 1$ by integral test, so if it uniformly converges in interval $[a,b]$, then $1<a<b$.
For $x\in[a,b]$ and $1<a<b$,
$|\frac{1}{n^x}|\leq\frac{1}{n^a}$. $\sum_n \frac{1}{n^a}$ is a convergent series, so by Weierstrass M test,  $\sum_{n=1}^\infty\frac{1}{n^x}$ is uniformly convergent in the range $[a,b]$ if $1<a<b$.

\paragraph{1.2.2}
The series converges when $|x|<1$ and diverges when $|x|\geq1$. If it uniformly converges in the interval $[a,b]$, then $-1<a<b<1$. For $x\in [a,b]$ and $-1<a<b<1$, let $c=\max(|a|,|b|)$, then $|x^n|\leq x^c$. Because $c<1$, so $\sum_{n=0}^\infty x^c$ converges, so by Weietress M test, $\sum_{n=0}^\infty x^n$ uniformly converges in the range $[a,b]$ if $-1<a<b<1$.

\paragraph{1.2.3}
(a) When $0<x\leq1$, $\lim_{n\to\infty}\frac{1}{1+x^n}\neq0$, so the series diverges. When $x>1$, $0<\frac{1}{1+x^n}<\frac{1}{x^n}$. The geometry series $\frac{1}{x^n}$ converges, so $\sum_{n=0}^\infty\frac{1}{1+x^n}$ converges by comparison test.

(b) If the series is uniformly convergent in the interval $[a,b]$, then $1<a<b$. For $x\in [a,b]$ and $1<a<b$, $\frac{1}{1+x^n}<\frac{1}{x^n}\leq\frac{1}{a^n}$. The geometry series $\sum_{n=0}^\infty\frac{1}{a^n}$ converges, so by Weierstrass M test, $\sum_{n=0}^\infty\frac{1}{1+x^n}$ is uniformly convergent in the range $[a,b]$ if $1<a<b$.

\paragraph{1.2.4}
For $x\in[a,b]$, $|a_n\cos nx+b_n\sin nx|\leq|a_n|+|b_n|$. $\sum |a_n|$ and $\sum |b_n|$ converges, so $\sum(|a_n|+|b_n|)$ converges, so $\sum(a_n\cos nx+b_n\sin nx)$ is uniformly convergent by Weierstrass M test in the range $[a,b]$ for any $a<b$.

\paragraph{1.2.5}
Let $j=2n$, $a_n(x)=u_{2n}(x)$, then $a_{n+1}(x)=\frac{(2n+1)(2n+2)-l(l+1)}{(2n+2)(2n+3)}x^2a_n(x)$.
$\lim_{n\to\infty}\frac{a_{n+1}(x)}{a_n(x)}=x^2>1$ when $|x|>1$ and $\lim_{n\to\infty}\frac{a_{n+1}(x)}{a_n(x)}<1$ when $|x|<1$, so by ratio test the series diverges when $|x|>1$ and converges when $|x|<1$. When $x=1$, $\frac{a_n}{a_{n+1}}=\frac{4n^2+10n+6}{4n^2+6n+2-l(l+1)}=1+\frac{4n+4+l(l+1)}{4n^2+6n+2-l(l+1)}=1+\frac{1}{n}+\frac{B(n)}{n^2}$, where $B(n)$ is bound for large n. By Gauss' test, the series diverges when $x=1$, so the range of convergence is $-1<x<1$.
\paragraph{1.2.6}
Let $j=2m$, $a_m(x)=u_{2m}(x)$. when $x=\pm1$,  $\frac{a_m(x)}{a_{m+1}(x)}=1+\frac{3}{2m}+\frac{B(m)}{m^2}$, where $B(m)$ is bound for large m. By Gauss' test, the series converges at $x=\pm1$.

\paragraph{1.2.7}
Let $j=2m$, $u_m=a_{2m}$, then $\frac{u_m}{u_{m+1}}=\frac{4m^2+(4k+6)m+(k+1)(k+2)}{4m^2+(4k+4\alpha)m+k(k+2\alpha)-n(n+2\alpha)}=1+\frac{6-4\alpha}{4m}+\frac{B(m)}{m^2}$, where $B(m)$ is bound for large m. By Gauss' test, the series converges $\alpha<\frac{1}{2}$ and diverges when $\alpha\geq\frac{1}{2}$.

\paragraph{1.2.8}
\[\sin x=\sum_{n=0}^\infty\frac{x^n}{n!}\left(\frac{d^n\sin{x}}{dx^n}\Big|_{x=0}\right)=\sum_{k=0}^\infty\frac{x^{2k}}{(2k)!}(-1)^k\sin{0}+\sum_{k=0}^\infty\frac{x^{2k+1}}{(2k+1)!}(-1)^k\cos{0}=\sum_{n=0}^\infty(-1)^n\frac{x^{2n+1}}{(2n+1)!}\]

\[\cos x=\sum_{n=0}^\infty\frac{x^n}{n!}\left(\frac{d^n\cos{x}}{dx^n}\Big|_{x=0}\right)=\sum_{k=0}^\infty\frac{x^{2k}}{(2k)!}(-1)^k\cos{0}+\sum_{k=0}^\infty\frac{x^{2k+1}}{(2k+1)!}(-1)^{k+1}\sin{0}=\sum_{n=0}^\infty(-1)^n\frac{x^{2n}}{(2n)!}\]

\paragraph{1.2.9}
expand $\sin{x}$ and $\cos{x}$ for 4 terms, and perform long division.
\[
\renewcommand{\arraystretch}{1.5}
\begin{array}{ccccccccccc}
& & & & & &\frac{1}{x} &-\frac{x}{3} &-\frac{x^3}{45} &-\frac{2x^5}{945} &\cdots \\
\cline{7-11}
&x &-\frac{x^3}{6} &+\frac{x^5}{120} &-\frac{x^7}{5040} &\surd &1 &-\frac{x^2}{2} &+\frac{x^4}{24} &-\frac{x^6}{720} &\cdots \\
& & & & & &1 &-\frac{x^2}{6} &+\frac{x^4}{120} &-\frac{x^6}{5040} &\cdots \\
\cline{7-11}
& & & & & & &-\frac{x^2}{3} &+\frac{x^4}{30} &-\frac{x^6}{840} &\cdots \\
& & & & & & &-\frac{x^2}{3} &+\frac{x^4}{18} &-\frac{x^6}{360} &\cdots \\
\cline{8-11}
& & & & & & & &-\frac{x^4}{45} &+\frac{x^6}{630} &\cdots \\
& & & & & & & &-\frac{x^4}{45} &+\frac{x^6}{270} &\cdots \\
\cline{9-11}
& & & & & & & & &-\frac{2x^6}{945} &\cdots \\
\end{array}
\]

So $\cot{x}=\frac{1}{x}-\frac{x}{3}-\frac{x^3}{45}-\frac{2x^5}{945}+\cdots$.

\paragraph{1.2.10}
\[\frac{d}{dx}\coth^{-1}x=\frac{1}{1-x^2}=\frac{d}{dx}\left(\frac{1}{2}\ln\frac{x+1}{x-1}\right)=\frac{1}{1-x^2}\]

So $\frac{d^n}{dx^n}\coth^{-1}x=\frac{d^n}{dx^n}\left(\frac{1}{2}\ln\frac{x+1}{x-1}\right)$, and $\sum_{n=0}^\infty\frac{x^n}{n!}\frac{d^n}{dx^n}\coth^{-1}x=\sum_{n=0}^\infty\frac{x^n}{n!}\frac{d^n}{dx^n}\left(\frac{1}{2}\ln\frac{x+1}{x-1}\right)$.

Therefore, $\coth^{-1}x=\frac{1}{2}\ln\frac{x+1}{x-1}$.

\paragraph{1.2.11}
(a) $\frac{d}{dx}x^{\frac{1}{2}}=\frac{1}{2}x^{-\frac{1}{2}}$ is undefined at $x=0$, so Maclaurin expansion does not exist.

(b)
\[x^{\frac{1}{2}}=\sum_{n=0}^\infty\frac{(x-x_0)^n}{n!}\frac{d^n}{dx^n}x^{\frac{1}{2}}=\sum_{n=0}^\infty u_n(x)\]
\[\lim_{n\to\infty}\frac{u_{n+1}(x)}{u_n(x)}= \lim_{n\to\infty}\left|\frac{(x-x_0)^{n+1}}{(n+1)!}\frac{d^{n+1}}{dx^{n+1}}x^{\frac{1}{2}}\Big/\frac{(x-x_0)^n}{n!}\frac{d^n}{dx^n}x^{\frac{1}{2}}\right|=\lim_{n\to\infty}\left|\frac{x-x_0}{x_0}\frac{2n-1}{2n+2} \right|<1\] when $|x-x_0|<x_0$, so the series converges when $|x-x_0|<x_0$. When $x=0$, all the terms are less than 0, and
\[\frac{u_{n}(x)}{u_{n+1}(x)}=\frac{2n+2}{2n-1}=1+\frac{2}{2n-1}=1+\frac{1}{n}+\frac{B(n)}{n^2}\] where B(n) is bound for large n, so the series diverges by Gauss' test.
When $x=2x_0$, $\sum_{n=0}^\infty u_n(x)$ is an alternating series, and $\lim_{n\to\infty}u_n(x)=0$, so the series converges by Leibniz criterion.
Therefore, the range of convergence is $0<x\leq 2x_0$.

\paragraph{1.2.12}
\[\lim_{x\to x_0}\frac{f(x)}{g(x)}=\lim_{x\to x_0}\frac{f(x_0)+(x-x_0)f'(x_0)+\sum_{n=2}^{\infty}a_n(x-x_0)^n}{g(x_0)+(x-x_0)g'(x_0)+\sum_{n=2}^{\infty}b_n(x-x_0)^n}\]

When $f(x_0)=g(x_0)=0$,
\[\lim_{x\to x_0}\frac{f(x)}{g(x)}=\lim_{x\to x_0}\frac{(x-x_0)f'(x_0)+\sum_{n=2}^{\infty}a_n(x-x_0)^n}{(x-x_0)g'(x_0)+\sum_{n=2}^{\infty}b_n(x-x_0)^n}=\lim_{x\to x_0}\frac{f'(x_0)+\sum_{n=1}^\infty c_n(x-x_0)^n}{g'(x_0)}=\lim_{x\to x_0}\frac{f'(x)}{g'(x)}\]
by binomial theorem\footnote{This is not a formal proof of l'H\^{o}pital's rule}.

\paragraph{1.2.13}
(a) \[\frac{1}{n}-\ln{\frac{n}{n-1}}=\frac{1}{n}+\ln{\frac{n-1}{n}}=\frac{1}{n}+
\ln{(1-\frac{1}{n})}=\frac{1}{n}-\sum_{k=1}^\infty(\frac{1}{n})^k=-\sum_{k=2}^\infty(\frac{1}{n})^k<0\]

(b) \[\frac{1}{n}-\ln{\frac{n+1}{n}}=\frac{1}{n}-\ln{(1+\frac{1}{n})}=\frac{1}{n}-\sum_{k=1}^\infty(-1)^{k+1}(\frac{1}{n})^k=\sum_{k=2}^\infty(-1)^k(\frac{1}{n})^k>0\]

Euler-Mascheroni constant:
\[\gamma=\lim_{n\to\infty}\left(\sum_{k=1}^n\frac{1}{k}-\ln{n}\right)=1+\sum_{n=2}^\infty(\frac{1}{n}-\ln{\frac{n}{n-1}})<1\]
\[\gamma=1+\sum_{n=2}^\infty(\frac{1}{n}-\ln{\frac{n}{n-1}})=1+\sum_{n=1}^\infty(\frac{1}{n+1}-\ln{\frac{n+1}{n}})=1-1+\sum_{n=1}^\infty(\frac{1}{n}-\ln{\frac{n+1}{n}})+\lim_{n\to\infty}\frac{1}{n+1}>0\]
So the Euler-Mascheroni constant $\gamma$ is bound by 0 and 1, and is therefore finite.

\paragraph{1.2.14}
\[\psi(x\pm h)=\psi(x)\pm h\psi'(x)+\frac{h^2}{2}\psi''(x)\pm \frac{h^3}{6}\psi^{(3)}(x)+\frac{h^4}{24}\psi^{(4)}(x)+\cdots\]
\[\frac{1}{h^2}\left[\psi(x+h)-2\psi(x)+\psi(x-h)\right]=\psi''(x)+\frac{h^2}{12}\psi^{(4)}(x)+\cdots\]

So the error is $\frac{h^2}{12}\psi^{(4)}(x)$.

\paragraph{1.2.15}
$\sin{x}=x-\frac{x^3}{6}+\frac{x^5}{120}-\frac{x^7}{5040}+\cdots$, $\tan{x}=x+\frac{x^3}{3}+\frac{2x^5}{15}+\frac{7x^7}{315}+\cdots$ (expansion of $\tan{x}$ can be obtained by long division of expansions of $\sin{x}$ and $\cos{x}$).
The term of highest order in $(\sin{(\tan{x})}-\tan{(\sin{x})})$ is $x^7$, the coefficient is \\
$\left\{\left[\frac{7}{315}-\frac{1}{6}\left(3\times\frac{2}{15}+3\times\frac{1}{3^2}\right)+\frac{1}{120}\left(5\times\frac{1}{3}\right)-\frac{1}{5040}\right]-\left[-\frac{1}{5040}+\frac{1}{3}\left(3\times\frac{1}{120}+3\times\frac{1}{36}\right)+\frac{2}{15}\left(5\times\frac{-1}{6}+\frac{7}{315} \right)\right]\right\}x^7$

\[\lim_{x\to\infty}\left[\frac{\sin{(\tan{x})}-\tan{(\sin{x})}}{x^7} \right]=-\frac{1}{30}\]

\paragraph{1.2.16}
If the convergence ranges of the series $\sum_{n=0}^\infty a_n x^n$ is $-R<x<R$, then $\lim_{n\to\infty}\left|\frac{a_n+1}{a_n}R\right|=1$. The differentiated series is $\sum_{n=1}^\infty na_nx^{n-1}$, $\lim_{n\to\infty}\left|\frac{n+1}{n}\frac{a_n+1}{a_n}x\right|=\lim_{n\to\infty}\left|\frac{a_n+1}{a_n}x\right|<1$ when $-R<x<R$ (ignoring the end points). The integrated series is $\sum_{n=0}^\infty\frac{a_n}{n+1}x^{n+1}$, $\lim_{n\to\infty}\left|\frac{n+1}{n+2}\frac{a_n+1}{a_n}x\right|=\lim_{n\to\infty}\left|\frac{a_n+1}{a_n}x\right|<1$ when $-R<x<R$ (ignoring the end points). So all the series have the same converging range (ignoring the end points).

\section*{1.3 Binomial Theorem}

\paragraph{1.3.1}
\[P(x)=c\left(\frac{\cosh{x}}{\sinh(x)}-\frac{1}{x} \right)=c\frac{(1+\frac{x^2}{2}+\frac{x^4}{24}+\cdots)-(1+\frac{x^3}{6}+\frac{x^4}{120})}{x+\frac{x^3}{6}+\frac{x^5}{120}+\cdots}=c\frac{\frac{x}{3}+\frac{x^3}{30}+\cdots}{1+\frac{x^2}{6}+\cdots}\]
\[=c(\frac{x}{3}+\frac{x^3}{30}+\cdots)(1-\frac{x^2}{6}+\cdots)=c\left(\frac{x}{3}-\frac{x^3}{45}+\cdots\right)\]

\paragraph{1.3.2}
By binomial theorem, $\frac{1}{1-x^2}=\sum_{n=0}^\infty(-1)^n x^{2n}$, $\int_0^1\frac{1}{1+x^2}dx=\sum_{n=0}^\infty(-1)^n\frac{x^{2n+1}}{2n+1}$. At $x=1$, $\lim_{n\to\infty}(-1)^n x^{2n}\neq 0$, so the series diverges; $\lim_{n\to\infty}\frac{x^{2n+1}}{2n+1}=0$ and the sequence $\frac{x^{2n+1}}{2n+1}$ is monotonically decreasing, so by Leibniz criterion the series converges.

\paragraph{1.3.3}
$e^{-t}t^n=\sum_{p=0}^\infty\frac{(-t)^p}{p!}t^n$. When $-a\leq t\leq a$ \,($a>0$), $\left|\frac{(-t)^p}{p!}t^n\right|\leq\frac{a^{p+n}}{p!}$ and $\sum_{p=0}^\infty\frac{a^{p+n}}{p!}$ is convergent, so by Weierstrass M test $\sum_{p=0}^\infty\frac{(-t)^p}{p!}t^n$ is uniformly convergent in $-a\leq t\leq a$ for every $a>0$, and the series can be integrated by terms.

\[\int_0^x e^{-t}t^n dt=\int_0^x\sum_{p=0}^\infty\frac{(-t)^p}{p!}t^n=\sum_{p=0}^\infty\int_0^x(-1)^p\frac{t^{n+p}}{p!}dt=\sum_{p=0}^\infty(-1)^p\frac{x^{n+p+1}}{p!(n+p+1)}\]
For $-a\leq x\leq a$\,($a>0$), the integrated series converges by Leibniz criterion, so the range of convergence is $-a\leq t\leq a$ for every $a>0$.

\paragraph{1.3.4}
(a) $x=\sinh{y}=\frac{e^y-e^{-y}}{2}=y+\frac{y^3}{6}+\frac{y^5}{120}+\cdots$. Because x in terms of y has only terms of odd orders, y in terms of x can only has terms of odd orders too. Let $y=a_1x+a_3x^3+a_5x^5+\cdots$, substituting into $x=y+\frac{y^3}{6}+\frac{y^5}{120}+\cdots$, obtaining $x=a_1x+(a_3+\frac{a_1^3}{6})x^3+(a_5+\frac{a_1^2a_3}{2}+\frac{a_1^5}{120})x^5+\cdots$, so $a_1=1$, $a_3=-\frac{1}{6}$, $a_5=\frac{3}{40}$. Therefore  $\sinh^{-1}x=x-\frac{x^3}{6}+\frac{3x^5}{40}+\cdots$.
\medskip

(b) $\frac{d}{dx}\sinh^{-1}x=(x^2+1)^{-1/2}$, $\frac{d^2}{dx^2}\sinh^{-1}x=-x(x^2+1)^{-3/2}$, $\frac{d^3}{dx^3}\sinh^{-1}x=-(x^2+1)^{-3/2}+3x^2(x^2+1)^{-5/2}$, $\frac{d^4}{dx^4}\sinh^{-1}x=9x(x^2+1)^{-5/2}-15x^3(x^2+1)^{-7/2}$, $\frac{d^5}{dx^5}\sinh^{-1}x=9(x^2+1)^{-5/2}-90x^2(x^2+1)^{-7/2}+105x^4(x^2+1)^{-9/2}$. So $\sinh^{-1}x=\sum_{n=0}^\infty\frac{x^n}{n!}\frac{d^n}{dx^n}\sinh^{-1}x=x-\frac{x^3}{6}+\frac{3x^5}{40}+\cdots$.

\paragraph{1.3.5}
\[\frac{1}{(1-x)^{n+1}}=\sum_{m=0}^\infty\binom{-(n+1)}{m}(-x)^m=\sum_{m=0}^\infty\frac{(n+m)!}{m!n!}x^m=\sum_{m'=n}^\infty\frac{m'!}{(m'-n)!n!}x^{m'-n}=\sum_{m=n}^\infty\binom{m}{n}x^{m-n}\]
In the third equal sign we use a substitution $m'=m+n$.

\paragraph{1.3.6}
\[(1+x)^{-\frac{m}{2}}=\sum_{n=0}^\infty\binom{-\frac{m}{2}}{n}x^n=\sum_{n=0}^\infty\frac{(-1)^n\frac{(m+2n-2)!!}{2^n (m-2)!!}}{n!}=\sum_{n=0}^\infty(-1)^n\frac{(m+2n-2)!!}{2^n n!(m-2)!!}\]

\paragraph{1.3.7}
(a) $\nu'=\nu(1\pm \frac{v}{c}+(\frac{v}{c})^2+\cdots) $

(b) $\nu'=\nu(1\pm \frac{v}{c})$

(c) $\nu'=\nu(1\pm\frac{v}{c}+\frac{1}{2}(\frac{v}{c})^2)+\cdots$

\paragraph{1.3.8}
(a) $v_1=c(\delta+\frac{1}{2}\delta^2)$

(b) $v_2=c\delta(1+\frac{1}{2}\delta)(1-2\delta+\cdots)=c(\delta-\frac{3}{2}\delta^2+\cdots)$

(c) Solve for $v_3$, obtaining $v_3=c\frac{\delta^2+2\delta}{2+2\delta+\delta^2}=c\delta(1+\frac{\delta}{2})(1-\delta\cdots)=c(\delta-\frac{1}{2}\delta^2+\cdots)$

\paragraph{1.3.9}
\[\frac{w}{c}=\frac{2(1-\alpha)}{1+(1-\alpha^2)}\frac{1-\alpha}{1-\alpha+\frac{\alpha^2}{2}}=(1-\alpha)\left[1-(-\alpha+\frac{\alpha^2}{2})+(-\alpha+\frac{\alpha^2}{2})^2-(-\alpha+\frac{\alpha^2}{2})^3+\cdots\right]\]

\[=(1-\alpha)(1+\alpha+\frac{\alpha^2}{2}+\cdots)=1-\frac{\alpha^2}{2}-\frac{\alpha^3}{2}+\cdots\]

\paragraph{1.3.10}
\[x=\frac{c^2}{g}\left\{ 1+\frac{1}{2}\left(g\frac{t}{c}\right)-\frac{1}{8}\left(g\frac{t}{c}\right)^4+\frac{1}{16}\left(g\frac{t}{c}\right)^6-\cdots \right\}=\frac{1}{2}gt^2-\frac{1}{8}\frac{g^3t^4}{c^2}+\frac{1}{16}\frac{g^5t^6}{c^4}-\cdots\]

\paragraph{1.3.11}
\[\frac{\gamma^2}{(s+n-|k|^2)^2}=\frac{\gamma^2}{\left(n+|k|(1-\frac{1}{2}\frac{\gamma^2}{|k|^2}+\cdots-1)\right)^2}=\frac{\gamma^2}{n^2(1-\frac{\gamma^2}{2n|k|})^2+\cdots}=\frac{\gamma^2}{n^2}(1+\frac{\gamma^2}{n|k|}+\cdots)=\frac{\gamma^2}{n^2}+\frac{\gamma^4}{n^3|k|}+\cdots\]

\[E=mc^2\left[1-\frac{1}{2}\left(\frac{\gamma^2}{n^2}+\frac{\gamma^4}{n^3|k|}+\cdots\right)+\frac{3}{8}\left(\frac{\gamma^2}{n^2}+\frac{\gamma^4}{n^3|k|}+\cdots\right)^2 +\cdots\right]\]

\[=mc^2\left[1-\frac{1}{2}\frac{\gamma^2}{n^2}+(\frac{3}{8}-\frac{n}{2|k|})\frac{\gamma^4}{n^4}+\cdots \right] \]

\paragraph{1.3.12}
(a)
\[R=\frac{2mc^2(1+\frac{E_k}{2mc^2})^{1/2}-2mc^2}{E_k}=\frac{\frac{1}{2}E_k+\cdots}{E_k}\approx \frac{1}{2}\]
(b)
\[R=\sqrt{\frac{2mc^2(E_k+2mc^2)}{E_k^2}}-\frac{2mc^2}{E_k}\approx0\]

\paragraph{1.3.13}
The first series converges for $|x|<1$, and the second series converges for $|x^{-1}|<1$, that is, $|x|>1$. The ranges of convergence of the two series do not overlap, so when adding together to get $\sum_{n=-\infty}^\infty x^n$, nowhere can the series converge.

\paragraph{1.3.14}
(a) By binomial theorem, when $|x|<1$, \[\frac{1}{1-x}=\sum_{n=0}^\infty\binom{-1}{n}(-x)^n=\sum_{n=0}^\infty x^n\]
\[\frac{x}{(1-x)^2}=x\sum_{n=0}^\infty\binom{-2}{n}(-x)^n=x\sum_{n=0}^\infty(n+1)x^n=\sum_{n=1}^\infty nx^n\]
\[\langle \varepsilon \rangle=\frac{\varepsilon_0 e^{\frac{-\varepsilon_0}{kT}}}{(1-\frac{-\varepsilon_0}{kT})^2}\Big/ \frac{1}{1-\frac{-\varepsilon_0}{kT}}==\frac{\varepsilon_0}{e^{\frac{\varepsilon_0}{kT}}-1}\]

(b)
\[\langle \varepsilon \rangle=\frac{\varepsilon_0}{1+\frac{\varepsilon_0}{kT}+\cdots-1}\approx kT\]

\paragraph{1.3.15}
\[\tan^{-1}x=\int_{0}^x\frac{dt}{1+t^2}=\int_0^\infty\sum_{n=0}^\infty(-1)^n t^{2n}=\sum_{n=0}^\infty(-1)^n\frac{x^{2n+1}}{2n+1}\]
When $-a<t<a$ and $0<a<1$, the series $\sum_{n=0}^\infty (-1)^n t^{2n}$ is uniformly convergent by Weierstrass M test, so the series can be integrated by term.

\paragraph{1.3.16}
\[\frac{2+2\varepsilon}{1+2\varepsilon}=2(1+\varepsilon)(1-2\varepsilon+4\varepsilon^2-\cdots)=2-2\varepsilon+4\varepsilon^2-\cdots\]
\[\frac{\ln(1+2\varepsilon)}{\varepsilon}=\frac{2\varepsilon-\frac{4\varepsilon^2}{2}+\frac{8\varepsilon^3}{3}-\cdots}{\varepsilon}=2-2\varepsilon+\frac{8}{3}\varepsilon^2-\cdots\]
\[\lim_{n\to\infty}f(\varepsilon)=\lim_{n\to\infty}\frac{(1+\varepsilon)}{\varepsilon^2}\left(\frac{4}{3}\varepsilon^2+\cdots\right)=\frac{4}{3}\]

\paragraph{1.3.17}
\[\xi_1=1+\frac{A^2(1-2A^{-1}+A^{-2})}{2A}\left[-(A^{-1}+\frac{A^{-2}}{2}+\frac{A^{-3}}{3}+\frac{A^{-4}}{4}+\cdots )-(A^{-1}-\frac{A^{-2}}{2}+\frac{A^{-3}}{3}-\frac{A^{-4}}{4}+\cdots ) \right]\]
\[=1+\frac{A}{2}(1-2A^{-1}+A^{-2})(-2A^{-1}-\frac{2}{3}A^{-3}-\cdots)=2A^{-1}-\frac{4}{3}A^{-2}+\frac{2}{3}A^{-3}+\cdots\]
\[\xi_2=\frac{2}{A}(1+\frac{2}{3}A^{-1})^{-1}=2A^{-1}(1-\frac{2}{3}A^{-1}+\frac{4}{9}A^{-2}-\cdots)=2A^{-1}-\frac{4}{3}A^{-2}+\frac{8}{9}A^{-3}+\cdots\]
The difference in the coefficients of the $A^{-3}$ term is $\frac{2}{9}$.

\paragraph{1.3.18}
(a) \[\arctan{x}=\int_0^\infty\frac{1}{1+t^2}dt=\int_0^\infty\sum_{k=0}^\infty(-1)^k t^{2k}dt=\sum_{k=0}^\infty\frac{x^{2k+1}}{2k+1}\]
(In exercise 1.3.15 we have verified that this series expansion is valid in $-a\leq x\leq a$ for $0<a<1$).
\[\int_{0}^1\arctan{t}\frac{dt}{t}=\int_0^1\sum_{n=0}^\infty\frac{t^{2k}}{2k+1}dt=\sum_{k=0}^\infty(-1)^k\frac{1}{(2k+1)^2}\]
which is the Catalan's constant.

(b) Integrating by parts,
\[-\int_0^1\ln{x}\frac{dx}{1+x^2}=-\left[(\ln{x})\arctan{x}\Big|_0^1-\int_0^1\frac{1}{x}\arctan{x}dx \right]=\int_0^1\arctan{x}\frac{dx}{x}\]
which is the same with (a).

\section*{1.4 Mathematical Induction}
\paragraph{1.4.1}
If the equation holds for $n=k-1$, then  $\sum_{j=1}^{k-1}j^4=\frac{k-1}{30}(2k-1)(k)(3k^2-3k-1)=\frac{k^5}{5}-\frac{k^4}{2}+\frac{k^3}{3}-\frac{k}{30}$, and $\sum_{j=1}^{k}j^4=\sum_{j=1}^{k-1}j^4+k^4=\frac{k^5}{5}+\frac{k^4}{2}+\frac{k^3}{3}-\frac{k}{30}=\frac{k}{30}(2k+1)(k+1)(3k^2+3k-1)$. $\sum_{j=1}^1j^4=1=\frac{1}{30}(2+1)(1+1)(3+3-1)$. The equation holds for $n=1$, and if it holds for $n=k-1$ then it will holds for $n=k$, so the equation holds for all positive integers by mathematical induction.

\paragraph{1.4.2}
If $(\frac{d}{dx})^n[f(x)g(x)]=\sum_{j=0}^n\binom{n}{j}\left[(\frac{d}{dx})^jf(x) \right]\left[(\frac{d}{dx})^{n-j}g(x) \right]$, then
\[\left(\frac{d}{dx} \right)^{n+1}\left[f(x)g(x) \right]=\sum_{j=0}^n\binom{n}{j}\left[\left(\frac{d}{dx} \right)^{j+1}f(x) \right]\left[\left(\frac{d}{dx} \right)^{n-j}g(x) \right]
+\sum_{j=0}^n\binom{n}{j}\left[\left(\frac{d}{dx} \right)^{j}f(x) \right]\left[\left(\frac{d}{dx} \right)^{n-j+1}g(x) \right]\]
\[=\sum_{j=1}^{n+1}\binom{n}{j-1}\left[\left(\frac{d}{dx} \right)^{j}f(x) \right]\left[\left(\frac{d}{dx} \right)^{n+1-j}g(x) \right]
+\sum_{j=0}^n\binom{n}{j}\left[\left(\frac{d}{dx} \right)^{j}f(x) \right]\left[\left(\frac{d}{dx} \right)^{n+1-j}g(x) \right]\]
\[=\sum_{j=1}^n\binom{n+1}{j}\left[\left(\frac{d}{dx} \right)^{j}f(x) \right]\left[\left(\frac{d}{dx} \right)^{n+1-j}g(x) \right]
+\left[\left(\frac{d}{dx} \right)^{n+1}f(x) \right]\left[\left(\frac{d}{dx} \right)g(x) \right]+\left[\left(\frac{d}{dx} \right)f(x) \right]\left[\left(\frac{d}{dx} \right)^{n+1}g(x) \right]\]
\[=\sum_{j=0}^{n+1}\binom{n+1}{j}\left[\left(\frac{d}{dx} \right)^{j}f(x) \right]\left[\left(\frac{d}{dx} \right)^{n+1-j}g(x) \right]\]
so the equation holds for all positive integers by mathematical induction.

\section*{1.5 Operations On Series Expansions Of Functions}

\paragraph{1.5.1}
\[\int_{-x}^x\frac{dt}{1-t~^2}=\frac{1}{2}\int_{-x}^x\left(\frac{1}{1-t}+\frac{1}{1+t}\right)dt=\frac{1}{2}\left[-\ln{\frac{1-x}{1+x}} +\ln{\frac{1+x}{1-x}}\right]=\ln{\frac{1+x}{1-x}}\]

\paragraph{1.5.2}
If the equation holds for p
\[\frac{1}{n(n+1)\cdots(n+p)}=\frac{1}{p!}\sum_{j=0}^p (-1)^j \binom{p}{j}\frac{1}{n+j}\]
\[\frac{1}{n(n+1)\cdots(n+p)(n+p+1)}=\frac{1}{p!}\sum_{j=0}^p (-1)^j \binom{p}{j}\frac{1}{n+j}\frac{1}{n+p+1}\]
\[=\frac{1}{p!}\sum_{j=0}^p (-1)^j \binom{p}{j}\left(\frac{1}{n+j}-\frac{1}{n+p+1}\right)\frac{1}{p+1-j}\]
\[=\frac{1}{(p+1)!}\sum_{j=0}^p (-1)^j\frac{p+1}{p+1-j} \binom{p}{j}\left(\frac{1}{n+j}-\frac{1}{n+p+1}\right)\]
\[=\frac{1}{(p+1)!}\sum_{j=0}^p(-1)^j\binom{p+1}{j}\frac{1}{n+j}-\frac{1}{(p+1)!}\frac{1}{n+p+1}\sum_{j=0}^p(-1)^j\binom{p+1}{j}\]
\[=\frac{1}{(p+1)!}\sum_{j=0}^p(-1)^j\binom{p+1}{j}\frac{1}{n+j}-\frac{1}{(p+1)!}\frac{1}{n+p+1}(-1)^{p+1}\sum_{j=1}^{p+1}(-1)^{j}\binom{p+1}{j}\]
\[=\frac{1}{(p+1)!}\sum_{j=0}^p(-1)^j\binom{p+1}{j}\frac{1}{n+j}+\frac{1}{(p+1)!}\frac{1}{n+p+1}(-1)^{p+1}\sum_{j=1}^{p+1}(-1)^{j-1}\binom{p+1}{j}\]
\[=\frac{1}{(p+1)!}\sum_{j=0}^p(-1)^j\binom{p+1}{j}\frac{1}{n+j}+\frac{1}{(p+1)!}\frac{1}{n+p+1}(-1)^{p+1}\]
\[=\frac{1}{(p+1)!}\sum_{j=0}^{p+1}(-1)^j\binom{p+1}{j}\frac{1}{n+j}\]
So the equation holds for p+1. The equation hold for 1. Therefore, it holds for all positive integers by mathematical induction.

\paragraph{1.5.3}
\[u_n(p)=\frac{1}{(n+1)\cdots(n+p-1)}\frac{1}{p}\left[\frac{1}{n}-\frac{1}{n+p} \right]=\frac{1}{p}\left[u_n(p-1)-u_{n+1}(p-1) \right]\]
\[\sum_{n=1}^\infty u_n(p)=\frac{u_1(p-1)}{p}=\frac{1}{p\cdot p!}\]

\paragraph{1.5.4}
Substituting Eq. (1.88) into Eq. (1.87):
\[f(x)=\sum_{n=0}^\infty\sum_{j=0}^n(-1)^{n+j}\binom{n}{j}\frac{x^n}{(1+x)^{n+1}}c_{n-j}\]
Rearrange the series by $n'=n-j$
\[f(x)=\sum_{n'=0}^\infty\sum_{j=0}^\infty(-1)^{n'}\binom{n'+j}{j}\frac{x^{n'+j}}{(1+x)^{n'+1+j}}c_{n'}
=\sum_{n'=0}^\infty(-1)^{n'}c_{n'}\frac{x^{n'}}{(1+x)^{n'+1}}\sum_{j=0}^\infty\binom{n'+j}{j}\left(\frac{x}{1+x} \right)^j\]
\[=\sum_{n'=0}^\infty(-1)^{n'}c_{n'}\frac{x^{n'}}{(1+x)^{n'+1}}\sum_{j=0}^\infty\binom{-n'-1}{j}\left(-\frac{x}{1+x} \right)^j =\sum_{n'=0}^\infty(-1)^{n'}c_{n'}\frac{x^{n'}}{(1+x)^{n'+1}}\left(1-\frac{x}{1+x} \right)^{-n'-1}\]
\[=\sum_{n'=0}^\infty(-1)^{n'}c_{n'}\frac{x^{n'}}{(1+x)^{n'+1}}(1+x)^{n'+1}=\sum_{n'=0}^\infty(-1)^{n'}c_{n'}x^{n'}=\sum_{n=0}^\infty(-1)^{n}c_{n}x^{n}\]

\paragraph{1.5.5}
Let $\arctan{x}=\sum_{n=0}^\infty(-1)^n c_n x^n$, then from $n=0$, $c_n=0, -\frac{1}{1}, 0, \frac{1}{3}, 0, -\frac{1}{5}, \cdots$, which means there are only odd terms. $a_n=\sum_{j=0}^n(-1)^j\binom{n}{j}c_{n-j}$, when n is odd, $a_n=\sum_{j=0,2,4,\cdots,n-1}\binom{n}{j}c_{n-j}=\sum_{k=1,3,5,\cdots,n}\binom{n}{k}c_k=-\binom{n}{1}\frac{1}{1}+\binom{n}{3}\frac{1}{3}-\binom{n}{5}\frac{1}{5}+\cdots$; when n is even, $a_n=\sum_{j=1,3,5,\cdots,n-1}(-1)\binom{n}{j}c_{n-j}=\sum_{k=1,3,5,\cdots,n-1}(-1)\binom{n}{k}c_k=\binom{n}{1}\frac{1}{1}-\binom{n}{3}\frac{1}{3}+\binom{n}{5}\frac{1}{5}-\cdots$. The numerical verification of $\arctan{(1)}$ and $\arctan{(3^{-1/2})}$ is straightforward by using Eq. (1.87).

\section*{1.6 Some Important Series}
\paragraph{1.6.1}
$\ln{(1+x)}=x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}+\frac{x^5}{5}-\cdots$, $\ln{(1-x)}=-x-\frac{x^2}{2}-\frac{x^3}{3}-\frac{x^4}{4}-\frac{x^5}{5}-\cdots$, so $\ln{\left(\frac{1+x}{1-x} \right)}=\ln{(1+x)}-\ln{(1-x)}=2\left(x+\frac{x^3}{3}+\frac{x^5}{5}+\cdots \right)$.

\section*{1.7 Vectors}

\paragraph{1.7.1}
$3(A_x)^2=1.732^2$, so $A_x=A_y=A_z\approx1.000$

\paragraph{1.7.2}
$(\textbf{B}-\textbf{A})+(\textbf{C}-\textbf{B})+(\textbf{A}-\textbf{C})=0$

\paragraph{1.7.3}
(a) $(x-x_1)^2+(y-y_1)^2+(z-z_1)^2=0$

(b) $\mathbf{r}=\mathbf{r}+\mathbf{a}$

\paragraph{1.7.4}
Let $\mathbf{v}_i'$ and $\mathbf{r}_i'$ be the velocity and position of the $i$th galaxy viewed from $\mathbf{r}_1$. Then $\mathbf{v}_i'=\mathbf{v}_i-\mathbf{v}_1=H_0\mathbf{r}_i-H_0\mathbf{r}_1=H_0\mathbf{r}_i'$

\paragraph{1.7.5}
Diagonals: $\pm(1,1,1), \pm(-1,1,1), \pm(1,-1,1), \pm(1,1,-1)$

Diagonals of faces: $\pm(1,-1,0),\pm(1,0,-1),\pm(0,1,-1)$

\paragraph{1.7.6}
(a) $(x-a_x)a_x+(y-a_y)a_y+(z-a_z)a_z=0$. It is the surface containing the tip of $\mathbf{a}$ and perpendicular to $\mathbf{a}$.

(b)$(x-a_x)x+(y-a_y)a_y+(z-a_z)a_z=0$, so $(x-\frac{a_x}{2})^2+(y-\frac{a_y}{2})^2+(z-\frac{a_z}{2})^2=\frac{a_x^2+a_y^2+a_z^2}{4}$. It is a sphere cantered at the tip of $\frac{1}{2}\mathbf{a}$ with radius  $\frac{1}{2}|\mathbf{a}|$.

\paragraph{1.7.7}
$(1,0,1)\cdot(0,1,-1)/(\sqrt{2}\cdot\sqrt{2})=-1/2=\cos{\theta}$, so $\theta=120^\circ$

\paragraph{1.7.8}
$(1+t-2,1+2t-1,1+3t-3)\cdot(1,2,3)=0$, so $t=\frac{1}{2}$, and the nearest point is $(\frac{3}{2},2,\frac{5}{2})$. So the nearest distance with $(2,1,3)$ is $\sqrt{\frac{3}{2}}$.

\paragraph{1.7.9}
Let the position vector of three vertices of the triangle be $\mathbf{A}, \mathbf{B}, \mathbf{C}$. Let the median from \textbf{C} and the median from \textbf{B} intersect at point \textbf{X}. Then $\mathbf{X}-\mathbf{B}=m(\frac{\mathbf{A}}{2}+\frac{\mathbf{C}}{2}-\mathbf{B})$,  $\mathbf{X}-\mathbf{C}=m(\frac{\mathbf{A}}{2}+\frac{\mathbf{B}}{2}-\mathbf{C})$. Solve for $m,n$ obtaining $m=n=\frac{2}{3}$, and $\mathbf{X}=\frac{\mathbf{A}}{3}+\frac{\mathbf{B}}{3}+\frac{\mathbf{C}}{3}$. $\mathbf{X}-\mathbf{A}=\frac{-2\mathbf{A}}{3}+\frac{\mathbf{B}}{3}+\frac{\mathbf{C}}{3}=\frac{2}{3}(-\mathbf{A}+\frac{\mathbf{B}}{2}+\frac{\mathbf{C}}{2})$. Therefore, the three medians intersect at one point, and the distances from this point to three vertices are $2/3$ of the median's length.

\paragraph{1.7.10}
$|\mathbf{A}|^2=|\mathbf{B}|^2+|\mathbf{C}|^2-2\mathbf{B}\cdot\mathbf{C}=|\mathbf{B}|^2+|\mathbf{C}|^2-2|\mathbf{B}||\mathbf{C}|$

\paragraph{1.7.11}
$\mathbf{Q}=-2\mathbf{P}$, so \textbf{Q} and \textbf{P} are anti-parallel. $\mathbf{P}\cdot\mathbf{R}=0$ and $\mathbf{Q}\cdot\mathbf{R}=0$, so \textbf{R} is perpendicular to \textbf{P} and \textbf{Q}.

\section*{1.8 Complex Numbers And Functions}

\paragraph{1.8.1}
$x+iy=re^{i\theta}$ where $r=\sqrt{x^2+y^2}$ and  $\theta=\tan^{-1}\frac{y}{x}$. $(x+iy)^{-1}=r^{-1}e^{-i\theta}=\frac{1}{\sqrt{x^2+y^2}}(\cos{(-\theta)}+i\sin{(-\theta}))=\frac{x}{x^2+y^2}-i\frac{y}{x^2+y^2}$

\paragraph{1.8.2}
$(re^{i\theta})^{1/2}=r^{1/2}e^{i\theta/2}$ is a complex number. $i^{1/2}=(e^{i\pi/2})^{1/2}=e^{i\pi/4}=\frac{\sqrt{2}}{2}+\frac{\sqrt{2}}{2}i$

\paragraph{1.8.3}
(a)
\[\cos{n\theta}=\Re{\left[e^{in\theta}\right]}=\Re{\left[(e^{i\theta})^n\right]}=\Re{\left[\sum_{k=0}^n\binom{n}{k}\cos^{n-k}\theta\sin^k\theta(i)^k\right]}=\]
\[\sum_{k=0,2,4,\cdots}\binom{n}{k}\cos^{n-k}\theta\sin^k\theta(-1)^{k/2}
=\cos^n\theta-\binom{n}{2}\cos^{n-2}\theta\sin^2\theta+\binom{n}{4}\cos^{n-4}\theta\sin^{n}\theta-\cdots\]

(b)
\[\sin{n\theta}=\Im{\left[e^{in\theta}\right]}=\Im{\left[(e^{i\theta})^n\right]}=\Im{\left[\sum_{k=0}^n\binom{n}{k}\cos^{n-k}\theta\sin^k\theta(i)^k\right]}=\]
\[\sum_{k=1,3,5,\cdots}\binom{n}{k}\cos^{n-k}\theta\sin^k\theta(-1)^{(k-1)/2}
=\binom{n}{1}\cos^{n-1}\theta\sin\theta-\binom{n}{3}\cos^{n-3}\theta\sin^3\theta+\cdots\]

\paragraph{1.8.4}
(a)
\[\sum_{n=0}^{N-1}\cos{nx}=\Re{\left[\sum_{n=0}^{N-1}e^{inx} \right]}=\Re{\left[\frac{1-e^{iNx}}{1-e^{ix}} \right]}=\Re{\left[\frac{e^{iNx/2}}{e^{ix/2}}\left(\frac{e^{iNx/2}-e^{-iNx/2}}{e^{ix/2}-e^{-ix/2}} \right) \right]}=\left(\cos{\frac{(N-1)x}{2}}\right)\frac{\sin{(Nx/2)}}{\sin{(x/2)}} \]

(b)
\[\sum_{n=0}^{N-1}\sin{nx}=\Im{\left[\sum_{n=0}^{N-1}e^{inx} \right]}=\Im{\left[\frac{1-e^{iNx}}{1-e^{ix}} \right]}=\Im{\left[\frac{e^{iNx/2}}{e^{ix/2}}\left(\frac{e^{iNx/2}-e^{-iNx/2}}{e^{ix/2}-e^{-ix/2}} \right) \right]}=\left(\sin{\frac{(N-1)x}{2}}\right)\frac{\sin{(Nx/2)}}{\sin{(x/2)}} \]

\paragraph{1.8.5}
$\sin{z}=z-\frac{z^3}{3!}+\frac{z^5}{5!}-\cdots$, $\cos{z}=1-\frac{z^2}{2!}+\frac{z^4}{4!}-\cdots$, $\sinh{z}=\frac{e^z-e^{-z}}{2}=z+\frac{z^3}{3!}+\frac{z^5}{5!}+\cdots$, $\cosh{z}=\frac{e^x+e^{-x}}{2}=1+\frac{z^2}{2!}+\frac{z^4}{4!}+\cdots$. Substituting $iz$ for $z$, then we obtain all the four equations.

\paragraph{1.8.6}
(a)
\[\sin{(x+iy)}=\frac{e^{-y+ix}-e^{y-ix}}{2i}=\frac{e^{-y}\cos{x}-e^y\cos{x}}{2i}+\frac{ie^{-y}\sin{x}+ie^y\sin{x}}{2i}=\sin{x}\cosh{y}+i\cos{x}\sinh{y} \]
\[\cos{(x+iy)}=\frac{e^{-y+ix}+e^{y-ix}}{2}=\frac{e^{-y}\cos{x}+e^y\cos{x}}{2}+\frac{ie^{-y}\sin{x}-ie^y\sin{x}}{2}=\cos{x}\cosh{y}-i\sin{x}\sinh{y} \]

(b)
\[|\sin{z}|^2=\sin^2x(1+\sinh^2y)+(1-\sin^2x)\sinh^2y=\sin^2x+\sinh^2y\]
\[|\cos{z}|^2=\cos^2x(1+\sinh^2y)+(1-\cos^2x)\sinh^2y=\cos^2x+\sinh^2y\]

\paragraph{1.8.7}
(a)
\[\sinh{(x+iy)}=i\sin{(y-ix)}=i(\sin{y}\cosh{x}-i\cos{y}\sinh{x})=\sinh{x}\cos{y}+i\cosh{x}\sin{y}\]
\[\cosh{x+iy}=\cos{y-ix}=\cos{y}\cosh{x}+i\sin{y}\sinh{x}=\cosh{x}\cos{y}+i\sinh{x}\sin{y}\]

(b)
\[|\sinh{(x+iy)}|^2=|\sin{(y-ix)}|^2=\sin^2{y}+\sinh^2{(-x)}=\sinh^2{x}+\sin^2{y}\]
\[|\cosh{(x+iy)}|^2=|\cos{(y-ix)}|^2=\cos^2{y}+\sinh^2{(-x)}=1-\sin^2{y}+\cosh^2{x}-1=\cosh^2{x}-\sin^2{y}\]

\paragraph{1.8.8}
(a)
\[\frac{\sinh{(\frac{z}{2})}}{\cosh{(\frac{z}{2}})}=\frac{\sinh{(\frac{x}{2})}\cos{(\frac{y}{2})}+i\cosh{(\frac{x}{2})}\sin{(\frac{y}{2})}}{\cosh{(\frac{x}{2})}\cos{(\frac{y}{2})}+i\sinh{(\frac{x}{2})}\sin{(\frac{y}{2})}}=\frac{\cosh(\frac{x}{2})\sinh(\frac{x}{2})+i\cos(\frac{y}{2})\sin(\frac{y}{2})}{\cosh^2(\frac{x}{2})\cos^2(\frac{y}{2})+\sinh^2(\frac{x}{2})\sin^2(\frac{y}{2})}\]
\[=\frac{\frac{1}{2}\sinh{x}+i\frac{1}{2}\sin{y}}{\frac{\cosh{x}+1}{2}\frac{1+\cos{y}}{2}+\frac{\cosh{x}-1}{2}\frac{1-\cos{y}}{2}}=\frac{\sinh{x}+i\sin{y}}{\cosh{x}+\cos{y}}\]
(b)
\[\coth(\frac{z}{2})=\frac{1}{\tanh(\frac{z}{2})}=\frac{\cosh{x}+\cos{y}}{\sinh{x}+i\sin{y}}=\frac{(\cosh{x}+\cos{y})(\sinh{x}-i\sin{y})}{\sinh^2{x}+\sin^2{y}}\]
\[=\frac{(\cosh{x}+\cos{y})(\sinh{x}-i\sin{y})}{\cosh^2{x}-\cos^2{y}}=\frac{\sinh{x}-i\sin{y}}{\cosh{x}-\cos{y}}\]

\paragraph{1.8.9}
\[\tan^{-1}x=\int_0^x\frac{1}{1+x^2}dx=\int_0^x(1-x^2+x^4-\cdots)dx=x-\frac{x^3}{3}+\frac{x^5}{5}-\cdots\]
\[\ln(1-ix)=-{ix}-\frac{(ix)^2}{2}-\frac{(ix)^3}{3}-\frac{(ix)^4}{4}-\frac{(ix)^5}{5}-\cdots\]
\[\ln(1+ix)={ix}-\frac{(ix)^2}{2}+\frac{(ix)^3}{3}-\frac{(ix)^4}{4}+\frac{(ix)^5}{5}-\cdots\]
\[\frac{i}{2}\ln\left(\frac{1-ix}{1+ix} \right)=\frac{i}{2}\left(\ln(1-ix)-\ln(1+ix) \right)=\frac{i}{2}(-2)\left((ix)+\frac{(ix)^3}{3}+\frac{(ix)^5}{5}+\cdots \right)=x-\frac{x^3}{3}+\frac{x^5}{5}-\cdots\]

\paragraph{1.8.10}
(a) \[(-8)^{1/3}=\left(8e^{i(1+2n)\pi} \right)^{1/3}=2e^{i\frac{\pi}{3}}, 2e^{i\pi},2e^{-i\frac{\pi}{3}}=1+\sqrt{3}i,-2,1-\sqrt{3}i\]
(b) \[i^{1/4}=(e^{i(\frac{1}{2}+2n)\pi})^{1/4}=e^{i\frac{\pi}{8}},e^{i\frac{5\pi}{8}},e^{i\frac{9\pi}{8}},e^{i\frac{13\pi}{8}} \]
(c) \[\frac{1}{\sqrt{2}}+\frac{1}{\sqrt{2}}i\]

\paragraph{1.8.11}
(a) \[(1+i)^3=\left(\sqrt{2}e^{i\frac{\pi}{4}} \right)^3=2^{3/2}e^{i3\pi/4}\]

(b) \[\left(e^{i(-1+2n)\pi} \right)^{1/5}=e^{ik\pi/5} \]
where $k=1,3,5,7,9$

\section*{1.9 Derivatives and Extrema}

\paragraph{1.9.1}
\[f(x,y)=\sum_{n=0}^\infty\frac{x^n}{n!}\frac{\partial^nf}{\partial x^n}\Big|_{0,y}=
\sum_{n=0}^\infty\frac{x^n}{n!}\sum_{m=0}^\infty\frac{y^m}{m!}\frac{\partial^{m+n}f}{\partial y^m\partial x^n}\Big|_{0,0}\]
Rearrange the double series by $p=m+n$ and $q=n$,
\[f(x,y)=\sum_{p=0}^\infty\sum_{q=0}^p\frac{x^{p-q}}{(p-q)!}\frac{y^q}{q!}\frac{\partial^{m+n}f}{\partial y^m\partial x^n}\Big|_{0,0}
=\sum_{p=0}^\infty\sum_{q=0}^p\frac{1}{p!}\binom{p}{q}x^{p-q}y^q\frac{\partial^{m+n}f}{\partial y^m\partial x^n}\Big|_{0,0}\]

\paragraph{1.9.2}
Expand the function in every variable as in Exercise 1.9.1, then
\[f(x_1,\cdots,x_m)=\sum_{n_1=0}^\infty\cdots\sum_{n_m=0}^\infty\frac{x_1^{n_1}}{n_1!}\cdots\frac{x_m^{n_m}}{n_m!}\frac{\partial^{n_1+\cdots+n_m}}{\partial x_1^{n_1}\cdots\partial x_m^{n_m}}f(0,\cdots,0)\]
Let $n=n_1+\cdots+n_m$, substitute $\alpha_i t$ for $x_i$, and apply the generalized form of binomial theorem (Eq 1.80)
\[f(x_1,\cdots,x_m)=\sum_{n_1=0}^\infty\cdots\sum_{n_m=0}^\infty\frac{1}{n!}\frac{n!}{n_1!\cdots n_m!}t^{n_1\cdots+n_m}\left(\alpha_1\frac{\partial}{\partial x_1} \right)^{n_1}\cdots\left(\alpha_m\frac{\partial}{\partial x_m} \right)^{n_m}f(0,\cdots,0)\]
\[=\sum_{n=0}^\infty\frac{t^n}{n!}\left(\alpha_1\frac{\partial}{\partial x_1}+\cdots+\alpha_m\frac{\partial}{\partial x_m} \right)^nf(0,\cdots,0)
=\sum_{n=0}^\infty\frac{t^n}{n!}\left(\sum_{i=1}^m\alpha_i\frac{\partial}{\partial x_i} \right)^n f(0,\cdots,0)\]

\section*{1.10 Evaluation of Integrals}

\paragraph{1.10.1}
\[\Gamma(n)=\int_0^\infty t^{n-1}e^{-t}dt=-t^{n-1}e^{-t}\Big|_0^\infty+\int_0^\infty(n-1)t^{n-2}e^{-t}dt=(n-1)\Gamma(n-1)\]
We have integrated by parts and applied the definition of $\Gamma(n-1)$. Keep reducing n by this method until $n=1$, and note that $\Gamma(1)=1$, we  obtain
\[\Gamma(n)=(n-1)!\]

\paragraph{1.10.2}
Let $J(a)=\int_o^\infty e^{-ax}\frac{\sin{x}}{x}dx$, then $\int_0^\infty \frac{\sin x}{x}dx=J(0)$.
\[\frac{dJ(a)}{da}=-\int_0^\infty e^{-ax}\sin{x}dx=-\Im{\left[ \int_0^\infty e^{(-a+i)x} \right] dx}=-\Im{\left
[\frac{e^{(-a+i)x}}{-a+i}\bigg|_0^\infty \right]}=\frac{-1}{a^2+1}\]
\[J(a)=\int\frac{-1}{a^2+1}da=-\tan^{-1}a+c=-\tan^{-1}a+\frac{\pi}{2}\]
where $c$ is determined by $J(\infty)=0$.
\[\int_0^\infty \frac{\sin x}{x}dx=J(0)=\frac{\pi}{2}\]

\paragraph{1.10.3}
\[\int_0^\infty\frac{dx}{\cosh{x}}=\int_0^\infty\frac{2}{e^x+e^{-x}}dx=\int_0^\infty\frac{2e^{-x}}{1+e^{-2x}}=\int_0^\infty2e^{-x}(1-e^{-2x}+e^{4x}-\cdots)dx=2(\frac{1}{1}-\frac{1}{3}+\frac{1}{5}-\cdots) \]
where the expansion is valid for all positive x because $e^{-2x}<1$ for all positive x. $\tan^{-1}1=\frac{\pi}{4}=\int_0^1\frac{1}{1+x^2}dx=\int_0^1(1-x^2+x^4-\cdots) dx=1-\frac{1}{3}+\frac{1}{5}-\cdots$, so
\[\int_0^\infty\frac{dx}{\cosh{x}}=2\tan^{-1}1=\frac{\pi}{2}\]

\paragraph{1.10.4}
\[\int_0^\infty\frac{dx}{e^{ax}+1}=\int_0^\infty\frac{e^{-ax}}{1+e^{-ax}}=\int_0^\infty e^{-ax}(1-e^{-ax}+e^{-2ax}-\cdots)dx=\frac{1}{a}(\frac{1}{1}-\frac{1}{2}+\frac{1}{3}-\cdots)=\frac{1}{a}\ln{(1+1)}=\frac{\ln{2}}{a}\]

\paragraph{1.10.5}
Integrating by parts
\[\int_\pi^\infty\frac{\sin{x}}{x^2}dx=\frac{-1}{x}\sin{x}\Big|_\pi^\infty-\int_\pi^\infty-\frac{\cos{x}}{x}dx=-\mathrm{Ci}(\pi)\]
where $\mathrm{Ci}(x)$ is the cosine integral (see Table 1.2)

\paragraph{1.10.6}
Let $J(a)=\int_0^\infty e^{-ax}\frac{\sin{x}}{x}dx$, which is the same as Exercise 1.10.2, then $\int_0^\infty e^{-x}\frac{\sin{x}}{x}dx=J(1)$.
\[\int_0^\infty e^{-x}\frac{\sin{x}}{x}dx=-\tan^{-1}{1}+\frac{\pi}{2}=\frac{\pi}{4}\]

\paragraph{1.10.7}
Integrating by parts
\[\int_0^x \mathrm{erf}(t)dt=\mathrm{erf}(t)\cdot t\Big|_0^x-\int_0^x d\,\mathrm{erf}(t)\cdot t=x\,\mathrm{erf}(x)-\int_0^x\frac{2}{\sqrt{\pi}}e^{-t^2}dt\cdot t=x\,\mathrm{erf}(x)+\frac{e^{-x^2}-1}{\sqrt{\pi}}\]

\paragraph{1.10.8}
Integrating by parts
\[\int_1^x\mathrm{E_1}(t)\,dt=\mathrm{E_1}(t)\,t\Big|_1^x-\int_1^x d\,\mathrm{E_1}(t)\cdot t=\mathrm{E_1}(t)\,t\Big|_1^x-\int_1^x -t^{-1}e^{-t}\,dt\cdot t=\mathrm{E_1}(t)\,t\Big|_1^x-e^{-t}\Big|_1^x\]
\[=x\,\mathrm{E_1}(x)-\mathrm{E_1}(1)+e^{-1}-e^{-x} \]

\paragraph{1.10.9}
Let $y=x+1$
\[\int_0^\infty\frac{e^{-x}}{x+1}dx=\int_1^\infty\frac{e^{-y+1}}{y}dy=e\,\mathrm{E_1}(1) \]

\paragraph{1.10.10}
Integrating by parts
\[I=\int_0^\infty(\tan^{-1}x)^2\frac{1}{x^2}dx=-(\tan^{-1}x)^2\frac{1}{x}\Big|_0^\infty-\int_0^\infty2\tan^{-1}x\frac{1}{1+x^2}\frac{-1}{x}dx=\int_0^\infty\frac{2\tan^{-1}x}{(1+x^2)x}dx\]
Let $J(a)=\int_0^\infty\frac{2\tan^{-1}ax}{(1+x^2)x}dx$, then $I=J(1)$
\[\frac{dJ(a)}{da}=\int_0^\infty\frac{2}{(1+x^2)x}\frac{x}{1+a^2x^2}=\frac{2}{1-a^2}\int_0^\infty\left(\frac{1}{1+x^2}-\frac{a^2}{1+a^2x^2} \right)dx\]
\[=\frac{2}{1-a^2}\left[\tan^{-1}x\Big|_0^\infty-a\tan^{-1}ax\Big|_0^\infty \right]=\frac{2}{1-a^2}\left[(1-a)\frac{\pi}{2} \right] =\frac{\pi}{1+a}\]
\[J(a)=\int\frac{\pi}{1+a}da=\pi\ln|1+a|+c=\pi\ln|1+a|\]
where $c=0$ is determined by $J(0)=0$. So
\[\int_0^\infty\left(\frac{\tan^{-1}x}{x} \right)^2dx=J(1)=\pi\ln2\]

\paragraph{1.10.11}
\[A=4\int_0^a dx\int_0^{b\sqrt{1-\frac{x^2}{a^2}}}dy=4\int_0^ab\sqrt{1-\frac{x^2}{a^2}}dx\]
Let $\frac{x}{a}=\sin{\theta}$, then$\sqrt{1-\frac{x^2}{a^2}}=\cos{\theta}$, $dx=a\cos{\theta}d\theta$, and the range of integration becomes $0$ to $\frac{\pi}{2}$
\[A=4\int_0^\frac{\pi}{2}ab\cos^2\theta d\theta=4ab\left(\frac{\theta}{2}+\frac{\sin{2\theta}}{4} \right)\Big|_0^{\frac{\pi}{2}}=\pi ab\]

\paragraph{1.10.12}
\[A=\int_{-\frac{\pi}{3}}^\frac{\pi}{3}d\theta\int_{\frac{1}{2}\sec{\theta}}^1 r\,dr=\int_{-\frac{\pi}{3}}^\frac{\pi}{3}\frac{1}{2}\left(1-\frac{\sec^2\theta}{4} \right)d\theta=\left(\frac{\theta}{2}-\frac{\tan{\theta}}{8} \right)\Big|_{-\frac{\pi}{3}}^{\frac{\pi}{3}}=\frac{\pi}{3}-\frac{\sqrt{3}}{4}\]
Which is the area of the circular sector minus the area of triangle.

\section*{1.11 Dirac Delta Function}

\paragraph{1.11.1}
\[\lim_{n\to\infty}\int_{-\infty}^\infty f(x)\delta_n(x)dx=\lim_{n\to\infty}\int_{-\frac{1}{2n}}^{\frac{1}{2n}}f(x)n\,dx=\lim_{n\to\infty}f(\xi_n)\frac{1}{n}n=f(0)\]
where $-\frac{1}{2n}\leq\xi_n\leq\frac{1}{2n}$ (by mean value theorem).

\paragraph{1.11.2}
Let $nx=\tan\theta$, then $1+n^2x^2=\sec^2\theta$, and $ndx=\sec^2\theta d\theta$. The range of integration becomes $-\frac{\pi}{2}$ to $\frac{\pi}{2}$
\[\int_{-\infty}^\infty\frac{n}{\pi}\frac{1}{1+n^2x^2}dx==\int_{-\frac{\pi}{2}}^\frac{\pi}{2}\frac{n}{\pi}\frac{1}{\sec^2\theta}\frac{1}{n}\sec^2\theta\,d\theta=\frac{\theta}{\pi}\Big|_{-\frac{\pi}{2}}^\frac{\pi}{2} =1\]

\paragraph{*1.11.3}
The proof probably requires contour integral of complex analysis, while I have no idea whether there is any elementary proof.

\paragraph{1.11.4}
Let $a(x-x_1)=y$, then $x=\frac{y}{a}+x_1$, $adx=dy$
\[\int_{-\infty}^\infty f(x)\delta[a(x-x_1)]dx=\frac{1}{a}\int_{-\infty}^\infty f(\frac{y}{a}+x_1)\delta(y)dy=\frac{1}{a}f(\frac{0}{a}+x_1)=\frac{1}{a}f(x_1)=\int_{-\infty}^\infty f(x)\frac{1}{a}\delta(x-x_1)dx\]
so $\delta[a(x-x_1)]=\frac{1}{a}\delta(x-x_1)$.

\paragraph{1.11.5}
When $(x-x_1)(x-x_2)\neq0$, $\delta[(x-x_1)(x-x_2)]=0$, so
\[\int_{-\infty}^\infty f(x)\delta[(x-x_1)(x-x_2)]dx=\int_{x_1-\varepsilon}^{x_1+\varepsilon}f(x)\delta[(x-x_1)(x-x_2)]dx+\int_{x_2-\varepsilon}^{x_2+\varepsilon}f(x)\delta[(x-x_1)(x-x_2)]dx\]
for arbitrarily small positive $\varepsilon$. Then
\[\lim_{\varepsilon\to0}\int_{x_1-\varepsilon}^{x_1+\varepsilon}f(x)\delta[(x-x_1)(x-x_2)]dx+\int_{x_2-\varepsilon}^{x_2+\varepsilon}f(x)\delta[(x-x_1)(x-x_2)]dx\]
\[=\int_{x_1-\varepsilon}^{x_1+\varepsilon}f(x)\delta[(x-x_1)(x_1-x_2)]dx+\int_{x_2-\varepsilon}^{x_2+\varepsilon}f(x)\delta[(x_2-x_1)(x-x_2)]dx\]
\[=\int_{x_1-\varepsilon}^{x_1+\varepsilon}f(x)\frac{1}{|x_1-x_2|}\delta(x-x_1)dx+\int_{x_2-\varepsilon}^{x_2+\varepsilon}f(x)\frac{1}{|x_1-x_2|}\delta(x-x_2)dx\]
\[=\int_{-\infty}^\infty f(x)\frac{\delta(x-x_1)+\delta(x-x_2)}{|x_1-x_2|}dx\]
Therefore,
\[\delta[(x-x_1)(x-x_2)]=\frac{\delta(x-x_1)+\delta(x-x_2)}{|x_1-x_2|}\]

\paragraph{1.11.6}
Integrating by parts
\[\int_{-\infty}^\infty f(x)x\frac{d\delta(x)}{dx}dx=f(x)x\delta(x)\Big|_{-\infty}^\infty-\int_{-\infty}^\infty[f'(x)x+f(x)]\delta(x)dx=0-f(0)=-\int_{-\infty}^\infty f(x)\delta(x)dx\]
Therefore,
\[x\frac{d\delta(x)}{dx}=-\delta(x)\]

\paragraph{1.11.7}
Integrating by parts
\[\int_{-\infty}^\infty\frac{d\delta(x)}{dx}f(x)dx=\delta(x)f(x)\Big|_{-\infty}^\infty-\int_{-\infty}^\infty\delta(x)f'(x)dx=-f'(0)\]

\paragraph{1.11.8}
(The equation holds only when $f(x)$ has only one zero point) When $f(x)\neq0$, $\delta\left(f(x)\right)=0$, so
\[\int_{-\infty}^\infty h(x)\delta(f(x))dx=\int_{x_0-\varepsilon}^{x_0+\varepsilon}h(x)\delta\left((x-x_0)f'(x_0)+\frac{(x-x_0)^2}{2}f''(x_0)+\cdots \right)dx\]
for arbitrary small positive $\varepsilon$. Then
\[\lim_{\varepsilon\to 0}\int_{x_0-\varepsilon}^{x_0+\varepsilon} h(x)\delta(f(x))dx
=\lim_{\varepsilon\to 0}\int_{x_0-\varepsilon}^{x_0+\varepsilon} h(x)\delta\left((x-x_0)f'(x_0)\right)dx
=\int_{-\infty}^{\infty} h(x)\frac{1}{|f'(x_0)|}\delta(x-x_0) dx\]
by Exercise 1.11.4. Therefore
\[\delta\left(f(x) \right)=\frac{1}{|f'(x_0)|}\delta(x-x_0)\]

\paragraph{1.11.9}
(a)
\[\int_{-\infty}^\infty\frac{n}{2\cosh^2{nx}}dx=\frac{1}{2}\tanh{nx}\Big|_{-\infty}^\infty=1\]
(b)
\[\int_{-\infty}^x\frac{n}{2\cosh^2{nx}}dx=\frac{1}{2}\left(\tanh{nx}+1 \right)=u_n(x)\]
When $n\to\infty$ and $x<0$, $u_n(x)=\frac{1}{2}(-1+1)=0$; when $n\to\infty$ and $x>0$, $u_n(x)=\frac{1}{2}(1+1)=1$.

\end{document}

Mathematical Methods for Physicists/Chapter 01/main.tex


% background of problem solved
% existing solutions
% reading and research
% !!!Project requirement
\section{Background}

\subsection{Brief Introduction to Population Protocols \label{background} \cite{AspnesR2007, MCS11}}
\par\noindent
Population protocols are theoretical models for distributed computation \cite{AspnesR2007, MCS11}.
The model contains a collection of indistinguishable agents.
They (i.e. the agents) carry out computation tasks through directly pair-wised interactions.
The interaction pattern of agents is unpredictable from perspective of agents themselves
and is controlled through an adversary scheduler with fairness constraints \cite{AspnesR2007, MCS11}.
\paragraph{Formal Definition \cite{AspnesR2007}}
A protocol can be formally defined as:
\begin{itemize}
  \item $Q$, a finite set of passible states for an agent,
  \item $\Sigma$, a finite set of input alphabet,
  \item $Y$, a finite set of output range,
  \item $\iota = \Sigma \to Q $, is an input map from $\sum$ to $Q$, hence $\iota(\sigma)$ represents the initial state whose input is $\sigma \in \Sigma$
  \item $\omega = Q \to Y $, is an output map from $Q$ to $Y$, and
  \item $\delta \subseteq Q^{4}$, a transition relation describes how pairs of agents can interact.
\end{itemize}

\par\noindent
A \textit{configuration} for a population is a vector of all the agents' states.
Because agents with a same state are indistinguishable with each other, each configuration
could also an unordered multiset of states. It can be represented as $C$ \cite{AspnesR2007, MCS11}.

\par \label{IntroToPPFairScheduler} \noindent
At any point of the discrete time, the interaction is unpredictable from the perspective of the agents
in the population and the population itself. The interactions at any time are decided
by a adversary scheduler necessarily enforced with \textit{fairness} condition \cite{AspnesR2007, MCS11}.
The fairness condition means that the scheduler cannot avoid a possible step forever.
Formally, it means if a infinitely often configuration $C$ and $C \to C^{'}$,
then $C^{'}$ must also appear infinitely of in the execution \cite{AspnesR2007}.

\begin{figure}[H]
\begin{center}
\begin{tikzpicture}
    [L0Node/.style={circle,   draw=black, thick, minimum size=7mm},
    L1Node/.style={circle,   draw=black, fill=red, very thick, minimum size=7mm}]
     \node[L0Node] (n0) at (0, 2){$q_1$};
     \node[L0Node] (n1) at (3, 2){$q_2$};
     \node[L1Node] (n2) at (1.2, 1){$q_1$};
     \node[L1Node] (n3) at (2.0, 1){$q_2$};
     \node[L1Node] (n4) at (1.2, 0){$q'_{1}$};
     \node[L1Node] (n5) at (2.1, 0){$q'_{2}$};
     \node[L0Node] (n6) at (0, -1){$q'_{1}$};
     \node[L0Node] (n7) at (3, -1){$q'_{2}$};
     \draw[->] (0.5,2) -- (1.0, 2);
     \draw[<-] (2,2) --  (2.5,2);
     \draw[<-] (0.5,-1) -- (1.0, -1);
     \draw[->] (2,-1) --  (2.5,-1);
     \draw[->] (-1.5,3) -- (-1.5, -2);
     \draw[|-|] (0.5,-0.5) -- (0.5,1.5);
     \node (TimeLabel) at (-2.2, 3){Time};
     \node (ApproachingLabel) at (1.5, 2.3){Approaching};
     \node (SeparatingLabel) at (1.5, -1.3){Separating};
     \node[rotate=-90]  (InteractingLabel) at (0.2, 0.5){Interacting};
\end{tikzpicture}
\end{center}
\caption{A typical (simple) interaction in population protocol}
\end{figure}

\par\noindent
The current implementation of this work assumes a more strict scheduler called random scheduler,
which resulting uniform random interactions (i.e. at each step, it presents
equally possibility for every pair of agents to interact.) Essentially, a random scheduler is a "fair" scheduler, but a "fair" scheduler is not necessarily a random scheduler.
The assumption actually increases the power of the model because it allows a leader agent detects the absence
of agents for a particular state after a long enough waiting \cite{AspnesR2007}. Note this is only for
simplifying the current implementation and possibly extends to other fair schedulers that is not a
random scheduler in the future.

\subsection{From Population Protocols to Network Constructor \cite{MS16a}}

\par\noindent
A variance of population protocol is called "network constructor" \cite{MS16a}.
It involves the extra elements do not existing in general population protocol called "edge", which is
the connection in between any two agents (or "processes") \cite{MS16a}. In general, the connection
is similar to the agents, on the characteristic that both of them have a finite number of states. For instance, if
a connection have $k + 1$ states,  state 0 may represent the connection does not exist and state $i \in \{1,2,3, ..., k\}$
show the strength for a particular connection.

\par\noindent
In the document and the currently implemented simulator, we solely consider the simplest
case containing only $on$ and $off$ two states for edges  \cite{MS16a}. A connection is said to be in
$on$ or $active$ state, if at any discrete time, the connection exists in between two
particular nodes; otherwise if the connection is stated as in $off$ or $inactive$ state  \cite{MS16a}.
At initial, all edge are in $off$ state, which means that there is no connection in a given
population at discrete time 0  \cite{MS16a}. The state for an edge may or may not change through an interaction
in between the two nodes that the edge currently connected or disconnected to.

\par\noindent
The network constructor also follows an adversary scheduler with "fairness" constraint. This is
exactly same as the paragraphs mentioned in the previous section \ref{IntroToPPFairScheduler}.

\paragraph{Formal Definition \cite{MS16a}}
Formally, a network constructor can be defined as:
\begin{itemize}
  \item $Q$, a finite set of passible states for an agent,
  \item $Q_{out}$, a finite set of output range,
  \item $q_{0} \in Q $, is initial state of node,
  \item $\delta: Q \times Q \times \{0,1\} \to Q \times Q \times \{0,1\}$, a transition function, where the $\{0,1\}$ is the states for edges with initial value 0.
\end{itemize}

\par\noindent
The main target of this model concentrates on network construction rather than
specific function computation, which is the task for general population protocol \cite{MS16a}. Notice that a transition can be either \textit{effective}
or \textit{ineffective}. Define $\delta(a, b, c) = (a^{'}, b^{'},c^{'})$ as a transition function (Here, $a, b$ are "node-state" whereas $c$ is state for edge.)
as it is in the formal definition, $\delta_{1}(a,b,c) = a^{'}$, $\delta_{2}(a,b,c) = b^{'}$ (representing two nodes states' change)
and $\delta_{3}(a,b,c) = c^{'}$ (representing edge state change), the transition $(a,b,c) \to (a^{'}, b^{'},c^{'})$ is called
effective if at least one $x \in \{a,b,c\} \not= x^{'} $; otherwise it is called ineffective \cite{MS16a}.

\par\noindent
Name the set of nodes (or "distributed processes" under this context) $V_{I}$ and the set of pairs of nodes as $E_{I}$.
A configuration $C$ is a mapping $ V_{I} \cup E_{I} \to Q \cup \{0,1\} $ determines the states of nodes and edges in the population at any discrete time.
The output of configuration $C$ is defined as the graph $G(C) = (V, E) $ where $V = \{u \in V_{I}: C(u) \in Q_{out}\}$
and  $E = \{uv: u, v \in V, u \not= v,$ and $C(uv) = 1\}$ \cite{MS16a}.

\subsection{Grid Terminating Network Constructor \cite{Mi17} \label{IntroToGrid}}

\par\noindent
Another paper \cite{Mi17} presents a different automata but very similar to network constructor. Each node in this
model has a fixed number of ports with it. In the 2-dimensional case, it will have 4 distinguished ports
$p_{y}$, $p_{x}$, $p_{-y}$ and $p_{-x}$, may simply donated as $u$, $r$, $d$ and $l$, respectively \cite{Mi17} .
The port, which neighbour with each other, are also perpendicular to each other, forming local axes. Hence,
$ u \perp r $, $ r \perp d $, $ d \perp l $, and  $ l \perp u $ \cite{Mi17} . The coordinates are only for local purposes and
do not necessarily represent the actual orientation of a node. A connection (or edge) can only be built through
pairs of ports, which is different from the previous model (network constructor).

\par\noindent
\begin{figure}[H]
\begin{center}
\begin{tikzpicture}
    \draw (2,0) -- (2,1);
    \draw (2,4) -- (2,3);
    \draw (0,2) -- (1,2);
    \draw (4,2) -- (3,2);
    \draw [red, ultra thick] (2,2) circle [radius=1];
    \node [below] at (2.7,1) {DOWN};
    \node [above] at (2.3,3) {UP};
    \node [left] at (1,2.3) {LEFT};
    \node [right] at (3,2.3) {RIGHT};
    \node [label] at (2,2) {$q_1$};
\end{tikzpicture}
\end{center}
\caption{Structure of a node in Grid Terminating Network Constructor model}
\end{figure}

\par\noindent
\paragraph{Formal Definition \cite{Mi17} }
Formally, a terminating grid network constructor in 2-D can be defined as:
\begin{itemize}
  \item $Q$, a finite set of passible states for an agent,
  \item $Q_{out}$, a finite set of output range,
  \item $q_{0} \in Q $, is initial state of node
  \item $\delta: (Q \times P ) \times (Q \times P) \times \{0,1\} \to Q \times Q \times \{0,1\}$, a transition function, where the $\{0,1\}$ is the states for edges with initial value 0.
  \item When required, there will be also a special initial leader-state $L_{0} \in Q $ defined.
\end{itemize}

\par\noindent
A transition can be either \textit{effective}
or \textit{ineffective}. Define $\delta((a, p_{1}), (b, p_{2}), c) = (a^{'}, b^{'},c^{'})$ as a transition function
as it is in the formal definition, it is called effective if at least one $x \in \{a,b,c\} \not= x^{'} $; otherwise it is called ineffective \cite{Mi17}.

\par\noindent
Every configuration $C$ forms a set of shapes $G[A(C)]$, where a shape means that the network induced
by active edges of $C$ \cite{Mi17}. Given the geometrical restrictions (i.e. the connection are
made at unit distance and are perpendicular whenever they correspond to consecutive ports of a node),
not all possible $A(C)$ are valid \cite{Mi17}. $A(C)$ is valid if any connected component defined by it is a
subnetwork of 2D grid network with the unit distance. A valid $A(C)$ at time $t -1$ also restricts the
possible valid $A(C)$ at time $t + k$, where $k \in Integer$ and $k \geq 0 $ \cite{Mi17}.

\par\noindent
The paper \cite{Mi17} also defines a set of
shapes $G_{out}(C) = \{V_{s}, E_{s}\}$ as output of a configuration where $V_{s} = \{u \in V : C_{v}(u) \in Q_{out} \}$
and $E_{s} = A(C) \cap \{ (v_{1}, p_{1}) : v_{1} \not= v_{2} \in V_{s}; p_{1}, p_{2} \in P \}$ \cite{Mi17}.
Less formally, the output shapes of a configuration contains all nodes in output states and the active edges in between them.
This model was designed as terminating protocols so it assumes $Q_{out} \subseteq Q_{halt} \subseteq Q $.
All rules containing $q_{halt} \in Q_{halt} $ is ineffective \cite{Mi17}.

\subsection{Existing solution}
There is an existing simulator called NETCS \cite{DBLP:journals/corr/AmaxilatisLMS15} for network constructor, which is the model covered
in this paper \cite{MS16a}. The simulator was written in Java, providing an web user interface
and assisting related research.

\par\noindent
This work will explore the possibility to simulate a further variance of network constructor, grid network constructor, as well as attempting
to provide a uniform simulation to different models and protocols, which would be easily extensible.

\subsection{Vector transformation: handle coordinate rotations in 2-dimension}

\par\noindent
As mentioned in the previous section \ref{IntroToGrid}, grid terminating network constructor enforces perpendicular ports
and geometrical restrictions. This means that handling rotation in some cases becomes necessary.
This section will cover some basic but related vector mathematics. The detailed algorithms will be discussed later on, in the section (\ref{design}).

\subsubsection{2D centred coordinate rotation, with origin point as the centre}

\par\noindent

\begin{figure}[H]
\begin{center}
\includegraphics[width=0.5\textwidth]{context/diagram/2d_vector.pdf}
\caption{Vector $\vec{r}$ and $\vec{r_{'}}$ in unit circle}

\label{vectorG}
\end{center}
\end{figure}

\par\noindent
The figure \ref{vectorG} has two same-length vectors,  $\vec{r}$ (or $\vec{AB}$) and $\vec{r_{'}}$ (or $\vec{AB_{'}}$) in the Cartesian coordinate and their destination point located at the same unit circle.
The point $A$ is the origin point with coordinate $(0, 0)$. Suppose it has already known that the coordinate of $B$ is
$(x,y)$, and the $\theta$ angle. The question is that what the coordinate of $B^{'} $ (representing in $(x^{'},y^{'})$) is, after the first vector $\vec{r}$ rotating the given angle $\theta$ and becoming $\vec{r_{'}}$.
Note that, the "positive" rotation direction in current context and the implementation of the simulator is defined as "clock-wised".

\par\noindent
To solve this, the following equation can be concluded:

\begin{equation} \label{Equ_ori}
  \begin{bmatrix}
   x^{'} \\ y^{'}
   \end{bmatrix} =   \begin{bmatrix}
      \cos\theta & \sin\theta \\
      -\sin\theta & \cos\theta
    \end{bmatrix} \begin{bmatrix}
      x \\ y
     \end{bmatrix}
\end{equation}

\par\noindent
A brief derivation can be found in appendix below and it also can be found in \cite{Mitnote09} with a more precise and general proof.

\subsubsection{2D centred coordinate rotation, with any points as the centre}
Given the equation (\ref{Equ_ori}), it can be easily
deduced the fact that the rotation equation for any centred points $c$ with coordinate $(c_{x}, c_{y})$ can be achieved through
panning $c$ to origin point with coordinate $(0, 0)$, carry out the rotation and panning back to its original coordinate $(c_{x}, c_{y})$.
Suppose the target point that is required to be rotated is called $p$ (with coordinate $(x, y)$), it then has :
\begin{equation} \label{Equ_anycen}
  \begin{bmatrix}
   x^{'} \\ y^{'}
   \end{bmatrix} =   \begin{bmatrix}
      \cos\theta & \sin\theta \\
      -\sin\theta & \cos\theta
    \end{bmatrix} \left(\begin{bmatrix}
      x \\ y
     \end{bmatrix} - \begin{bmatrix}
       c_{x} \\ c_{y}
     \end{bmatrix}\right) + \begin{bmatrix}
        c_{x} \\ c_{y}
       \end{bmatrix}
\end{equation}
$p_{'}$ (with coordinate $(x_{'}, y_{'})$) will be point after $p$ rotating centred on $c$.
\subsubsection{Affine transformation form}
After a series of transformation, the equation \ref{Equ_anycen} becomes the following form:

\begin{equation} \label{Equ_aff}
  \begin{bmatrix}
   x^{'} \\ y^{'}
   \end{bmatrix}  = \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
+ \begin{bmatrix} c_{x}(1 - \cos\theta) - c_{y}\sin\theta \\ c_{y}(1 - \cos\theta) + c_{x}\sin\theta \end{bmatrix}
\end{equation}

\par\noindent
Let $ \textbf{M} = \begin{bmatrix} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{bmatrix} $
and $ \textbf{B} = \begin{bmatrix} c_{x}(1 - \cos\theta) - c_{y}\sin\theta \\ c_{y}(1 - \cos\theta) + c_{x}\sin\theta \end{bmatrix}$, then $ \begin{bmatrix} x^{'} \\ y^{'} \end{bmatrix}  = \textbf{M} \begin{bmatrix} x \\ y \end{bmatrix} + \textbf{B}$,
where it forms an \textit{affine transformation} \cite{WolframAT}. \textbf{M} and \textbf{B} can be calculated directly after knowing the rotation centre $(c_{x}, c_{y})$ and the
rotation agle $\theta$, and therefore the calculated \textbf{M} and  \textbf{B} can be applied for multiple target coordinates (those coordinates required to be rotated). This simplifies the calculation for a large batch of centred rotation with multiple target coordinates.

% \section {Data required} see website
% \section {Realisation \label{Realisation}} each stage & component; discuss problem encountered problem and solutions; testing (for each component); snapshot
% \section {Experiment  (optional)} propose; design of exp. ; exp. settings; discussion of results; chart and explain for chart
% \section {Evaluation} successful or not; how evaluate; who evaluate the project; strength and weakness of the project
% \section {Learning Points} [at least one page], story
% \section {Professional issues}  [at least one page] British Computer Society related to the project: Code of practice; Code of conduct
% \section Bio
% \section{Appendix} details of test data; (optional)more screen shot of sample; use guide; full design diagram
% zip of project


\section{Undesirable priors imposed on SFR} \label{sec:sfr_priors}
The input chain are samples drawn from the inferred posteriors for our
parameters: M*, b1, b2, b3, b4, g1, g2, etc. Regardless of whether we
use a Dirichlet or Uniform priors for b1, b2, b3, b4 (the SFH basis
coefficients), we impose an undesirable prior on SSFR. We correct for
this using importance weighting with weights derived from maximum
entropy prior correction of Handley & Millea (2019).


\subsection{Crypto Functions}
The first thing that we define is the crypto functions that will be needed to make the cryptocurrency.
Messages can be defined in multiple ways, one array of bytes, one string or a natural number.
Messages in this context means some data.

A private key is a number, a secret that someone has.
In Bitcoin, the private key is a 256-bit number.
A private key is used to signed messages.

The public key is generated from a private key.
But getting the private key from a public key is difficult.
To verify who signed a message with a private key, he has to show the public key.

Hash is an injection function (the probability of two functions having the same hash is very low).
The function is used from a big domain to a small domain.
For example, a hash of the big file (some GBs) is an integer of just some bytes.
It is very useful to prove for example that 2 files are equal.
If the hash of two files are equal, the probability of these files being equal is high.
It is used in torrents clients, so it is safe to download a program to untrusted peers,
just have to verify if the hash of the file is equal to the hash of the file wanted.

These functions can be defined, but it is not the purpose of this thesis.
So they will be just postulates.

\agda{Crypto}{cryptoPostulates}


\chapter{Abstract}

Balancing the workload of an assembly line
leads to a decision problem where the aim is to
assign a set of tasks to a sequence of work stations,
whilst optimising a measure of performance, \eg maximising the production
rate.
The SetUp Assembly Line Balancing and Scheduling Problem (\sua{})
is a recent variant on the classical Assembly Line Balancing Problem (\albp{}).
This new problem introduces sequence-dependent
setup times between any pair of consecutive tasks
processed within a work station's task sequence.
Considering these setup times leads an additional layer
of complexity as the problem now involves a set
of scheduling decisions for each station along the production line.

Benders decomposition naturally suggests itself as an appropriate
approach for the \sua{} as we can divide the problem's decisions
into two distinct sets.
We propose a general logic-based Benders decomposition framework which
leads to the assignment portion being decided by a relaxed
master problem and a number of sub-problems which together
handle the scheduling portion.
Each sub-problem is highly combinatorial in nature and so
we consider state-of-the-art solving technology from
both Operations Research and Artificial Intelligence
to solve the scheduling problem efficiently.
% We provide a detailed experimental analysis into the superior
% sub-problem formulation
A range of Benders cuts are devised
and their practical effectiveness
is one of our primary contributions to the
literature.

We test the best-known exact methods to solve
the \sua{} and use these models
as a benchmark against which to scrutinise our hybrid solution methodology.
In total, 396 instances of the problem were tested and our Benders
decomposition approach vastly outperformed the best models from the literature.
Due to this variant of the \albp{} being notably under-studied,
we conclude the paper by remarking on a range of possible future directions
which the research community could investigate.


\documentclass{templates/paper}
\usepackage{xcolor} \pagecolor[rgb]{0.1,0.1,0.1} \color[rgb]{1,1,1}
\definecolor{invertedblue}{rgb}{0.85, 0.85, 0}
\hypersetup{
    colorlinks=true,
    linkcolor=white,
    urlcolor=invertedblue,
    citecolor=white
}

\title{Sample Paper}
\author{Christoffer Aakre}

\newcommand{\dx}{\mathop{dx}}
\begin{document}

\section*{\centering Standard integrals}
\begin{align*}
    &\int x^n \; \dx = \frac{x^{n + 1}}{n + 1} + C \text{ if $n \neq -1$, reverse power rule} \\
    &\int \frac{\dx}{x} = \ln \lvert x \rvert + C \\
    &\int \sin x \; \dx = -\cos x + C \\
    &\int \cos x \; \dx = \sin x + C \\
    &\int \tan x \; \dx = \ln \lvert \sec x \rvert + C \\
    &\int \sec^2 x \; \dx = \tan x + C \\
    &\int \sec x \tan x \; \dx = \sec x + C \\
    &\int e^x \; dx = e^x + C \\
\end{align*}
\end{document}


\section{Dependent type theory}
\label{ch:dtt}

Type theory is a system of inference rules that can be combined to make \emph{derivations}. In these derivations, the goal is often to construct a term of a certain type. Such a term can be a function if the type of the constructed term is a function type; a proof of a property if the type of the constructed term is a proposition; an identification if the type of the constructed term is an identity type, and so on. In some respect, a type is just a collection of mathematical objects and constructing terms of a type is the everyday mathematical task or challenge. The system of inference rules that we call type theory offers a principled way of engaging in mathematical activity.

\subsection{Judgments and contexts in type theory}\label{sec:judgments}

An \define{inference rule} is an expression of the form
\begin{prooftree}
  \AxiomC{$\mathcal{H}_1$\quad $\mathcal{H}_2$ \quad \dots \quad $\mathcal{H}_n$}
  \UnaryInfC{$\mathcal{C}$}
\end{prooftree}
containing above the horizontal line a finite list $\mathcal{H}_1$, $\mathcal{H}_2$, \dots, $\mathcal{H}_n$ of \emph{judgments} for the hypotheses, and below the horizontal line a single judgment $\mathcal{C}$ for the conclusion. A very simple example that we will encounter in \cref{ch:pi} when we introduce function types, is the inference rule
\begin{prooftree}
  \AxiomC{$\Gamma\vdash a:A$}
  \AxiomC{$\Gamma\vdash f:A\to B$}
  \BinaryInfC{$\Gamma\vdash f(a):B$}
\end{prooftree}
This rule asserts that in any context $\Gamma$ we may use a term $a:A$ and a function $f:A\to B$ to obtain a term $f(a):B$. Each of the expressions
\begin{align*}
  \Gamma & \vdash a :A \\
  \Gamma & \vdash f : A \to B \\
  \Gamma & \vdash f(a):B
\end{align*}
are examples of judgments. There are four kinds of judgments in type theory:
\begin{enumerate}
\item \emph{$A$ is a (well-formed) \define{type}\index{well-formed type}\index{type} in context $\Gamma$.}\index{judgment!type in context} The symbolic expression for this judgment is
  \begin{equation*}
    \Gamma\vdash A~\mathrm{type}
  \end{equation*}
\item \emph{$A$ and $B$ are \define{judgmentally equal types} in context $\Gamma$.}\index{judgment!equal types in context}\index{judgmental equality!of types} The symbolic expression for this judgment is
  \begin{equation*}
    \Gamma\vdash A \jdeq B~\mathrm{type}
  \end{equation*}
\item \emph{$a$ is a (well-formed) \define{term}\index{well-formed term}\index{term} of type $A$ in context $\Gamma$.}\index{judgment!term of a type in context} The symbolic expression for this judgment is
  \begin{equation*}
    \Gamma \vdash a:A
  \end{equation*}
\item \emph{$a$ and $b$ are \define{judgmentally equal terms} of type $A$ in context $\Gamma$.}\index{judgment!equal terms of a type in context}\index{judgmental equality!of terms} The symbolic expression for this judgment is
  \begin{equation*}
    \Gamma\vdash a\jdeq b:A
  \end{equation*}
\end{enumerate}
Thus we see that any judgment is of the form $\Gamma\vdash\mathcal{J}$, consisting of a context $\Gamma$ and an expression $\mathcal{J}$ asserting that $A$ is a type, that $A$ and $B$ are equal types, that $a$ is a term of type $A$, or that $a$ and $b$ are equal terms of type $A$. A \define{context}\index{context|textbf} is an expression of the form
\begin{equation}\label{eq:context}
x_1:A_1,~x_2:A_2(x_1),~\ldots,~x_n:A_n(x_1,\ldots,x_{n-1})
\end{equation}
satisfying the condition that for each $1\leq k\leq n$ we can derive, using the inference rules of type theory, that
\begin{equation}\label{eq:context-condition}
  x_1:A_1,~x_2:A_2(x_1),~\ldots,~x_{k-1}:A_{k-1}(x_1,\ldots,x_{k-2})\vdash A_k(x_1,\ldots,x_{k-1})~\mathrm{type}.
\end{equation}
In other words, to check that an expression of the form \cref{eq:context} is a context, one starts on the left and works their way to the right verifying that each variable $x_k$ is assigned a well-formed type. We say that a context as in \cref{eq:context} \define{declares the variables}\index{variable declaration} $x_1,\ldots,x_n$. We may use variable names other than $x_1,\ldots,x_n$, as long as no variable is declared more than once.

Note that the context of length $0$ satisfies the requirement in \cref{eq:context-condition} vacuously. This context is called the \define{empty context}\index{context!empty context|textbf}\index{empty context|textbf}. An expression of the form $x_1:A_1$ is a context if and only if $A_1$ is a well-formed type in the empty context. Such types are called \define{closed types}\index{closed type|textbf}. We will soon encounter the type $\N$ of natural numbers, which is an example of a closed type. There is also the notion of \define{closed term}\index{closed term|textbf}, which is simply a term in the empty context. The next case is that an expression of the form $x_1:A_1,~x_2:A_2(x_1)$ is a context if and only if $A_1$ is a well-formed type in the empty context, and $A_2(x_1)$ is a well-formed type in context $x_1:A_1$, and so on.

It is a feature of \emph{dependent} type theory that all judgments are context-dependent, and indeed that even the types of the variables may depend on any previously declared variables. For example, when we introduce the \emph{identity type} in \cref{chap:identity}, we make full use of the machinery of dependent types, as is clear from how they are introduced:
\begin{prooftree}
  \AxiomC{$\Gamma\vdash A~\mathrm{type}$}
  \UnaryInfC{$\Gamma,x:A,y:A\vdash x=y~\mathrm{type}$}
\end{prooftree}
This rule asserts that given a type $A$ in context $\Gamma$, we may form a type $x=y$ in context $\Gamma,x:A,y:A$. Note that in order to know that the expression $\Gamma,x:A,y:A$ is indeed a well-formed context, we need to know that $A$ is a well-formed type in context $\Gamma,x:A$. This is an instance of \emph{weakening}, which we will describe shortly.

In the situation where we have
\begin{equation*}
  \Gamma,x:A\vdash B(x)~\mathrm{type},
\end{equation*}
we say that $B$ is a \define{family} of types over $A$ (or indexed by $A$) in context $\Gamma$. Similarly, in the situation where we have
\begin{equation*}
  \Gamma,x:A\vdash b(x):B(x),
\end{equation*}
we say that $b$ is a \define{section} of the family $B$ over $A$ in context $\Gamma$. Note that $A$, $B$, and $b$ also depend on the variables declared in the context $\Gamma$, even though we have not explicitly mentioned them. It is common practice to not mention every variable in the context $\Gamma$ in such situations.

\subsection{Inference rules}\label{sec:rules}

In this section we present the basic inference rules of dependent type theory. Those rules are valid to be used in any type theoretic derivation. There are only four sets of inference rules:
\begin{enumerate}
\item Rules for judgmental equality
\item Rules for substitution
\item Rules for weakening
\item The ``variable rule''
\end{enumerate}

\subsubsection*{Judgmental equality}

In this set of inference rules we ensure that judgmental equality (both on types and on terms) are equivalence relations, and we make sure that in any context $\Gamma$, we can change the type of any variable to a judgmentally equal type.

\begin{samepage}
The rules postulating that judgmental equality on types and on terms is an equivalence relation are as follows\index{judgmental equality!equivalence relation}:
\begin{center}
%\begin{small}
\begin{minipage}{.2\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\UnaryInfC{$\Gamma\vdash A\jdeq A~\textrm{type}$}
\end{prooftree}
\end{minipage}
\begin{minipage}{.25\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A\jdeq A'~\textrm{type}$}
\UnaryInfC{$\Gamma\vdash A'\jdeq A~\textrm{type}$}
\end{prooftree}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A\jdeq A'~\textrm{type}$}
\AxiomC{$\Gamma\vdash A'\jdeq A''~\textrm{type}$}
\BinaryInfC{$\Gamma\vdash A\jdeq A''~\textrm{type}$}
\end{prooftree}
\end{minipage}
\\*
\bigskip
\begin{minipage}{.2\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash a:A$}
\UnaryInfC{$\Gamma\vdash a\jdeq a : A$}
\end{prooftree}
\end{minipage}
\begin{minipage}{.25\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash a\jdeq a':A$}
\UnaryInfC{$\Gamma\vdash a'\jdeq a: A$}
\end{prooftree}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash a\jdeq a' : A$}
\AxiomC{$\Gamma\vdash a'\jdeq a'': A$}
\BinaryInfC{$\Gamma\vdash a\jdeq a'': A$}
\end{prooftree}
\end{minipage}
%\end{small}
\end{center}
\end{samepage}

\bigskip
Apart from the rules postulating that judgmental equality is an equivalence relation, there are also \define{variable conversion rules}\index{judgmental equality!conversion rules}\index{variable conversion rules}\index{conversion rule!variable}\index{rule!variable conversion}.
Informally, these are rules stating that if $A$ and $A'$ are judgmentally equal types in context $\Gamma$, then any valid judgment in context $\Gamma,x:A$ is also a valid judgment in context $\Gamma,x:A'$. In other words: we can convert the type of a variable to a judgmentally equal type.

The first variable conversion rule states that
\begin{prooftree}
\AxiomC{$\Gamma\vdash A\jdeq A'~\textrm{type}$}
\AxiomC{$\Gamma,x:A,\Delta\vdash B(x)~\mathrm{type}$}
\BinaryInfC{$\Gamma,x:A',\Delta\vdash B(x)~\mathrm{type}$}
\end{prooftree}
In this conversion rule, the context of the form $\Gamma,x:A,\Delta$ is just any extension of the context $\Gamma,x:A$.

Similarly, there are variable conversion rules for judgmental equality of types, for terms, and for judgmental equality of terms. To avoid having to state essentially the same rule four times, we state all four variable conversion rules at once using a \emph{generic judgment} $\mathcal{J}$, which can be any of the four kinds of judgments.
\begin{prooftree}
\AxiomC{$\Gamma\vdash A\jdeq A'~\textrm{type}$}
\AxiomC{$\Gamma,x:A,\Delta\vdash \mathcal{J}$}
\BinaryInfC{$\Gamma,x:A',\Delta\vdash \mathcal{J}$}
\end{prooftree}
An analogous \emph{term conversion rule}\index{term conversion rule}\index{conversion rule!term}\index{rule!term conversion}, stated in \cref{ex:term_conversion}, converting the type of a term to a judgmentally equal type, is derivable using the rules for substitution and weakening, and the variable rule.

\subsubsection*{Substitution}
If we are given a term $a:A$ in context $\Gamma$, then for any type $B$ in context $\Gamma,x:A,\Delta$ we can form the type $B[a/x]$ in context $\Gamma,\Delta[a/x]$, where $B[a/x]$ is an abbreviation for
\begin{equation*}
B(x_1,\ldots,x_{n-1},a(x_1,\ldots,x_{n-1}),x_{n+1},\ldots,x_{n+m-1})
\end{equation*}
This definition of substituting $a$ for $x$ is understood to be recursive over the length of $\Delta$. Similarly we obtain for any term $b:B$ in context $\Gamma,x:A,\Delta$ a term $b[a/x]:B[a/x]$. The \define{substitution rule}\index{substitution}\index{rule!substitution} asserts that substitution preserves well-formedness and judgmental equality of types and terms:
\begin{prooftree}
\AxiomC{$\Gamma\vdash a:A$}
\AxiomC{$\Gamma,x:A,\Delta\vdash \mathcal{J}$}
\RightLabel{$S_a$}
\BinaryInfC{$\Gamma,\Delta[a/x]\vdash \mathcal{J}[a/x]$}
\end{prooftree}
Furthermore, we postulate that substitution by judgmentally equal terms results in judgmentally equal types
\begin{prooftree}
\AxiomC{$\Gamma\vdash a\jdeq a':A$}
\AxiomC{$\Gamma,x:A,\Delta\vdash B~\mathrm{type}$}
\BinaryInfC{$\Gamma,\Delta[a/x]\vdash B[a/x]\jdeq B[a'/x]~\mathrm{type}$}
\end{prooftree}
and it also results in judgmentally equal terms
\begin{prooftree}
\AxiomC{$\Gamma\vdash a\jdeq a':A$}
\AxiomC{$\Gamma,x:A,\Delta\vdash b:B$}
\BinaryInfC{$\Gamma,\Delta[a/x]\vdash b[a/x]\jdeq b[a'/x]:B[a/x]$}
\end{prooftree}
When $B$ is a family of types over $A$ and $a:A$, we also say that $B[a/x]$ is the \define{fiber}\index{family!fiber of}\index{fiber!of a family} of $B$ at $a$. Often we write $B(a)$ for $B[a/x]$.

\subsubsection*{Weakening}
If we are given a type $A$ in context $\Gamma$, then any judgment made in a longer context $\Gamma,\Delta$ can also be made in the context $\Gamma,x:A,\Delta$, for a fresh variable $x$. The \define{weakening rule}\index{weakening}\index{rule!weakening} asserts that weakening by a type $A$ in context preserves well-formedness and judgmental equality of types and terms.
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\AxiomC{$\Gamma,\Delta\vdash \mathcal{J}$}
\RightLabel{$W_A$}
\BinaryInfC{$\Gamma,x:A,\Delta \vdash \mathcal{J}$}
\end{prooftree}
This process of expanding the context by a fresh variable of type $A$ is called \define{weakening (by $A$)}.

In the simplest situation where weakening applies, we have two types $A$ and $B$ in context $\Gamma$. Then we can weaken $B$ by $A$ as follows
\begin{prooftree}
  \AxiomC{$\Gamma\vdash A~\textrm{type}$}
  \AxiomC{$\Gamma\vdash B~\textrm{type}$}
  \RightLabel{$W_A$}
  \BinaryInfC{$\Gamma,x:A\vdash B~\mathrm{type}$}
\end{prooftree}
in order to form the type $B$ in context $\Gamma,x:A$. The type $B$ in context $\Gamma,x:A$ is called the \define{constant family}\index{family!constant family}\index{constant family} $B$, or the \define{trivial family}\index{family!trivial family}\index{trivial family} $B$.

\subsubsection*{The variable rule}
If we are given a type $A$ in context $\Gamma$, then we can weaken $A$ by itself to obtain that $A$ is a type in context $\Gamma,x:A$. The \define{variable rule}\index{variable rule}\index{rule!variable rule|textbf} now asserts that $x$ is a well-formed term of type $A$ in context $\Gamma,x:A$.
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\RightLabel{$\delta_A$}
\UnaryInfC{$\Gamma,x:A\vdash x:A$}
\end{prooftree}
One of the reasons for including the variable rule is that it provides an \emph{identity function}\index{identity function} on the type $A$ in context $\Gamma$.

\begin{comment}
\bigskip
\begin{minipage}{.45\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\AxiomC{$\Gamma,\Delta\vdash B~\textrm{type}$}
\RightLabel{$W_A$}
\BinaryInfC{$\Gamma,x:A,\Delta \vdash B~\textrm{type}$}
\end{prooftree}
\end{minipage}\hfill
\begin{minipage}{.45\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\AxiomC{$\Gamma,\Delta\vdash b:B$}
\RightLabel{$W_A$}
\BinaryInfC{$\Gamma,x:A,\Delta \vdash b:B$}
\end{prooftree}
\end{minipage}

\noindent
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\RightLabel{$\delta_A$}
\UnaryInfC{$\Gamma,x:A\vdash x:A$}
\end{prooftree}

\noindent
\begin{minipage}{.5\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash a:A$}
\AxiomC{$\Gamma,x:A,\Delta\vdash B~\textrm{type}$}
\RightLabel{$S_a$}
\BinaryInfC{$\Gamma,\Delta[a/x]\vdash B[a/x]~\textrm{type}$}
\end{prooftree}
\end{minipage}\hfill
\begin{minipage}{.5\textwidth}
\begin{prooftree}
\AxiomC{$\Gamma\vdash a:A$}
\AxiomC{$\Gamma,x:A,\Delta\vdash b:B$}
\RightLabel{$S_a$}
\BinaryInfC{$\Gamma,\Delta[a/x]\vdash b[a/x] : B[a/x]$}
\end{prooftree}
\end{minipage}

\bigskip
\end{comment}

\subsection{Derivations}\label{sec:derivations}

A derivation in type theory is a tree in which each node is a valid rule of inference. We give two examples of derivations: a derivation showing that any variable can be changed to a fresh one, and a derivation showing that any two variables that do not depend on one another can be swapped in order.

Thus, we will see some examples of new inference rules that can be derived using the rules of type theory. Such inference rules are called \define{admissible}. Since derivations tend to get long and unwieldy, we declare that admissible inference rules are also valid to be used in derivations.

\subsubsection*{Changing variables}

Variables can always be changed to fresh variables. We show that this is the case by showing that the inference rule
\begin{prooftree}
  \AxiomC{$\Gamma,x:A,\Delta\vdash \mathcal{J}$}
  \RightLabel{$x'/x$}
  \UnaryInfC{$\Gamma,x':A,\Delta[x'/x]\vdash \mathcal{J}[x'/x]$}
\end{prooftree}
is admissible, where $x'$ is a variable that does not occur in the context $\Gamma,x:A,\Delta$.

Indeed, we have the following derivation using substitution, weakening, and the variable rule:
\begin{prooftree}
  \AxiomC{$\Gamma\vdash A~\mathrm{type}$}
  \RightLabel{$\delta_A$}
  \UnaryInfC{$\Gamma,x':A\vdash x':A$}
  \AxiomC{$\Gamma\vdash A~\mathrm{type}$}
  \AxiomC{$\Gamma,x:A,\Delta\vdash \mathcal{J}$}
  \RightLabel{$W_A$}
  \BinaryInfC{$\Gamma,x':A,x:A,\Delta\vdash \mathcal{J}$}
  \RightLabel{$S_{x'}$}
  \BinaryInfC{$\Gamma,x':A,\Delta[x'/x]\vdash \mathcal{J}[x'/x]$}
\end{prooftree}
In this derivation it is the application of the weakening rule where we have to check that $x'$ does not occur in the context $\Gamma,x:A,\Delta$.

\subsubsection*{Interchanging variables}

The \define{interchange rule}\index{rule!interchange}\index{interchange rule} states that if we have two types $A$ and $B$ in context $\Gamma$, and we make a judgment in context $\Gamma,x:A,y:B,\Delta$, then we can make that same judgment in context $\Gamma,y:B,x:A,\Delta$ where the order of $x:A$ and $y:B$ is swapped. More formally, the interchange rule is the following inference rule
\begin{prooftree}
\AxiomC{$\Gamma\vdash B~\textrm{type}$}
\AxiomC{$\Gamma,x:A,y:B,\Delta\vdash \mathcal{J}$}
\BinaryInfC{$\Gamma,y:B,x:A,\Delta\vdash \mathcal{J}$}
\end{prooftree}
Just as the rule for changing variables, we claim that the interchange rule is an admissible rule.

The idea of the derivation for the interchange rule is as follows: If we have a judgment
\begin{equation*}
  \Gamma,x:A,y:B,\Delta\vdash\mathcal{J},
\end{equation*}
then we can change the variable $y$ to a fresh variable $y'$ and weaken the judgment to obtain the judgment
\begin{equation*}
  \Gamma,y:B,x:A,y':B,\Delta[y'/y]\vdash\mathcal{J}[y'/y].
\end{equation*}
Now we can substitute $y$ for $y'$ to obtain the desired judgment $\Gamma,y:B,x:A,\Delta\vdash\mathcal{J}$. The formal derivation is as follows:
%\begin{small}
\begin{prooftree}
\AxiomC{$\Gamma\vdash B~\textrm{type}$}
\RightLabel{$\delta_B$}
\UnaryInfC{$\Gamma,y:B\vdash y:B$}
\RightLabel{$W_{W_B(A)}$}
\UnaryInfC{$\Gamma,y:B,x:A\vdash y:B$}
\AxiomC{$\Gamma,x:A,y:B,\Delta\vdash \mathcal{J}$}
\RightLabel{$y'/y$}
\UnaryInfC{$\Gamma,x:A,y':B,\Delta[y'/y]\vdash \mathcal{J}[y'/y]$}
\RightLabel{$W_B$}
\UnaryInfC{$\Gamma,y:B,x:A,y':B,\Delta[y'/y]\vdash \mathcal{J}[y'/y]$}
\RightLabel{$S_{W_A(y)}$}
\BinaryInfC{$\Gamma,y:B,x:A,\Delta\vdash \mathcal{J}$}
\end{prooftree}
%\end{small}

\begin{comment}
For $A\in T_n$ we define $T_{n+k+1}(A):= \{B\in T_{n+k}\mid \mathrm{ft}^{k+1}(B)=A\}$. Similarly we define $\tilde{T}_{n+k+1}(A):=\{b\in\tilde{T}_{n+k+1}\mid\mathrm{ft}^{k+1}(\partial(b))=A\}$. For any closed type $A$ we maintain the convention that $T_{k}(\mathrm{ft}(A)):= T_k$.
\begin{enumerate}
\item For all $A\in T_n$, and all $k\in\N$, \define{weakening} operations
\begin{align*}
W_A & : T_{n+k}(\mathrm{ft}(A)) \to T_{n+k+1}(A) \\
\tilde{W}_A & : \tilde{T}_{n+k}(\mathrm{ft}(A))\to \tilde{T}_{n+k+1}(A)
\end{align*}
subject to the conditions $\mathrm{ft}(W_A(B))=W_A(\mathrm{ft}(B))$ if $B\in T_{n+k}$ with $k\geq 1$, and $\partial(\tilde{W}_A(b))=W_A(\partial(b))$.
\item For all $A\in T_n$ a term $\delta_A\in \tilde{T}_{n+1}$ satisfying $\partial(\delta_A)=W_A(A)$.
\item For all $a\in \tilde{T}_n$ satisfying $\partial(a)=A$, and all $k\in\N$, \define{substitution} operations
\begin{align*}
S_a & : \{B\in T_{n+k+1}\mid \mathrm{ft}^{k+1}(B)= A\}\to T_k \\
\tilde{S}_a & : \{b\in \tilde{T}_{n+k+1}\mid \mathrm{ft}^{k+1}(\partial(b))=A\}\to \tilde{T}_{n+k}
\end{align*}
subject to the conditions $\mathrm{ft}(S_a(B))=\mathrm{ft}(A)$ if $B\in T_{n+1}$, $\mathrm{ft}(S_a(B))=S_a(\mathrm{ft}(B))$ if $B\in T_{n+k+1}$ with $k\geq 1$, and $\partial(\tilde{S}_a(b))=S_a(\partial(b))$.
\end{enumerate}
\end{comment}

%\subsection{Axioms for weakening, substitution, and the diagonal}
\begin{comment}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
  \AxiomC{$\Gamma,x:A,\Delta\vdash B~\textrm{type}$}
    \AxiomC{$\Gamma,x:A,\Delta,y:B,E\vdash C~\textrm{type}$}
\TrinaryInfC{$\Gamma,\Delta[a/x],E[b/y][a/x]\vdash C[b/y][a/x]\jdeq C[a/x][b[a/x]/y']~\textrm{type}$}
\end{prooftree}
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
  \AxiomC{$\Gamma,x:A,\Delta\vdash B~\textrm{type}$}
    \AxiomC{$\Gamma,x:A,\Delta,y:B,E\vdash c:C$}
\TrinaryInfC{$\Gamma,\Delta[a/x],E[b/y][a/x]\vdash c[b/y][a/x]\jdeq c[a/x][b[a/x]/y']:C[b/y][a/x]$}
\end{prooftree}
\begin{prooftree}
\AxiomC{$\Gamma\vdash a:A$}
  \AxiomC{$\Gamma,\Delta\vdash B~\textrm{type}$}
\RightLabel{($x$ not free in $B$)}
\BinaryInfC{$\Gamma,\Delta\vdash B[a/x]\jdeq B~\textrm{type}$}
\end{prooftree}
\end{comment}

\begin{comment}
\subsection{An algebraic presentation of dependent type theory}

%Let us write $T_n$ for the set of well-formed contexts of length $n$, for $n>1$. Then any well-formed context of length $n+1$ is of the form $\Gamma,x:A$, where $\Gamma$ is a well-formed context of length $n$. Thus we see that there are maps $\eft:T_{n+1}\to T_n$ for $n>1$. Similarly, if we write $\tilde{T}_n$ for the set of all terms of a type in a context of length $n-1$, we see that there is a map $\tilde{T}_n\to T_n$. The following picture emerges:
%\begin{equation*}
%\begin{tikzcd}
%\tilde{T}_3 \arrow[dr,"\partial"] & \vdots \arrow[d,"\mathrm{ft}"] \\
%\tilde{T}_2 \arrow[dr,"\partial"] & T_3 \arrow[d,"\mathrm{ft}"] \\
%\tilde{T}_1 \arrow[dr,"\partial"] & T_2 \arrow[d,"\mathrm{ft}"] \\
%& T_1
%\end{tikzcd}
%\end{equation*}

Observe that given a type $A$ in context $\Gamma$ and a type $B$ in context $\Gamma,\Delta$ we can weaken twice by first weakening by $B$ and then by $A$, as indicated in the following derivation:
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
\AxiomC{$\Gamma,\Delta\vdash B~\textrm{type}$}
  \AxiomC{$\Gamma,\Delta,\mathrm{E}\vdash \mathcal{J}$}
\BinaryInfC{$\Gamma,\Delta,y:B,\mathrm{E}\vdash \mathcal{J}$}
\BinaryInfC{$\Gamma,x:A,\Delta,y:B,\mathrm{E}\vdash \mathcal{J}$}
\end{prooftree}
However, we can also first weaken by $A$, and then by `$B$ weakened by $A$', as indicated in the following derivation:
\begin{prooftree}
\AxiomC{$\Gamma\vdash A~\textrm{type}$}
  \AxiomC{$\Gamma,\Delta\vdash B~\textrm{type}$}
\BinaryInfC{$\Gamma,x:A,\Delta\vdash B~\textrm{type}$}
  \AxiomC{$\Gamma\vdash A~\textrm{type}$}
    \AxiomC{$\Gamma,\Delta,\mathrm{E}\vdash \mathcal{J}$}
  \BinaryInfC{$\Gamma,x:A,\Delta,\mathrm{E}\vdash \mathcal{J}$}
\BinaryInfC{$\Gamma,x:A,\Delta,y:B,\mathrm{E}\vdash \mathcal{J}$}
\end{prooftree}
For the end result it does not matter in what order the two weakenings are performed. We can express this conveniently as an equation:
\begin{equation*}
W_A(W_B(\mathcal{J}))\jdeq W_{W_A(B)}(W_A(\mathcal{J})).
\end{equation*}
The complete list of rules (in alphabetic order) is
\begin{align*}
S_a(\delta_B) & \jdeq \delta_{S_a(B)} \\
S_a(\delta_A) & \jdeq a \\
S_a(S_b(\mathcal{J})) & \jdeq S_{S_a(b)}(S_a(\mathcal{J})) \\
S_a(W_A(\mathcal{J})) & \jdeq \mathcal{J} \\
S_a(W_B(\mathcal{J})) & \jdeq W_{S_a(B)}(S_a(\mathcal{J})) \\
S_{\delta_A}(W_{W_A}(\mathcal{J})) & \jdeq \mathcal{J} \\
W_A(\delta_B) & \jdeq \delta_{W_A(B)} \\
W_A(S_b(\mathcal{J})) & \jdeq S_{W_A(b)}(W_A(\mathcal{J})) \\
W_A(W_B(\mathcal{J})) & \jdeq W_{W_A(B)}(W_A(\mathcal{J}))
\end{align*}
Here $A$ is a type in context $\Gamma$ and $a$ is a term of type $A$, $B$ is a type in context $\Gamma,x:A,\Delta$ and $b$ is a term of type $B$.
\end{comment}

%\begin{rmk}
%To avoid overly long proof trees maintain as a convention that every derivation with hypotheses $\mathcal{H}_1,\ldots,\mathcal{H}_n$ and conclusion $\mathcal{C}$ can be used as a rule
%\begin{prooftree}
%\AxiomC{$\mathcal{H}_1$}
%\AxiomC{$\cdots$}
%\AxiomC{$\mathcal{H}_n$}
%\TrinaryInfC{$\mathcal{C}$}
%\end{prooftree}
%in later derivations.
%\end{rmk}

\begin{exercises}
\item \label{ex:term_conversion}Give a derivation for the following conversion rule\index{term conversion rule}\index{term conversion rule}\index{rule!term conversion}\index{term conversion rule}\index{conversion rule!term}:
\begin{prooftree}
\AxiomC{$\Gamma\vdash A\jdeq A'~\textrm{type}$}
\AxiomC{$\Gamma\vdash a:A$}
\BinaryInfC{$\Gamma\vdash a:A'$}
\end{prooftree}
\item Consider a type $A$ in context $\Gamma$. In this exercise we establish a connection between types in context $\Gamma,x:A$, and uniform choices of types $B_a$, where $a$ ranges over terms of $A$ in a uniform way. A similar connection is made for terms.
  \begin{subexenum}
  \item We define a \define{uniform family} over $A$ to consist of a type
    \begin{equation*}
      \Delta,\Gamma\vdash B_a~\mathrm{type}
    \end{equation*}
    for every context $\Delta$, and every term $\Delta,\Gamma\vdash a:A$, subject to the condition that one can derive
    \begin{prooftree}
      \AxiomC{$\Delta\vdash d:D$}
      \AxiomC{$\Delta,y:D,\Gamma\vdash a:A$}
      \BinaryInfC{$\Delta,\Gamma\vdash B_a[d/y]\jdeq B_{a[d/y]}~\mathrm{type}$}
    \end{prooftree}
    Define a bijection between types in context $\Gamma,x:A$ and uniform families over $A$.
  \item Consider a type $\Gamma,x:A\vdash B$. We define a \define{uniform term} of $B$ over $A$ to consist of a type
    \begin{equation*}
      \Delta,\Gamma\vdash b_a:B[a/x]~\mathrm{type}
    \end{equation*}
    for every context $\Delta$, and every term $\Delta,\Gamma\vdash a:A$, subject to the condition that one can derive
    \begin{prooftree}
      \AxiomC{$\Delta\vdash d:D$}
      \AxiomC{$\Delta,y:D,\Gamma\vdash a:A$}
      \BinaryInfC{$\Delta,\Gamma\vdash b_a[d/y]\jdeq b_{a[d/y]}:B[a/x][d/y]$}
    \end{prooftree}
    Define a bijection between terms of $B$ in context $\Gamma,x:A$ and uniform terms of $B$ over $A$.
  \end{subexenum}
\end{exercises}