\chapter{angular momentum solutions}
\begin{abox}
	Practice set 1 solutions
	\end{abox}
\begin{enumerate}
	\begin{minipage}{\textwidth}
		\item The Hamiltonian of an electron in a constant magnetic field $\vec{B}$ is given by $H=\mu \vec{\sigma} \cdot \vec{B}$. where $\mu$ is a positive constant and $\vec{\sigma}=\left(\sigma_{1}, \sigma_{2}, \sigma_{3}\right)$ denotes the Pauli matrices. Let $\omega=\mu B / \hbar$ and $I$ be the $2 \times 2$ unit matrix. Then the operator $e^{i H t / \hbar}$ simplifies to
		\exyear{NET JUNE 2011}
	\end{minipage}
	\begin{tasks}(2)
		\task[\textbf{A.}] $I \cos \frac{\omega t}{2}+\frac{i \vec{\sigma} \cdot \vec{B}}{B} \sin \frac{\omega t}{2}$
		\task[\textbf{B.}]$I \cos \omega t+\frac{i \vec{\sigma} \cdot \vec{B}}{B} \sin \omega t$
		\task[\textbf{C.}]$I \sin \omega t+\frac{i \vec{\sigma} \cdot \vec{B}}{B} \cos \omega t$
		\task[\textbf{D.}]$I \sin 2 \omega t+\frac{i \vec{\sigma} \cdot \vec{B}}{B} \cos 2 \omega t$
	\end{tasks}
\begin{answer}
	$H=\mu \vec{\sigma} \vec{B}$ where $\vec{\sigma}=\left(\sigma_{1}, \sigma_{2}, \sigma_{3}\right)$ are pauli spin matrices and $\vec{B}$ are constant magnetic field. $\vec{\sigma}=\left(\sigma_{1} \hat{i}, \sigma_{2} \hat{j}, \sigma_{3} \hat{k}\right), \vec{B}=\left(B_{x} \hat{i}+B_{y} \hat{j}+B_{z} \hat{k}\right)$ and Hamiltonion $H=\mu \vec{\sigma} \cdot \vec{B}$ in matrices form is given by
	$$
	H=\mu\left(\begin{array}{cc}
	B_{z} & B_{x}-i B_{y} \\
	B_{x}+i B_{y} & -B_{z}
	\end{array}\right) .
	$$
	Eigenvalue of given matrices are given by $+\mu \mathrm{B}$ and $-\mu \mathrm{B} . H$ matrices are not diagonals so $e^{i H t / \hbar}$ is equivalent to
	$$
	S^{-1}\left(\begin{array}{cc}
	e^{\frac{i \mu B t}{\hbar}} & 0 \\
	0 & e^{\frac{-i \mu B t}{\hbar}}
	\end{array}\right) S
	$$
	where $S$ is unitary matrices\\
	and $\quad S^{-1}=S=\left(\begin{array}{cc}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}}\end{array}\right)$.\\
	$S^{-1}\left(\begin{array}{cc}e^{\frac{i \mu B t}{\hbar}} & 0 \\ 0 & e^{\frac{-i \mu B t}{\hbar}}\end{array}\right) S=\left(\begin{array}{cc}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}}\end{array}\right)\left(\begin{array}{cc}e^{\frac{i \mu B t}{\hbar}} & 0 \\ 0 & e^{\frac{-i \mu B t}{\hbar}}\end{array}\right)\left(\begin{array}{cc}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}}\end{array}\right)$,\\ where $\omega=\mu \mathrm{B} / \hbar$.\\
	$e^{i H t / \hbar}=\left(\begin{array}{cc}\cos \omega t & i \sin \omega t \\ i \sin \omega t & \cos \omega t\end{array}\right)$,\\
	 which is equivalent to $I \cos \omega t+i \sigma_{x} \sin \omega t$ can be written
	as $I \cos \omega t+\frac{i \vec{\sigma} \cdot \vec{B}}{B} \sin \omega t$, where $\sigma_{x}=\frac{i \vec{\sigma} \cdot B}{B}$\\
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item  In a system consisting of two spin $\frac{1}{2}$ particles labeled 1 and 2, let $\vec{S}^{(1)}=\frac{\hbar}{2} \vec{\sigma}^{(1)}$ and $\vec{S}^{(2)}=\frac{\hbar}{2} \vec{\sigma}^{(2)}$ denote the corresponding spin operators. Here $\vec{\sigma} \equiv\left(\sigma_{x}, \sigma_{y}, \sigma_{z}\right)$ and $\sigma_{x}, \sigma_{y}, \sigma_{z}$ are the three Pauli matrices.\\
	$\text { In the standard basis the matrices for the operators } S_{x}^{(1)} S_{y}^{(2)} \text { and } S_{y}^{(1)} S_{x}^{(2)} \text { are respectively, }$
	\exyear{NET JUNE 2011}
\end{minipage}
\begin{tasks}(1)
	\task[\textbf{A.}]$\frac{\hbar^{2}}{4}\left(\begin{array}{cc}
		1 & 0 \\
		0 & -1
	\end{array}\right), \frac{\hbar^{2}}{4}\left(\begin{array}{rr}
		-1 & 0 \\
		0 & 1
	\end{array}\right)$
	\task[\textbf{B.}]$\frac{\hbar^{2}}{4}\left(\begin{array}{cc}
		i & 0 \\
		0 & -i
	\end{array}\right), \frac{\hbar^{2}}{4}\left(\begin{array}{rr}
		-i & 0 \\
		0 & i
	\end{array}\right)$
	\task[\textbf{C.}]$\frac{\hbar^{2}}{4}\left(\begin{array}{cccc}
		0 & 0 & 0 & -i \\
		0 & 0 & i & 0 \\
		0 & -i & 0 & 0 \\
		i & 0 & 0 & 0
	\end{array}\right), \frac{\hbar^{2}}{4}\left(\begin{array}{cccc}
		0 & 0 & 0 & -i \\
		0 & 0 & -i & 0 \\
		0 & i & 0 & 0 \\
		i & 0 & 0 & 0
	\end{array}\right)$
	\task[\textbf{D.}]$\frac{\hbar^{2}}{4}\left(\begin{array}{cccc}
		0 & 1 & 0 & 0 \\
		1 & 0 & 0 & 0 \\
		0 & 0 & 0 & -i \\
		0 & 0 & i & 0
	\end{array}\right), \frac{\hbar^{2}}{4}\left(\begin{array}{cccc}
		0 & -i & 0 & 0 \\
		i & 0 & 0 & 0 \\
		0 & 0 & 0 & 1 \\
		0 & 0 & 1 & 0
	\end{array}\right)$
\end{tasks}
\begin{answer}
$\mathrm{S}_{\mathrm{x}}^{(1)} \mathrm{S}_{\mathrm{y}}^{(2)}=\frac{\hbar^{2}}{4}\left(\begin{array}{ll}
	0 & 1 \\
	1 & 0
\end{array}\right) \otimes\left(\begin{array}{cc}
	0 & -\mathrm{i} \\
	\mathrm{i} & 0
\end{array}\right) \Rightarrow \frac{\hbar^{2}}{4}\left(\begin{array}{cccc}
	0 & 0 & 0 & -\mathrm{i} \\
	0 & 0 & \mathrm{i} & 0 \\
	0 & -\mathrm{i} & 0 & 0 \\
	\mathrm{i} & 0 & 0 & 0
\end{array}\right)$\\
$S_{y}^{(1)} S_{x}^{(2)}=\frac{\hbar^{2}}{4}\left(\begin{array}{cc}
	0 & -i \\
	i & 0
\end{array}\right) \otimes\left(\begin{array}{cc}
	0 & 1 \\
	1 & 0
\end{array}\right) \Rightarrow \frac{\hbar^{2}}{4}\left(\begin{array}{cccc}
	0 & 0 & 0 & -i \\
	0 & 0 & -i & 0 \\
	0 & i & 0 & 0 \\
	i & 0 & 0 & 0
\end{array}\right)$	\\
The correct option is \textbf{c}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\text { These two operators of above QUESTION satisfy the relation }$
	\exyear{NET JUNE 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\left\{S_{x}^{(1)} S_{y}^{(2)}, S_{y}^{(1)} S_{x}^{(2)}\right\}=S_{z}^{(1)} S_{z}^{(2)}$
	\task[\textbf{B.}]$\left\{S_{x}^{(1)} S_{y}^{(2)}, S_{y}^{(1)} S_{x}^{(2)}\right\}=0$
	\task[\textbf{C.}]$\left[S_{x}^{(1)} S_{y}^{(2)}, S_{y}^{(1)} S_{x}^{(2)}\right]=i S_{z}^{(1)} S_{z}^{(2)}$
	\task[\textbf{D.}] $\left[S_{x}^{(1)} S_{y}^{(2)}, S_{y}^{(1)} S_{x}^{(2)}\right]=0$
\end{tasks}
\begin{answer}
 We have matrix $S_{x}^{(1)} S_{y}^{(2)}$ and $S_{y}^{(1)} S_{x}^{(2)}$ from question 6(A) so commutation is given by $\left[S_{x}^{(1)} S_{y}^{(2)}, S_{y}^{(1)} S_{x}^{(2)}\right]=0 .$\\
 The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The component along an arbitrary direction $\hat{n}$, with direction $\operatorname{cosines}\left(n_{x}, n_{y}, n_{z}\right)$, of the spin of a spin $-\frac{1}{2}$ particle is measured. The result is
	\exyear{NET JUNE 2012}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] 0
	\task[\textbf{B.}]$\pm \frac{\hbar}{2} n_{z}$
	\task[\textbf{C.}]$\pm \frac{\hbar}{2}\left(n_{x}+n_{y}+n_{z}\right)$
	\task[\textbf{D.}]$\pm \frac{\hbar}{2}$
\end{tasks}
\begin{answer}
	$S_{x}=\frac{\hbar}{2}\left(\begin{array}{ll}
		0 & 1 \\
		1 & 0
	\end{array}\right), S_{y}=\frac{\hbar}{2}\left(\begin{array}{ll}
		0 & -i \\
		i & 0
	\end{array}\right), S_{z}=\frac{\hbar}{2}\left(\begin{array}{ll}
		1 & 0 \\
		0 & -1
	\end{array}\right)$\\
	$\overrightarrow{\mathrm{n}}=\mathrm{n}_{\mathrm{x}} \hat{\mathrm{i}}+\mathrm{n}_{\mathrm{y}} \hat{\mathrm{j}}+\mathrm{n}_{\mathrm{z}} \hat{\mathrm{k}} \text { and } n_{x}^{2}+n_{y}^{2}+n_{z}^{2}=1, \vec{S}=S_{x} \hat{i}+S_{y} \hat{j}+S_{z} \hat{k}$\\
	$\vec{n} \cdot \vec{S}=n_{x}\left(\begin{array}{cc}
		0 & \frac{\hbar}{2} \\
		\frac{\hbar}{2}
	\end{array}\right)+n_{y}\left(\begin{array}{cc}
		0 & -\frac{i \hbar}{2} \\
		\frac{i \hbar}{2} & 0
	\end{array}\right)+n_{z}\left(\begin{array}{cc}
		\frac{\hbar}{2} & 0 \\
		0 & \frac{-\hbar}{2}
	\end{array}\right)$\\
	$\vec{n} \cdot \vec{S}=\left(\begin{array}{ll}
		n_{z} \frac{\hbar}{2} & \frac{\hbar}{2}\left(n_{x}-i n_{y}\right) \\
		\frac{\hbar}{2}\left(n_{x}+i n_{y}\right) & -n_{z} \frac{\hbar}{2}
	\end{array}\right)$\\
	Let $\lambda$ is eigen value of $\vec{n} \cdot \vec{S}$
	$$
	\left|\begin{array}{ll}
	n_{z} \frac{\hbar}{2}-\lambda & \frac{\hbar}{2}\left(n_{x}-i n_{y}\right. \\
	\frac{\hbar}{2}\left(n_{x}+i n_{y}\right) & -n_{z} \frac{\hbar}{2}-\lambda
	\end{array}\right|=0
	$$
	$\Rightarrow-\left(\frac{\mathrm{n}_{\mathrm{z}} \hbar}{2}-\lambda\right)\left(\frac{\mathrm{n}_{\mathrm{z}} \hbar}{2}+\lambda\right)-\frac{\hbar^{2}}{4}\left(\mathrm{n}_{\mathrm{x}}^{2}+\mathrm{n}_{\mathrm{y}}^{2}\right)=0 \Rightarrow-\left(\frac{n_{z}^{2} \hbar^{2}}{4}-\lambda^{2}\right)-\frac{\hbar^{2}}{4}\left(n_{x}^{2}+n_{y}^{2}\right)=0$\\
	$\Rightarrow-\frac{\hbar^{2}}{4}\left(n_{x}^{2}+n_{y}^{2}+n_{z}^{2}\right)+\lambda^{2}=0 \Rightarrow \lambda=\pm \frac{\hbar}{2}$\\
	The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item In a basis in which the $z$ - component $S_{z}$ of the spin is diagonal, an electron is in a spin state $\psi=\left(\begin{array}{c}(1+i) / \sqrt{6} \\ \sqrt{2 / 3}\end{array}\right) .$ The probabilities that a measurement of $S_{2}$ will yield the values $\hbar / 2$ and $-\hbar / 2$ are, respectively,
	\exyear{NET JUNE 2013}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $1 / 2$ and $1 / 2$
	\task[\textbf{B.}]$2 / 3$ and $1 / 3$
	\task[\textbf{C.}]$1 / 4$ and $3 / 4$
	\task[\textbf{D.}]$1 / 3$ and $2 / 3$
\end{tasks}
\begin{answer}
Eigen state of $S_{z}$ is $\left|\phi_{1}\right\rangle=\left(\begin{array}{l}1 \\ 0\end{array}\right)$ and $\left|\phi_{2}\right\rangle=\left(\begin{array}{l}0 \\ 1\end{array}\right)$ corresponds to Eigen value $\frac{\hbar}{2}$ and $-\frac{\hbar}{2}$ respectively.
$$
P\left(\frac{\hbar}{2}\right)=\frac{\left|\left\langle\phi_{1} \mid \psi\right\rangle\right|^{2}}{\langle\psi \mid \psi\rangle}=\left|\frac{1+i}{\sqrt{6}}\right|^{2}=\frac{2}{6}=\frac{1}{3}, \quad P\left(-\frac{\hbar}{2}\right)=\frac{\left|\left\langle\phi_{2} \mid \psi\right\rangle\right|^{2}}{\langle\psi \mid \psi\rangle}=\frac{2}{3}
$$
The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item A spin $-\frac{1}{2}$ particle is in the state $\chi=\frac{1}{\sqrt{11}}\left(\begin{array}{c}1+i \\ 3\end{array}\right)$ in the eigenbasis of $S^{2}$ and $S_{2}$. If we measure $S_{z}$, the probabilities of getting $+\frac{h}{2}$ and $-\frac{h}{2}$, respectively are
	\exyear{NET DEC 2013}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{1}{2}$ and $\frac{1}{2}$
	\task[\textbf{B.}]$\frac{2}{11}$ and $\frac{9}{11}$
	\task[\textbf{C.}] 0 and 1
	\task[\textbf{D.}]$\frac{1}{11}$ and $\frac{3}{11}$
\end{tasks}
\begin{answer}
	$P\left(\frac{\hbar}{2}\right)=\left|\frac{1}{\sqrt{11}}(10)\left(\begin{array}{c}1+i \\ 3\end{array}\right)\right|^{2}=\frac{1}{11} \times 2=\frac{2}{11} \quad \because\langle\psi \mid \psi\rangle=1$\\ $P\left(-\frac{\hbar}{2}\right)=\left|\frac{1}{\sqrt{11}}(01)\left(\begin{array}{c}1+i \\ 3\end{array}\right)\right|^{2}=\frac{9}{11}$\\
	i.e. probability of $S_{z}$ getting $\left(\frac{\hbar}{2}\right)$ and $\left(-\frac{\hbar}{2}\right)$\\
	The correct option is \textbf{b}
\end{answer}
\begin{minipage}{\textwidth}
\item Let $\vec{\sigma}=\left(\sigma_{1}, \sigma_{2}, \sigma_{3}\right)$, where $\sigma_{1}, \sigma_{2}, \sigma_{3}$ are the Pauli matrices. If $\vec{a}$ and $\vec{b}$ are two arbitrary constant vectors in three dimensions, the commutator $[\vec{a} \cdot \vec{\sigma}, \vec{b} \cdot \vec{\sigma}]$ is equal to (in the following $I$ is the identity matrix)
	\exyear{NET DEC 2014}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $(\vec{a} \cdot \vec{b})\left(\sigma_{1}+\sigma_{2}+\sigma_{3}\right)$
	\task[\textbf{B.}]$2 i(\vec{a} \times \vec{b}) \cdot \vec{\sigma}$
	\task[\textbf{C.}]$(\vec{a} \cdot \vec{b}) I$
	\task[\textbf{D.}]$|\vec{a}||\vec{b}| I$
\end{tasks}
\begin{answer}
	$\vec{a}=a_{1} \hat{i}+a_{2} \hat{j}+a_{3} \hat{k}, \vec{b}=b_{1} \hat{i}+b_{2} \hat{j}+b_{3} \hat{k}, \sigma=\sigma_{x} \hat{i}+\sigma_{y} \hat{j}+\sigma_{z} \hat{k}$

	\begin{align*}
	&{[\vec{a} \cdot \vec{\sigma}, \vec{b} \cdot \vec{\sigma}]=\left[a_{1} \sigma_{x}+a_{2} \sigma_{y}+a_{3} \sigma_{z}, b_{1} \sigma_{x}+b_{2} \sigma_{y}+b_{3} \sigma_{z}\right]} \\
	&{[\vec{a} \cdot \vec{\sigma}, \vec{b} \cdot \vec{\sigma}]=a_{1} b_{1}\left[\sigma_{x}, \sigma_{x}\right]+a_{1} b_{2}\left[\sigma_{x}, \sigma_{y}\right]+a_{1} b_{3}\left[\sigma_{x}, \sigma_{z}\right]+a_{2} b_{1}\left[\sigma_{y}, \sigma_{x}\right]+a_{2} b_{2}\left[\sigma_{y}, \sigma_{y}\right]} \\
	&+a_{2} b_{3}\left[\sigma_{y}, \sigma_{z}\right]+a_{3} b_{1}\left[\sigma_{z}, \sigma_{x}\right]+a_{3} b_{2}\left[\sigma_{z}, \sigma_{y}\right]+a_{3} b_{3}\left[\sigma_{z}, \sigma_{z}\right] \\
	&=a_{1} b_{1} \cdot 0+a_{1} b_{2} \cdot 2 i \sigma_{z}-2 i a_{1} b_{3} \sigma_{y}-a_{2} b_{1} \cdot 2 i \sigma_{z}+0+a_{2} b_{3} \cdot 2 i \sigma_{x}+a_{3} b_{1} \cdot 2 i \sigma_{y}-a_{3} b_{2} \cdot 2 i \sigma_{x}+0 \\
	&\Rightarrow[\vec{a} \cdot \vec{\sigma}, \vec{b} \cdot \vec{\sigma}]==2 i(\vec{a} \times \vec{b}) \cdot \vec{\sigma}
	\end{align*}
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $L_{i}$ are the components of the angular momentum operator $\vec{L}$, then the operator $\sum_{i=1,2,3}\left[\vec{L}, L_{i}\right]$ equals
	\exyear{NET JUNE 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\vec{L}$
	\task[\textbf{B.}]$2 \vec{L}$
	\task[\textbf{C.}]$3 \vec{L}$
	\task[\textbf{D.}]$-\vec{L}$
\end{tasks}
\begin{answer}
	 Let $\vec{L}=L_{x} \hat{i}+L_{y} \hat{j}+L_{z} \hat{k}$
	\begin{align*}
	&x=1, y=2, z=3 \\
	&{\left[\vec{L}, L_{x}\right]=\left[L_{y}, L_{x}\right] j+\left[L_{z}, L_{x}\right] \hat{k}=-i \hbar L_{z} \hat{j}+L_{y} \hat{k} i \hbar} \\
	&{\left[\left[\vec{L}, L_{x}\right], L_{x}\right]=i \hbar\left[-L_{z}, L_{x}\right] \hat{j}+\left[L_{y}, L_{x}\right] i \hbar-i \hbar . i \hbar L_{y} \hat{j}-(i \hbar) L_{z}(i \hbar) L_{z}(i \hbar) \cdot \hat{k}=\hbar^{2}\left[L_{y} \hat{j}+L_{z} \hat{k}\right]} \\
	&\text { similarly, }\left[\left[\vec{L}, L_{y}\right] L_{y}\right]=\hbar^{2}\left[L_{x} \hat{i}+L_{z} \hat{k}\right] \\
	&{\left[\left[\vec{L}, L_{z}\right] L_{z}\right]=\hbar^{2}\left[L_{x} \hat{i}+L_{y} \hat{j}\right]} \\
	&\sum_{i=1,2,3}[[L, L i] L i]=2 \hbar^{2}\left[L_{x} \hat{i}+L_{y} \hat{j}+L_{z} \hat{k}\right]=2 \vec{L} \quad \text { put } \hbar=1
	\end{align*}
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The Hamiltonian for a spin- $\frac{1}{2}$ particle at rest is given by $H=E_{0}\left(\sigma_{z}+\alpha \sigma_{x}\right)$, where $\sigma_{x}$ and $\sigma_{z}$ are Pauli spin matrices and $E_{0}$ and $\alpha$ are constants. The eigenvalues of this Hamiltonian are
	\exyear{NET DEC 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\pm E_{0} \sqrt{1+\alpha^{2}}$
	\task[\textbf{B.}]$\pm E_{0} \sqrt{1-\alpha^{2}}$
	\task[\textbf{C.}]$E_{0}$ (doubly degenerate)
	\task[\textbf{D.}]$E_{0}\left(1 \pm \frac{1}{2} \alpha^{2}\right)$
\end{tasks}
\begin{answer}
	$ H=E_{0}\left(\dot{\sigma}_{z}+\alpha \sigma_{x}\right)=E_{0}\left[\left(\begin{array}{cc}1 & 0 \\ 0 & -1\end{array}\right)+\alpha\left(\begin{array}{ll}0 & 1 \\ 1 & 0\end{array}\right)\right] \Rightarrow H=E_{0}\left(\begin{array}{cc}1 & \alpha \\ \alpha & -1\end{array}\right)$
	if $\lambda$ is eigen value, then
	$$
	H-\lambda I=0 \Rightarrow E_{0}\left(\begin{array}{cc}
	(1-\lambda) & \alpha \\
	\alpha & -(1+\lambda)
	\end{array}\right)=0, \quad \lambda=\pm E_{0} \sqrt{1+\alpha^{2}}
	$$
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $\hat{L}_{x}, \hat{L}_{y}, \hat{L}_{z}$ are the components of the angular momentum operator in three dimensions the commutator $\left[\hat{L}_{x}, \hat{L}_{x} \hat{L}_{y} \hat{L}_{z}\right]$ may be simplified to
	\exyear{NET JUNE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \hbar L_{x}\left(\hat{L}_{z}^{2}-\hat{L}_{y}^{2}\right)$
	\task[\textbf{B.}]$i \hbar \hat{L}_{z} \hat{L}_{y} \hat{L}_{x}$
	\task[\textbf{C.}] $i \hbar L_{x}\left(2 \hat{L}_{z}^{2}-\hat{L}_{y}^{2}\right)$
	\task[\textbf{D.}]0
\end{tasks}
\begin{answer}
	\begin{align*}
		&:\left[L_{x}, L_{x} L_{y} L_{z}\right]=L_{x}\left[L_{x}, L_{y} L_{z}\right]+\left[L_{x}, L_{x}\right] L_{y} L_{z} \\
		&=L_{x}\left[L_{x}, L_{y}\right] L_{z}+L_{x} L_{y}\left[L_{x}, L_{z}\right]+0=L_{x}\left[i \hbar L_{z}\right] L_{z}+L_{x} L_{y}\left(-i \hbar L_{y}\right) \\
		&=i \hbar L_{x} L_{z}^{2}-i \hbar L_{x} L_{y}^{2}=i \hbar L_{x}\left(L_{z}^{2}-L_{y}^{2}\right)
	\end{align*}
	The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item The Hamiltonian of a spin $\frac{1}{2}$ particle in a magnetic field $\vec{B}$ is given by $H=-\mu \cdot \vec{B} \cdot \vec{\sigma}$, where $\mu$ is a real constant and $\vec{\sigma}=\left(\sigma_{x}, \sigma_{y}, \sigma_{z}\right)$ are the Pauli spin matrices. If $\vec{B}=\left(B_{0}, B_{0}, 0\right)$ and the spin state at time $t=0$ is an eigenstate of $\sigma_{x}$, then of the expectation values $\left\langle\sigma_{x}\right\rangle,\left\langle\sigma_{y}\right\rangle$ and $\left\langle\sigma_{z}\right\rangle$
	\exyear{NET JUNE 2018}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] only $\left\langle\sigma_{x}\right\rangle$ changes with time
	\task[\textbf{B.}] only $\left\langle\sigma_{y}\right\rangle$ changes with time
	\task[\textbf{C.}]only $\left\langle\sigma_{z}\right\rangle$ changes with time
	\task[\textbf{D.}]all three change with time
\end{tasks}
\begin{answer}
 $\left\langle\sigma_{x}\right\rangle,\left\langle\sigma_{y}\right\rangle$ and $\left\langle\sigma_{z}\right\rangle$ will changes with time because Eigen state of $\sigma_{x}$ ie $\frac{1}{\sqrt{2}}\left(\begin{array}{l}1 \\ 1\end{array}\right)$ and $\frac{1}{\sqrt{2}}\left(\begin{array}{c}1 \\ -1\end{array}\right)$ and can be written in basis of eigen state of $H=-\mu \cdot \vec{B} \cdot \vec{\sigma}=-B_{0}\left(\begin{array}{cc}0 & 1-i \\ 1+i & 0\end{array}\right)$\\
 THe correct option is \textbf{(d)}
\end{answer}
\end{enumerate}

\newpage
\begin{abox}
	Practice set 2 solutions
	\end{abox}
\begin{enumerate}
\begin{minipage}{\textwidth}
	\item $\text { For a spin-s particle, in the eigen basis of } \vec{S}^{2}, S_{x} \text { the expectation value }\left\langle s m\left|S_{x}^{2}\right| s m\right\rangle \text { is }$
	\exyear{GATE 2010}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{\hbar^{2}\left\{s(s+1)-m^{2}\right\}}{2}$
	\task[\textbf{B.}] $\hbar^{2}\left\{s(s+1)-2 m^{2}\right\}$
	\task[\textbf{C.}]$\hbar^{2}\left\{s(s+1)-m^{2}\right\}$
	\task[\textbf{D.}]$\hbar^{2} m^{2}$
\end{tasks}
\begin{answer}
\begin{align*}
	&\left\langle s m\left|S_{x}^{2}\right| s m\right\rangle=\frac{1}{4}\left\langle s m\left|\left(S_{+}+S_{-}\right)^{2}\right| s m\right\rangle=\frac{1}{4}\left\langle s m\left|S_{+}^{2}+S_{-}^{2}+S_{+} S_{-}+S_{-} S_{+}\right| s m\right\rangle \\
	&=\frac{1}{4}\left\langle s m\left|S_{+} S_{-}+S_{-} S_{+}\right| s m\right\rangle=\frac{\hbar^{2}}{2}\left[s(s+1)-m^{2}\right] \quad\left[\because S_{+} S_{-}+S_{-} S_{+}=2\left(S^{2}-S_{z}^{2}\right)\right]
\end{align*}
The correct option is \textbf{(a)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $L_{x}, L_{y}$ and $L_{z}$ are respectively the $x, y$ and $z$ components of angular momentum operator $L$. The commutator $\left[L_{x} L_{y}, L_{z}\right]$ is equal to
	\exyear{GATE 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $i \hbar\left(L_{x}^{2}+L_{y}^{2}\right)$
	\task[\textbf{B.}]$2 i \hbar L_{z}$
	\task[\textbf{C.}]$i \hbar\left(L_{x}^{2}-L_{y}^{2}\right)$
	\task[\textbf{D.}]0
\end{tasks}
\begin{answer}
	$\left\lfloor L_{x} L_{y}, L_{z}\right\rfloor=L_{x}\left[L_{y} L_{z}\right]+\left[L_{x}, L_{z}\right] L_{y}=i \hbar\left(L_{x}^{2}-L_{y}^{2}\right)$\\
	The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item Which one of the following commutation relations is NOT CORRECT? Here, symbols have their usual meanings.
	\exyear{GATE 2013}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\left[L^{2}, L_{z}\right]=0$
	\task[\textbf{B.}]$\left\lfloor L_{x}, L_{y}\right\rfloor=i \hbar L_{z}$
	\task[\textbf{C.}]$\left[L_{z}, L_{+}\right]=\hbar L_{+}$
	\task[\textbf{D.}]$\left[L_{z}, L_{-}\right]=\hbar L_{-}$
\end{tasks}
\begin{answer}
The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item A spin-half particle is in a linear superposition $0.8|\uparrow\rangle+0.6|\downarrow\rangle$ of its spin-up and spindown states. If $|\uparrow\rangle$ and $|\downarrow\rangle$ are the eigenstates of $\sigma_{z}$, then what is the expectation value up to one decimal place, of the operator $10 \sigma_{z}+5 \sigma_{x}$ ? Here, symbols have their usual meanings.
	\exyear{GATE 2013}
\end{minipage}
\begin{answer}
\begin{align*}
	&\psi\rangle=.8|\uparrow\rangle+.6|\downarrow\rangle=0.8\left(\begin{array}{l}
		1 \\
		0
	\end{array}\right)+0.6\left(\begin{array}{l}
		0 \\
		1
	\end{array}\right)=\left(\begin{array}{l}
		0.8 \\
		0.6
	\end{array}\right) \\
	&\text { Operator } A=10 \sigma_{z}+5 \sigma_{x}=10\left(\begin{array}{cc}
		1 & 0 \\
		0 & -1
	\end{array}\right)+5\left(\begin{array}{ll}
		0 & 1 \\
		1 & 0
	\end{array}\right) \Rightarrow A=\left(\begin{array}{cc}
		10 & 5 \\
		5 & -10
	\end{array}\right) \\
	&\qquad\langle A\rangle=\langle\psi|A| \psi\rangle=\left(\begin{array}{ll}
		0.8 & 0.6
	\end{array}\right)\left(\begin{array}{cc}
		10 & 5 \\
		5 & -10
	\end{array}\right)\left(\begin{array}{l}
		0.8 \\
		0.6
	\end{array}\right)=(8.8-1.2)=7.6
\end{align*}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $\vec{L}$ is the orbital angular momentum and $\bar{S}$ is the spin angular momentum, then $\vec{L} \cdot \vec{S}$ does not commute with
	\exyear{GATE 2014}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $S_{z}$
	\task[\textbf{B.}]$L^{2}$
	\task[\textbf{C.}]$S^{2}$
	\task[\textbf{D.}]$(\vec{L}+\vec{S})^{2}$
\end{tasks}
\begin{answer}
The correct option is \textbf{(d)}
\end{answer}
\begin{minipage}{\textwidth}
	\item If $L_{+}$and $L_{-}$are the angular momentum ladder operators then the expectation value of $\left(L_{+} L_{-}+L_{-} L_{+}\right)$in the state $|l=1, m=1\rangle$ of an atom is $\hbar^{2}$
	\exyear{GATE 2014}
\end{minipage}
\begin{answer}
	$\left(L_{+} L_{-}+L_{-} L_{+}\right)=2\left(L^{2}-L_{z}^{2}\right)=2\left(l .(l+1)-m^{2}\right) \hbar^{2}=2 \hbar^{2}$
\end{answer}
\begin{minipage}{\textwidth}
	\item The Pauli matrices for three spin $-\frac{1}{2}$ particles are $\vec{\sigma}_{1}, \vec{\sigma}_{2}$ and $\vec{\sigma}_{3}$, respectively. The dimension of the Hilbert space required to define an operator $\hat{O}=\vec{\sigma}_{1} \cdot \vec{\sigma}_{2} \times \vec{\sigma}_{3}$ is
	\exyear{GATE 2015}
\end{minipage}
\begin{answer}
	$\sigma_{2} \times \sigma_{3} \text { has dimension of } 4 \text { and } \sigma_{1} . \sigma_{2} \times \sigma_{3} \text { has dimension of } 2 \times 4=8$
\end{answer}
\begin{minipage}{\textwidth}
	\item Let the Hamiltonian for two spin-1/2 particles of equal masses $m$, momenta $\vec{p}_{1}$ and $\vec{p}_{2}$ and positions $\vec{r}_{1}$ and $\vec{r}_{2}$ be $H=\frac{1}{2 m} p_{1}^{2}+\frac{1}{2 m} p_{2}^{2}+\frac{1}{2} m \omega^{2}\left(r_{1}^{2}+r_{2}^{2}\right)+k \vec{\sigma}_{1} \cdot \vec{\sigma}_{2}$, where $\vec{\sigma}_{1}$ and $\vec{\sigma}_{2}$ denote the corresponding Pauli matrices, $\hbar \omega=0.1 \mathrm{eV}$ and $k=0.2 \mathrm{eV}$. If the ground state has net spin zero, then the energy (in $\mathrm{eV}$ ) is
	\exyear{GATE 2015}
\end{minipage}
\begin{answer}
$H=\frac{1}{2 m} p_{1}^{2}+\frac{1}{2 m} p_{2}^{2}+\frac{1}{2} m \omega^{2}\left(r_{1}^{2}+r_{2}^{2}\right)+k \vec{\sigma}_{1} \cdot \vec{\sigma}_{2}$
\begin{align*}
&\vec{\sigma}=\overrightarrow{\sigma_{1}}+\vec{\sigma}_{2} \Rightarrow \vec{\sigma}^{2}=\sigma_{1}^{2}+\sigma_{2}^{2}+2 \vec{\sigma}_{1} \cdot \vec{\sigma}_{2} \Rightarrow 2 \vec{\sigma}_{1} \cdot \vec{\sigma}_{2}=\vec{\sigma}^{2}-\sigma_{1}^{2}-\sigma_{2}^{2} \\
&\Rightarrow 2 \vec{\sigma}_{1} \cdot \vec{\sigma}_{2}=0-3 I-3 I=-6 I \Rightarrow \vec{\sigma}_{1} \cdot \vec{\sigma}_{2}=-3
\end{align*}
Now energy $E=2 \times \frac{3}{2} \hbar \omega+k(-3)=3 \times(0.1)+(0.2)(-3)=-0.3 \mathrm{eV}$
\end{answer}
\begin{minipage}{\textwidth}
	\item If $\vec{s}_{1}$ and $\vec{s}_{2}$ are the spin operators of the two electrons of a He atom, the value o $\left\langle\vec{s}_{1} \cdot \vec{s}_{2}\right\rangle$ for the ground state is
	\exyear{GATE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-\frac{3}{2} \hbar^{2}$
	\task[\textbf{B.}]$-\frac{3}{4} \hbar^{2}$
	\task[\textbf{C.}] 0
	\task[\textbf{D.}] $\frac{1}{4} \hbar^{2}$
\end{tasks}
\begin{answer}
	$\vec{s}=\vec{s}_{1}+\vec{s}_{2}, s_{1}=\frac{1}{2}, s_{1}=\frac{1}{2}, s=0,1$\\ $$\left\langle\vec{s}_{1} \cdot \vec{s}_{2}\right\rangle=\frac{s(s+1) \hbar^{2}-s_{1}\left(s_{1}+1\right) \hbar^{2}-s_{2}\left(s_{2}+1\right) \hbar^{2}}{2}$$
	For $$s=1,\left\langle\vec{s}_{1} \cdot \vec{s}_{2}\right\rangle=\frac{2 \hbar^{2}-\frac{3}{4} \hbar^{2}-\frac{3}{4} \hbar^{2}}{2}=\frac{3}{4} \hbar^{2}$$
	$$
	s=0,\left\langle\vec{s}_{1} \cdot \vec{s}_{2}\right\rangle=\frac{0 \hbar^{2}-\frac{3}{4} \hbar^{2}-\frac{3}{4} \hbar^{2}}{2}=-\frac{3}{4} \hbar^{2}
	$$
	The correct option is \textbf{(b)}
\end{answer}
\begin{minipage}{\textwidth}
	\item $\sigma_{x}, \sigma_{y} \text { and } \sigma_{z} \text { are the Pauli matrices. The expression } 2 \sigma_{x} \sigma_{y}+\sigma_{y} \sigma_{x} \text { is equal to }$
	\exyear{GATE 2016}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $-3 i \sigma_{z}$
	\task[\textbf{B.}]$-i \sigma_{z}$
	\task[\textbf{C.}]$i \sigma_{z}$
	\task[\textbf{D.}]$3 i \sigma_{z}$
\end{tasks}
\begin{answer}
	$2 \sigma_{x} \sigma_{y}+\sigma_{y} \sigma_{x} \Rightarrow \sigma_{x} \sigma_{y}+\sigma_{x} \sigma_{y}+\sigma_{y} \sigma_{x} \Rightarrow \sigma_{x} \sigma_{y}=i \sigma_{z}$\\
	The correct option is \textbf{(c)}
\end{answer}
\begin{minipage}{\textwidth}
	\item For the Hamiltonian $H=a_{0} I+\vec{b} \cdot \vec{\sigma}$ where $a_{0} \in R, \vec{b}$ is a real vector, $I$ is the $2 \times 2$ identity matrix, and $\vec{\sigma}$ are the Pauli matrices, the ground state energy is
	\exyear{GATE 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $|b|$
	\task[\textbf{B.}]$2 a_{0}-|b|$
	\task[\textbf{C.}]$a_{0}-|b|$
	\task[\textbf{D.}]$a_{0}$
\end{tasks}
\begin{answer}
$a_{0} I+\vec{b} \cdot \vec{\sigma}=a_{0}\left(\begin{array}{cc}
	1 & 0 \\
	0 & 1
\end{array}\right)+b_{x}\left(\begin{array}{cc}
	0 & 1 \\
	1 & 0
\end{array}\right)+b_{y}\left(\begin{array}{cc}
	0 & -i \\
	i & 0
\end{array}\right)+b_{z}\left(\begin{array}{cc}
	1 & 0 \\
	0 & -1
\end{array}\right)=\left(\begin{array}{cc}
	a_{0}+b_{z} & b_{x}-i b_{y} \\
	b_{x}+i b_{y} & a_{0}-b_{z}
\end{array}\right)$\\
$H=a_{0} I+\vec{b} \cdot \vec{\sigma}=\left(\begin{array}{cc}
	a_{0}+b_{z} & b_{x}-i b_{y} \\
	b_{x}+i b_{y} & a_{0}-b_{z}
\end{array}\right)$\\
For eigen value $\left(\begin{array}{cc}a_{0}+b_{z}-\lambda & b_{x}-i b_{y} \\ b_{x}+i b_{y} & a_{0}-b_{z}-\lambda\end{array}\right)=0$
$$
\begin{aligned}
&\left(a_{0}+b_{z}-\lambda\right)\left(a_{0}-b_{z}-\lambda\right)-\left(b_{x}^{2}+b_{y}^{2}\right)=0 \\
&\lambda_{1}=a_{0}-|b|, \lambda_{1}=a_{0}+|b|
\end{aligned}
$$
The correct option is \textbf{(c)}
\end{answer}
\end{enumerate}

QM -CSIR/chapter/angular momentum solutions.tex


\documentclass[a4paper,11pt]{article}
\usepackage{amsmath, amsthm, amssymb, commath, graphicx, bbold, endnotes, graphicx, subfigure, multirow, setspace, siunitx}
\usepackage{amsmath}
\usepackage[font=footnotesize]{caption}
\usepackage[top=1.25in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
\linespread{1}
\setlength{\parindent}{30pt}

\title{Cosmological Parameters and Conversions Memo}
\author{Ruby Byrne}
\date{October 2018}

\begin{document}

\maketitle

\section{Parallel to the Line-of-Sight}

From Morales and Hewitt 2004, frequency $\Delta f$ is related to the co-moving line-of-sight distance $\Delta r_z$ by
\begin{equation}
\Delta f \approx \frac{f_{21} E(z)}{D_H (1+z)^2} \Delta r_z
\end{equation}
The Fourier inverse of $\Delta f$ is $\eta$ and the Fourier inverse of $\Delta r_z$ is $k_z$. These are related by
\begin{equation}
\eta \approx \frac{D_H (1+z)^2}{2 \pi f_{21} E(z)} k_z
\end{equation}
$f_{21}$ is the frequency of the 21-cm signal, so $f_{21} = \frac{c}{0.21 \si{m}}$. $D_H$ is the Hubble distance. From Hogg 2000,
\begin{equation}
D_H = \frac{c}{H_0} = 3000 \frac{\si{Mpc}}{h}
\end{equation}
where $H_0$ is the Hubble constant in the present epoch and $h$ is a dimensionless quantity that is thought to be $0.6 < h < 0.9$ (the \textit{IDL} function \texttt{cosmology\_measures} defaults $h=0.71$). $H_0$ is related to $h$ by
\begin{equation}
H_0 = 100 \frac{h\si{km}}{\si{s.Mpc}}
\end{equation}
Again from Morales and Hewitt 2004,
\begin{equation}
E(z) = \sqrt{\Omega_M(1+z)^3+\Omega_k(1+z)^2+\Omega_{\Lambda}}
\end{equation}
where $\Omega_M$ is the matter constant, $\Omega_k$ is the curvature constant, and $\Omega_{\Lambda}$ is the ``lambda'' constant (whatever that is).

The \textit{IDL} function \texttt{cosmology\_measures} defaults these parameters to $\Omega_M=0.27$, $\Omega_k=0$, and $\Omega_{\Lambda}=0.73$. Plugging these to $E(z)$ for $z=7$ in gives $E(7) \approx 11.79$. Therefore at $z=7$, the conversion between $\eta$ and $k_z$ is given by
\begin{equation}
k_z \approx \left(5.51\times10^5 \frac{h}{\si{s.Mpc}}\right) \eta
\end{equation}

\section{Perpendicular to the Line-of-Sight}

From Morales and Hewitt 2004, sky positions $\theta_x$ and $\theta_y$ are related to co-moving distances $r_x$ and $r_y$ according to
\begin{equation}
\theta_x = \frac{r_x}{D_M(z)}, \quad \theta_y = \frac{r_y}{D_M(z)}
\end{equation}
The Fourier inverses of $\theta_x$ and $\theta_y$ are $u$ and $v$ and the Fourier inverses of $r_x$ and $r_y$ are $k_x$ and $k_y$. These are related by
\begin{equation}
u = \frac{k_x D_M(z)}{2 \pi}, \quad v = \frac{k_y D_M(z)}{2 \pi}
\end{equation}
$D_M$ is the ``transverse co-moving distance.''

From Hogg 2000,
\begin{equation}
  D_M=\begin{cases}
    D_H \frac{1}{\sqrt{\Omega_k}} \text{sinh}(\sqrt{\Omega_k}D_C/D_H), & \text{for $\Omega_k>0$}\\
    D_C, & \text{for $\Omega_k=0$}\\
    D_H \frac{1}{\sqrt{\Omega_k}} \text{sin}(\sqrt{\Omega_k}D_C/D_H), & \text{for $\Omega_k<0$}
  \end{cases}
\end{equation}
$D_C$ is the co-moving distance and is defined as
\begin{equation}
D_C = D_H \int_0^z \frac{dz'}{E(z')} = D_H \int_0^z \frac{dz'}{\sqrt{\Omega_M(1+z')^3+\Omega_k(1+z')^2+\Omega_{\Lambda}}}
\end{equation}

This integral must be evaluated numerically. With $z=7$, $\Omega_M=0.27$, $\Omega_k=0$, and $\Omega_{\Lambda}=0.73$ as above and evaluating the integral with
\textit{Mathematica}, we get that
\begin{equation}
D_C \approx D_H(2.09) = 6.27 \times 10^3 \frac{\si{Mpc}}{h}
\end{equation}
This integral is also evaluated by \textit{IDL}'s \texttt{cosmology\_measures} function. Since we are assuming $\Omega_k=0$, $D_M=D_C$ and
\begin{equation}
D_M \approx 6.27 \times 10^3 \frac{\si{Mpc}}{h}
\end{equation}
To convert from $(u, v)$ coordinates to $(k_x,k_y)$ coordinates, we therefore get
\begin{equation}
k_x \approx \left(1.00\times10^{-3} \frac{h}{\si{Mpc}}\right)u, \quad k_y \approx \left(1.00\times10^{-3} \frac{h}{\si{Mpc}}\right)v
\end{equation}

\end{document}


% ----------------------------------------------------------------------
\section{Incompressible Isotropic Elasticity with Infinitesimal Strain (Bathe)}

In this section we apply a similar approach to the one we use for the
elasticity equation to the case of an incompressible material. We only
consider the quasistatic case (neglect inertia) without faults. As the
bulk modulus ($K$) approaches infinity, the volumetric strain
($\Tr(\epsilon)$) approaches zero and the pressure remains finite,
$p = -K \Tr(\epsilon)$. We consider pressure $p$ as an independent
variable and decompose the stress into the pressure and deviatoric
components. As a result, we write the stress tensor in terms of both
the displacement and pressure fields,
\begin{equation}
  \tensor{\sigma}(\vec{u},p) = \tensor{\sigma}^\mathit{dev}(\vec{u}) - p\tensor{I}.
\end{equation}

The strong form is
\begin{gather}
  % Solution
  \vec{s}^T = \left( \vec{u} \quad \ p \right)^T, \\
  % Elasticity
  \vec{f}(t) + \tensor{\nabla} \cdot \left(\tensor{\sigma}^\mathit{dev}(\vec{u}) - p\tensor{I}\right) = \vec{0} \text{ in }\Omega, \\
  % Pressure
  \vec{\nabla} \cdot \vec{u} + \frac{p}{K} = 0 \text{ in }\Omega, \\
  % Neumann
  \tensor{\sigma} \cdot \vec{n} = \vec{\tau} \text{ on }\Gamma_\tau, \\
  % Dirichlet
  \vec{u} = \vec{u}_0 \text{ on }\Gamma_u, \\
  p = p_0 \text{ on }\Gamma_p.
\end{gather}
We place all terms for the elasticity and pressure equations on the
left-hand-side, consistent with PETSc TS implicit time stepping.

\begin{table}[htbp]
  \caption{Mathematical notation for incompressible elasticity with
    infinitesimal strain.}
  \label{tab:notation:incompressible:elasticity}
  \begin{tabular}{lcp{3.5in}}
    \toprule
    {\bf Category} & {\bf Symbol} & {\bf Description} \\
    \midrule
    Unknowns & $\vec{u}$ & Displacement field \\
    & $p$ & Pressure field ($p>0$ corresponds to negative mean stress \\
    Derived quantities & $\tensor{\sigma}$ & Cauchy stress tensor \\
                   & $\tensor{\epsilon}$ & Cauchy strain tensor \\
    Common constitutive parameters & $\rho$ & Density \\
  & $\mu$ & Shear modulus \\
  & $K$ & Bulk modulus \\
Source terms & $\vec{f}$ & Body force per unit volume, for example $\rho \vec{g}$ \\
    \bottomrule
  \end{tabular}
\end{table}

Using trial functions $\trialvec[u]$ and $\trialscalar[p]$ and
incorporating the Neumann boundary conditions, we write the weak form
as
\begin{gather}
  % Displacement
  \int_\Omega \trialvec[u] \cdot \vec{f}(t) + \nabla \trialvec[u] : \left(-\tensor{\sigma}^\mathit{dev}(\vec{u}) + p\tensor{I}
  \right)\, d\Omega + \int_{\Gamma_\tau} \trialvec[u] \cdot \vec{\tau}(t) \, d\Gamma, = 0 \\
  % Pressure
  \int_\Omega \trialscalar[p] \cdot \left(\vec{\nabla} \cdot \vec{u} + \frac{p}{K} \right) \, d\Omega = 0.
\end{gather}

\subsection{Residual Pointwise Functions}

Identifying $F(t,s,\dot{s})$, we have
\begin{gather}
  \label{eqn:incompressible:elasticity:displacement}
  F^u(t,s,\dot{s}) = \int_\Omega \trialvec[u] \cdot \eqnannotate{\vec{f}(t)}{f_0^u} + \nabla \trialvec[u] :
  \eqnannotate{\left(-\tensor{\sigma}^\mathit{dev}(\vec{u}) + p\tensor{I}\right)}{f_1^u}  \, d\Omega
  + \int_{\Gamma_\tau} \trialvec[u] \cdot \eqnannotate{\vec{\tau}(t)}{f_0^u} \, d\Gamma, \\
%
  \label{eqn:incompressible:elasticity:pressure}
  F^p(t,s,\dot{s}) = \int_\Omega \trialscalar[p] \cdot \eqnannotate{\left(\vec{\nabla} \cdot \vec{u} +
\frac{p}{K} \right)}{f_0^p} \, d\Omega.
\end{gather}

\subsection{Jacobians Pointwise Functions}

With two fields we have four Jacobian pointwise functions for the LHS:
\begin{align}
  % JF uu
  J_F^{uu} &= \frac{\partial F^u}{\partial u} + s_\mathit{tshift} \frac{\partial F^u}{\partial \dot{u}} =
             \int_\Omega \nabla \trialvec[u] : \frac{\partial}{\partial u}(-\tensor{\sigma}^\mathit{dev}) \, d\Omega
             = \int_\Omega \trialscalar[u]_{i,k} \, \eqnannotate{\left(-C^\mathit{dev}_{ikjl}\right)} {J_{f3}^{uu}}  \, \basisscalar[u]_{j,l}\, d\Omega \\
  % JF up
  J_F^{up} &= \frac{\partial F^u}{\partial p} + s_\mathit{tshift} \frac{\partial F^u}{\partial \dot{p}} =
             \int_\Omega \nabla\trialvec[u] : \tensor{I} \basisscalar[p] \,  d\Omega
             = \int_\Omega \trialscalar[u]_{i,k} \eqnannotate{\delta_{ik}}{J_{f2}^{up}} \, \basisscalar[p] \, d\Omega \\
  % JF pu
  J_F^{pu} &= \frac{\partial F^p}{\partial u} + s_\mathit{tshift} \frac{\partial F^p}{\partial \dot{u}} =
             \int_\Omega \trialscalar[p] \left(\vec{\nabla}  \cdot \basisvec[u]\right) \, d\Omega
             = \int_\Omega \trialscalar[p] \eqnannotate{\delta_{jl}}{J_{f1}^{pu}} \basisscalar[u]_{j,l} \, d\Omega\\
  % JF pp
  J_F^{pp} &= \frac{\partial F^p}{\partial p}  + s_\mathit{tshift} \frac{\partial F^p}{\partial \dot{p}} =
             \int_\Omega \trialscalar[p] \eqnannotate{\frac{1} {K}}{J_{f0}^{pp}} \basisscalar[p] \, d\Omega
\end{align}

For isotropic, linear incompressible elasticity, the deviatoric elastic constants are:
\begin{align}
    C_{1111} &= C_{2222} = C_{3333} = +\frac{4}{3} \mu \\
    C_{1122} &= C_{1133} = C_{2233} = -\frac{2}{3} \mu \\
    C_{1212} &= C_{1313} = C_{2323} = \mu
\end{align}


\section*{Multi-class Hinge Loss}
One vs. One | One vs. All | Maintain $w^{(1)},..,w^{(c)}$\hfil
%$l_{MC-H}(w^{(1)},..,w^{(c)};x,y) =
%\underset{j\in\{1,..,y-1,y+1,..,c\}}{\operatorname{max}}\\
%(0,1+\text{max } w^{(j)T} x - w^{(y)T} x)$


\documentclass[]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
%opening
\title{Actor Critic Agent}
\author{Marco Marini}

\begin{document}

\maketitle

\begin{abstract}
Description of Actor Critic Agent and definitions of performance indicators
\end{abstract}

\tableofcontents

\section{Actor Critic Agent}

The Policy Actor Critic Agent is composed by an artificial neural network (ANN) that generates the differential state value of critic component and the policy parameters for action selection of each actor (the action space dimensions) from the state input signals.
At each iteration with the environment, the agent computes the average reward $r_\pi$ and the differential TD error $ \delta_t $
\begin{equation}
\delta_t = R_{t+1} - \bar R + \hat v(S_{t+1}) - \hat v(S_t)
\end{equation}

The differential TD error indicate how different is the differential state value determined by the current reward from the estimated differential state value.

If the error is positive the agent changes the policy reinforcing the current strategy. It increments the probabilities of selected actions and at the same time reduces the probabilities of the other actions.

If the error is negative the agent changes the policy weakening the current strategy. It reduces the probabilities of selected actions and increments the probabilities of the other actions.

The magnitude of changes is proportional to the TD Error by a $ \alpha_i $ parameter for each $ i $ actor that allows to control the convergence of the algorithm.

The TD error is used to determine the updated output values and train the AAN with these expected outputs.

\subsection{Discrete Policy Actor}

The policy actor computes the probabilities $ \pi(a|s) $ of choose action $ a $ at status $ s $.
The probabilities are the softmax function of the action preferences $ h(s,a,\vec \theta) $ given by the ANN
\begin{align}
	\pi(a|s, \vec \theta)
	&= \frac{e^{h_a(s,a,\vec{\theta})}}{\sum_{b \in A} e^{h(s,b,\vec{\theta})}}
\end{align}

To train the ANN the agent updates the $ \vec \theta $ parameters at each step $ t $
\begin{align}
	\vec \theta_{t+1} =
	\vec \theta_t + \alpha \delta_t \nabla \ln \pi(A_t|S_t, \vec \theta_t)
\end{align}

The policy gradient function is
\begin{align*}
\begin{split}
	\nabla \ln \pi(A_t|S_t, \vec \theta)
	& = \frac{1}{\pi(A_t|S_t, \vec \theta)}
	\nabla \pi(A_t|S_t, \vec \theta)
	\\
	\pi(a|s, \vec \theta)
	&= \frac{e^{h_a(s,a,\vec{\theta})}}{D(s,\vec \theta)}
	\\
	D(s,\vec \theta)
	&= \sum_{b \in A} e^{h(s,b,\vec{\theta})}
	\\
	\nabla \pi(A_t|S_t, \vec \theta)
	& =
	\frac{1}{D^2(S_t,\vec \theta)}
	\left[
		D(S_t, \vec \theta) \nabla e^{h(S_t,A_t,\vec \theta)} - e^{h(S_t,A_t,\vec \theta)} \nabla D(S_t, \vec \theta)
	\right]
	\\
	& =	\frac{1}{D^2(S_t,\vec \theta)}
	\left[
		D(S_t, \vec \theta) e^{h(S_t,A_t,\vec \theta)} \nabla h(S_t,A_t,\vec \theta)
		- e^{h(S_t,A_t,\vec \theta)} \nabla D(S_t, \vec \theta)
	\right]
	\\
	& =
	\frac{\pi(A_t|S_t,\vec \theta)}{D(S_t,\vec \theta)}
	\left[
		D(S_t, \vec \theta) \nabla h(S_t,A_t,\vec \theta)
		- \nabla D(S_t, \vec \theta)
	\right]
	\\
	\nabla D(s,\vec \theta)
	&= \sum_{b \in A} \nabla e^{h(s,b,\vec \theta)}
	\\
	&= \sum_{b \in A} e^{h(s,b,\vec \theta)}	\nabla h(s,b,\vec \theta)
	\\
	\nabla \pi(A_t|S_t, \vec \theta)
	& =
	\frac{\pi(A_t|S_t,\vec \theta)}{D(S_t,\vec \theta)}
	\left[
		D(S_t, \vec \theta) \nabla h(S_t,A_t,\vec \theta)
		- \sum_{b \in A} e^{h(s,b,\vec \theta)}	\nabla h(s,b,\vec \theta)
	\right]
\end{split}
\end{align*}

Let be
\begin{align*}
	I(a, b) = 1, \Rightarrow a = b
	\\
	I(a,b) = 0 \Rightarrow a \ne b
\end{align*}
then
\begin{align*}
\begin{split}
	\sum_{b \in A} I(At, b) \nabla h(St, b), \vec \theta)
	&= \nabla h(St, At), \vec \theta)
	\\
	\nabla \pi(A_t|S_t, \vec \theta)
	&=
	\frac{\pi(A_t|S_t,\vec \theta)}{D(S_t,\vec \theta)}
	\sum_{b \in A}
	\left[
		D(S_t, \vec \theta) I(A_t,b)
		-  e^{h(S_t,b,\vec \theta)}
	\right]
	\nabla h(S_t,b,\vec \theta)
	\\
	\nabla \ln \pi(A_t|S_t, \vec \theta)
	&=
	\sum_{b \in A}
	\left[
		I(A_t,b)
		-  \pi(S_t,b,\vec \theta)
	\right]
	\nabla h(S_t,b,\vec \theta)
	\\
	\delta_h(S_t, A_t, b, \theta_t)
	&= \delta_t
	\left[
		I(A_t,b) - \pi(S_t,b,\vec \theta)
	\right]
	\\
	\vec \theta_{t+1}
	&=
	\vec \theta_t +
	\sum_{b \in A}
	\alpha \delta_h(S_t, A_t, b, \theta_t)  \nabla h(S_t,b,\vec \theta_t)
\end{split}
\end{align*}

The same result is obtained by training the network with labels
\begin{align}
\begin{split}
	h^*(S_t,A_t,b) = h(S_t,b,\vec \theta_t) +
	\alpha \delta_h(S_t, A_t, b, \vec \theta_t)
\end{split}
\end{align}

\subsection{Gaussian policy actor}

The Gaussian policy actor computes the probabilities $ \pi(a|s) $ of choose a continuous action $ a $ at status $ s $ as a normal distributed function of two parameters $ \mu(s, \vec \theta_\mu) $ and $ \sigma(s,\vec \theta_h) $.

\begin{align}
	\pi(a|s,\vec \theta_\mu, \vec \theta_h)
	&= \frac{1}{\sigma(s,\vec \theta_h) \sqrt{2 \pi}} e^{-\frac{(a - \mu(s, \vec \theta_\mu))^2}{\sigma(s, \vec \theta_h)^2}}
	\\
	\sigma(s, \vec \theta_h)
	&	= e^{h(s, \vec \theta_h)}
\end{align}

To train the ANN the agent updates the $ \vec \theta_\mu, \vec \theta_h $ parameters at each step $ t $
\begin{align}
	\vec \theta_{\mu t+1}
	&= \vec \theta_{\mu t}
	+ \alpha_\mu \delta_t \nabla \ln \pi(A_t|S_t, \vec \theta_{\mu t}, \vec \theta_{h t})
	\\
	\vec \theta_{h+1}
	&= \vec \theta_{h t}
	+ \alpha_h \delta_t \nabla \ln \pi(A_t|S_t, \vec \theta_{\mu t}, \vec \theta_{h t})
\end{align}

The policy gradient functions for $\vec \theta_\mu $ is
\begin{align*}
	\nabla \ln \pi(a|s,\vec \theta_\mu, \vec \theta_h)
	& = \pi^{-1}(a|s,\vec \theta_\mu, \vec \theta_h) \nabla \pi(a|s,\vec \theta_\mu, \vec \theta_h)
	\\
	& = \pi^{-1}(a|s,\vec \theta_\mu, \vec \theta_h) \frac{\partial \pi(a|s,\vec \theta_\mu, \vec \theta_h)}{\partial \mu(s, \vec \theta_\mu)} \nabla \mu(s, \vec \theta_\mu)
	\\
	\frac{\partial \pi(a|s,\vec \theta_\mu, \vec \theta_h)}{\partial \mu(s, \vec \theta_\mu)}
	& = - \frac{1}{\sigma^3(s, \vec \theta_h) \sqrt{2 \pi} } e^{-\frac{(a-\mu(s, \vec \theta_\mu))^2}{\sigma^2(s, \vec \theta_h)}} \frac{\partial }{\partial \mu(s,\vec \theta_\mu)} (a-\mu(s, \vec \theta_\mu))^2
	\\
	& = -\pi(a|s,\vec \theta_\mu, \vec \theta_h)  (-2) (a - \mu(s, \vec \theta_\mu)) \sigma^{-2}(s, \vec \theta_h)
	\\
	\nabla \ln \pi(a|s,\vec \theta_\mu, \vec \theta_h)
	& = \frac{2 [a - \mu(s, \vec \theta_\mu)]}{\sigma^2(s, \vec \theta_h)} \nabla \mu(s, \vec \theta_\mu)
\end{align*}
The policy gradient functions for $\vec \theta_h $ is
\begin{align*}
	\nabla \ln \pi(a|s,\vec \theta_\mu, \vec \theta_h )
	& = \pi^{-1}(a|s,\vec \theta_\mu, \vec \theta_h ) \nabla \pi(a|s,\vec \theta_\mu, \vec \theta_h)
	\\
	& = \pi^{-1}(a|s,\vec \theta_\mu, \vec \theta_h )
	\frac{\partial \pi(a|s,\vec \theta_\mu, \vec \theta_h )}{\partial h(s, \vec \theta_h)} \nabla h(s, \vec \theta_h)
	\\
	\frac{\partial \pi(a|s,\vec \theta_\mu, \vec \theta_h )}{\partial h(s, \vec \theta_h)}
	&= \frac{\partial \pi(a|s,\vec \theta_\mu, \vec \theta_h )}{\partial \sigma(s, \vec \theta_h)}
 	\frac{\partial \sigma(s, \vec \theta_h)}{\partial h(s, \vec \theta_h)}
	\\
	\frac{\partial \pi(a|s,\vec \theta_\mu, \vec \theta_h )}{\partial \sigma(s, \vec \theta_h)}
	& = \frac{
	\left\{
		\sigma(s,\vec \theta_h) \frac{\partial}{\partial \sigma(s,\vec \theta_h)}
		\left[
			e^{-\frac{(a-\mu(s, \vec \theta_\mu))^2}{\sigma^2(s,\vec \theta_h)}}
		\right]
		- e^{-\frac{(a-\mu(s, \vec \theta_\mu))^2}{\sigma^2(s, \vec \theta_h)}}
	\right\}}{\sigma^2(s,\vec \theta_h) \sqrt{2 \pi}}
	\\
	& = \frac{
	e^{-\frac{(a-\mu(s, \vec \theta_\mu))^2}{\sigma^2(s,\vec \theta_h)}}
	\left\{
		-\sigma(s,\vec \theta_h)
		(a-\mu(s,\vec \theta_\mu))^2
		\frac{\partial}{\partial \sigma(s,\vec \theta_h)}
		\left[
			\sigma^{-2}(s,\vec \theta_h)
		\right]
		- 1
	\right\} }{\sigma^2(s,\vec \theta_h) \sqrt{2 \pi}}
	\\
	& = \frac{\pi(a|s,\vec \theta_\mu, \vec \theta_h)}{\sigma(s,\vec \theta_h)}
	\left\{
		2 \frac{(a-\mu(s,\vec \theta_\mu))^2} {\sigma^2(s,\vec \theta_h)} - 1
	\right\}
	\\
	\frac{\partial \sigma(s,\vec \theta_h)}{\partial h(s,\vec \theta_h)}
	&= e^{h(s, \vec \theta_h)}
	\\
	&= \sigma(s, \vec \theta_h)
	\\
	\nabla \ln \pi(a|s,\vec \theta_\mu, \vec \theta_h )
	& = 2 \frac{(a-\mu(s,\vec \theta_\mu))^2} {\sigma^2(s,\vec \theta_h)} - 1
\end{align*}

Let be
\begin{align*}
	\delta_\mu(s, a, \vec \theta_\mu, \vec \theta_h )
	&= \delta_t 2 \frac{a - \mu(s, \vec \theta_\mu)}{\sigma^2(s, \vec \theta_h)}
	\\
	\delta_h(s, a, \vec \theta_\mu, \vec \theta_h )
	&= \delta_t
	\left[
		2 \frac{(a-\mu(s,\vec \theta_\mu))^2} {\sigma^2(s,\vec \theta_h)} - 1
	\right]
\end{align*}

The $ \vec \theta_\mu, \vec \theta_h $ parameters are updated by
\begin{align*}
	\vec \theta_{\mu t+1}
	&= \vec \theta_{\mu t} + \alpha_\mu \delta_\mu(S_t, A_t, \vec \theta_{\mu t}, \vec \theta_{h t} )
	\\
	\vec \theta_{h t+1}
	&= \vec \theta_{h t} + \alpha_h \delta_h(S_t, A_t, \vec \theta_{\mu t}, \vec \theta_{ht} )
\end{align*}

The same result is obtained by training the network with labels
\begin{align}
	\mu^*(S_t) = \mu(S_t,\vec \theta_{\mu t}) +
	\alpha_\mu \delta_\mu(S_t, A_t, \vec \theta_{\mu t}, \vec \theta_{ht})
	\\
	h^*(S_t) = h(S_t,\vec \theta_{\mu t}) +
\alpha_h \delta_h(S_t, A_t, \vec \theta_{\mu t}, \vec \theta_{ht})
\end{align}

\subsection{Learning process}

Initially the agent do not have any experience and the differential state value generated by the ANN starts from a random initial estimation. The same is for the behavior generated by the actors where the preferences are random initialized.

Since the very first interactions the agent generates wrong differential state value estimation with high value of TD Error. Consequently the agent easily changes the policy behavior, trying different policies with the exploration of both the policy and state space. It tries to improve the average reward, the value state estimation at the same time selecting better policies.

Different factors influence the learning process.
External agent factors like the number of states, actions and policies not yet explored tent to generate high error rate.
The error increases as the agent experiences new environment states or try new policies, but as the agent faces states already visited it can exploit the past experiences reducing the error and improving the state value estimation and the policy.

Instead the agent internal factor, such as the ANN approximation, generates errors that can be reduced only to a low-bound limit value.

The ANN learning parameters can influence both in the quality of approximated functions and in the  speed of adaptation.

High value of step-size parameter $ \eta $ increases the correction of weights increasing consequently the speed of adaptation, but can easily generate corrective value too big bringing the network to not converging behaviors.
On the other hand small value of step-size parameter weakens the correction of weights decreasing the speed of adaptation.

Also the actor parameters $ \alpha_i $, which modulate the policy changes from the critic, influence the improvement capacity.
High value of $ \alpha_i $ determine strong policy changes even in the face of small errors, making it difficult a fine correction, the other way around very small value of $ \alpha_a $ bring very little variations on policy without improvement.

If the actor parameters that govern the policy have a limited range of values we may choose an $ \alpha_i = \alpha^*_i $ so that the average of corrections is $ \varepsilon_i $ a fraction of the limited range.

For the discrete policy actors we calculate the average of squared preferences variations $ \Delta^2h_{i} $
\begin{align*}
	h^*_{ia}(t) - h_{ia}(t)&=	\Delta h_{ia}(t)
	\\
	&=	\alpha_i \delta_{h_{ia}}(t)
	\\
	\Delta^2h_{i}(t)&=			\frac{1}{m} \sum_a^m \Delta h_{ia}(t)
	\\
	\Delta^2h_{i}&=			\frac{1}{n} \sum_t^n \Delta^2 h_{i}(t)
	\\
	&=			\frac{1}{n}\frac{1}{m}\sum_t^n \sum_a^m \Delta^2 h_{ia}(t)
	\\
	&=	\alpha^2_i\frac{1}{n}\frac{1}{m}\sum_t^n \sum_a^m  \delta^2_{h_{ia}}(t)
	\\
	\Delta^2h_i &=	\varepsilon^2_i
	\\
	\alpha^*_i&=	\frac{\varepsilon_i}{\sqrt{\frac{1}{n} \frac{1}{m}\sum_t^n \sum_a^m \delta^2 h_{ia}(t)}}
\end{align*}
if $ \alpha_i $ is the value used in the session then
\begin{align}
	\alpha^*_i&=	\frac{\varepsilon_i}{\sqrt{\frac{1}{n} \frac{1}{m} \sum_t^n \sum_a^m \Delta^2 h_{ia}(t)}} \alpha_i
\end{align}

For the Gaussian policy actors we calculate the average of squared parameter variations $ \Delta^2\mu_i$ and $ \Delta^2 h_{i\sigma} $
\begin{align*}
	\mu^*_i(t) - \mu_i(t)&=	\Delta \mu_i(t)
	\\
	&=	\alpha_{i\mu} \delta_{i\mu}(t)
	\\
	\Delta^2\mu_{i}&=			\frac{1}{n} \sum_t^n \Delta^2 \mu_i(t)
	\\
	&=	\alpha^2_{i\mu}\frac{1}{n}\sum_t^n  \delta^2_{\mu_{i}}(t)
	\\
	\Delta^2\mu_i &=	\varepsilon^2_{i\mu}
	\\
	\alpha^*_{i\mu}&=	\frac{\varepsilon_{i\mu}}{\sqrt{\frac{1}{n} \sum_t^n \delta^2 \mu_i(t)}}
\end{align*}
if $ \alpha_{i\mu} $ is the value used in the session then
\begin{align}
	\alpha^*_{i\mu}&=	\frac{\varepsilon_{i\mu}}{\sqrt{\frac{1}{n} \sum_t^n  \Delta^2 \mu_i(t)}} \alpha_{i\mu}
\end{align}

\begin{align*}
	h^*_{i\sigma}(t) - h_{i\sigma}(t)&=	\Delta h_{i\sigma}(t)
	\\
	&=	\alpha_{i\sigma} \delta_{ih_\sigma}(t)
	\\
	\Delta^2h_{i\sigma}&=			\frac{1}{n} \sum_t^n \Delta^2 h_{i\sigma}(t)
	\\
	&=	\alpha^2_{i\sigma}\frac{1}{n}\sum_t^n  \delta^2_{ih_\sigma}(t)
	\\
	\Delta^2h_{i\sigma} &=	\varepsilon^2_{i\sigma}
	\\
	\alpha^*_{i\sigma}&=	\frac{\varepsilon_{i\sigma}}{\sqrt{\frac{1}{n} \sum_t^n \delta^2 h_{i\sigma}(t)}}
\end{align*}
if $ \alpha_{i\sigma} $ is the value used in the session then
\begin{align}
	\alpha^*_{i\sigma}&=	\frac{\varepsilon_{i\sigma}}{\sqrt{\frac{1}{n} \sum_t^n  \Delta^2 h_{i\sigma}(t)}} \alpha_{i\sigma}
\end{align}

\subsection{Performance}

The average reward is the main indicators of learning quality, since the agent interacts with the environment the average reward grows up.

Because the process is adaptive the average reward can vary a lot during the interaction with the environment therefore it is necessary to evaluate the trend of the indicator. The logarithmic regression can be used to evaluate the performance
\begin{align}
	r_\pi(t) & = \ln (mt + q)
\end{align}

An increasing trend indicates the agent is selecting better policies and is getting higher and higher rewards.
A decreasing trend indicates the agent is not selecting good policies, this may be caused by low $ \alpha_a $ or $ \eta $ parameters.

Another indicator of performance is the squared TD error, as for the average reward it is necessary to evaluated the trend.
The error has not negative values that should approach zero when the agent select the local best policy. The exponential regression can be used to evaluate the performance
\begin{align}
	\delta^2(t) & = e^{(mt + q)}
\end{align}

A decreasing trend indicates the estimation of value states is getting better.
An increasing trend indicates the estimation of value states is getting worse it may be caused by the ANN which cannot correct the estimation due to $ \eta $ parameter too high.

Both the critic and actors approximate the value function and policy function with neural network.
To monitor the learning activity of ANN we compute the MSE of estimated functions.

The ANN is feed with normalized values label $ O^*_i $ so that the values are in the range $ -1, +1 $ by linear transformation

\begin{align*}
	O_i &= (O_C, O_{Ai})
	\\
	O_C &= m_c \delta_t + q_c
	\\
	O_{Ai} &= m_{ai} \delta_{hi} + q_{ai}
\end{align*}

The MSE of ANN is
\begin{align*}
	J(t)&	= \sum_i [O^*_i(t) - O_i(t)]^2
\end{align*}
and the MSE after the training is
\begin{align*}
	J'(t)&	= \sum_i [O^*_i(t) - O'_i(t)]^2
\end{align*}

The ratio between the total MSE after and before the training activity indicates the quality of such activity.
\begin{align}
\begin{split}
	K(t)&	= \frac{J'(t)}{J(t)}
\end{split}
\end{align}

A ratio $ K(t) \ge 1 $ means the error after training gets worst due a step-size parameter $ \alpha $ too high.
A ratio $ K(t) = 1 $  means no change on error and therefore no improvement. This can be affected by a local minimum reached or a step-size parameter too low with very poor capacity of learning.
A ratio $ K(t) < 1 $ means an improvement of neural network due to correct step-size parameter.
A ratio $ K(t) = 0 $ means a perfect fit of neural network.

We can classify the steps in three class:
\begin{description}

	\item[$ C_0 $]
	The steps that created a bad approximation with an increased of MSE ($ J > \varepsilon \cup K > 1$)

	\item[$ C_1 $]
	The steps that create a trivial approximation with a small reduction of MSE ($ J > \varepsilon \cup K_0 \le K \le 1 $ with $ K_0 = 0.9$ )

	\item[$ C_2 $]
	The remaining steps that have a small MSE or that have reduced significantly the MSE
\end{description}

The ideal distribution should have

\begin{align}
\begin{split}
	C_0 & = 0
	\\
	C_1 & = 0
	\\
	C_2 & = 1
\end{split}
\end{align}

A step parameter $ \eta $ too high generates over correction increasing $ C_0 $ and reducing $ C_2 $.

An $ \eta $ parameter too small generates under corrections increasing $ C_1 $ and reducing $ C_2 $.

Because it is difficult to determine the effects of step parameter changes on the result MSE, an empirical way to reduce or increment the parameter is applied, for example increasing or reducing by exponential factors ($ \dots $, $ \times 0.01 $, $ \times 0.03 $, $ \times 0.1$, $\times 0.3 $, $ \times 3 $, $ \times 10 $, $ \times 30$, $\times 100 $, $ \dots $).

\begin{figure}[ht]
	\centering
	\includegraphics[width=\linewidth]{ann.png}
	\caption{Step classification}
	\label{fig:steps}
\end{figure}

\end{document}


%\section{Surface flux}
{\bf \Large
\begin{tabular}{ccc}
\hline
  Corresponding author & : & Seiya Nishizawa\\
\hline
\end{tabular}
}

\subsection{Monin-Obukhov similarity}
First of all, we assume that in the boundary layer
1. fluxes are constant, and 2. variables are horizontally uniform.

Relations between flux and vertical gradient are:
\begin{align}
  \frac{kz}{u_*} \frac{\partial u}{\partial z} &= \phi_m\left(\frac{z}{L}\right), \label{eq: flux-gradient u} \\
  \frac{kz}{\theta_*} \frac{\partial \theta}{\partial z} &= \phi_h\left(\frac{z}{L}\right), \label{eq: flux-gradient t} \\
  \frac{kz}{q_*} \frac{\partial q}{\partial z} &= \phi_q\left(\frac{z}{L}\right),
\end{align}
where $k$ is the Von Karman constant.
$L$ is the Monin-Obukhov scale height:
\begin{equation}
  L = \frac{\theta u_*^2}{kg\theta_*},
\end{equation}
where $g$ is gravity.
The scaling velocity, $u_*$, temperature, $\theta_*$,
and water vapor, $q_*$, are defined from the vertical eddy fluxes of momentum, sensible heat, and water vapor:
\begin{align}
  \overline{u'w'} &= -u_*u_*, \\
  \overline{w'\theta'} &= - u_*\theta_*, \\
  \overline{w'q'} &= - u_*q_*.
\end{align}

The integration between roughness length $z_0$ to height $z$ of the lowest model level, eqs. (\ref{eq: flux-gradient u}) and (\ref{eq: flux-gradient t}) becomes:
\begin{align}
  u(z) &= \frac{u_*}{k} \left\{\ln(z/z_0)-\Phi_m(z/L)+\Phi_m(z_0/L)\right\}, \\
  \Delta\theta &= R\frac{\theta_*}{k} \left\{\ln(z/z_0)-\Phi_h(z/L)+\Phi_h(z_0/L)\right\},
\end{align}
where $\Delta\theta = \theta-\theta_0$,
and
\begin{align}
  \Phi_m(z) = \int^z \frac{1-\phi_m(z')}{z'} dz', \\
  \Phi_h(z) = \int^z \frac{R-\phi_h(z')}{R z'} dz'.
\end{align}

\subsection{Louis’s (1979) Model}
Louis (1979) introduced a parametric model of vertical eddy fluxes.

The $L$ becomes:
\begin{equation}
  L = \frac{\theta u^2}{g\Delta\theta}
    \frac{\ln(z/z_0)-\Phi_h(z/L)+\Phi_h(z_0/L)}{\left\{\ln(z/z_0)-\Phi_m(z/L)+\Phi_m(z/L)\right\}^2}.
\end{equation}
The bulk Richardson number for the layer $Ri_B$ is:
\begin{equation}
  Ri_B = \frac{gz\Delta\theta}{\theta u^2},
\end{equation}
and its form implies a relationship with the Monin-Obukhov scale height $L$.
The fluxes can then be written as:
\begin{align}
  u_*^2 &= a^2 u^2 F_m\left(\frac{z}{z_0},Ri_B\right), \label{eq: u_*^2} \\
  u_*\theta_* &= \frac{a^2}{R} u \Delta \theta F_h\left(\frac{z}{z_0},Ri_B\right), \label{eq: u_*t_*}
\end{align}
where
$R$ is ratio of the drag coefficients for momentum and heat in the neutral limit(the turbulent Prandtl number),
and
\begin{equation}
  a^2 = \frac{k^2}{\left\{\ln\left(z/z_0\right)\right\}^2}
\end{equation}
is the drag coefficient under neutral conditions.

For unstable conditions ($Ri_B<0$),
$F_i$s ($i=m,h$) could be:
\begin{equation}
  F_i = 1 - \frac{b Ri_B}{1 + c_i \sqrt{|Ri_B|}},
  \label{eq: F_i unstable}
\end{equation}
under the consideration that
$F_i$ must behave as $1/u$ (i.e., $\sqrt{|Ri_B|}$) in the free convection limit ($u \to 0$) and becomes $1$ under neutral conditions ($Ri_B \to 0$).
On the other hand, under stable conditions ($Ri_b$), Louis (1979) adopted the following form for $F_i$:
\begin{equation}
  F_i = \frac{1}{(1 + b' Ri_B)^2}.
  \label{eq: F_i stable}
\end{equation}

The constants are estimated as $R=0.74$ by Businger et al. (1971),
and $b=2b'=9.4$ by Louis (1979).
By dimensional analysis:
\begin{equation}
  c_i = C^*_i a^2 b \sqrt{\frac{z}{z_0}},
\end{equation}
and $C^*_m = 7.4, C^*_h = 5.3$, which result best fits curves.

\subsection{Uno et al.’s (1995) Model}
Uno et al. (1995) extended the Louis Model,
considering differences in roughness lengths related to momentum and temperature, i.e., $z_0$ and $z_t$, respectively.

The potential temperature difference between $z=z$ and $z=z_t$,
$\Delta\theta_t$, is:
\begin{align}
  \Delta\theta_t
  &= R\frac{\theta_*}{k}\left\{\ln(z_0/z_t) - \Phi_h(z_0/L) + \Phi_h(z_t/L)\right\} + \Delta\theta_0, \nonumber \\
  &= R\frac{\theta_*}{k}{\ln(z_0/z_t)} + \Delta\theta_0, \nonumber \\
  &= \Delta\theta_0 \left\{\frac{R\ln(z_0/z_t)}{\Psi_h} + 1\right\},
\end{align}
where $\Delta\theta_0 = \theta_z - \theta_{z_0} (=\Delta\theta)$:
\begin{equation}
  \Psi_h = \int_{z_0}^z\frac{\phi_h}{z'}dz', \label{eq: Psi_h}
\end{equation}
and $\phi_h$ is assumed to be $R$ in the range $z_t < z < z_0$.
Thus:
\begin{equation}
  \Delta\theta_0 = \Delta\theta_t \left\{\frac{R\ln(z_0/z_t)}{\Psi_h}+1\right\}^{-1},
  \label{eq: Delta t_0}
\end{equation}
or equivalently,
\begin{equation}
  Ri_{B0} = Ri_{Bt} \left\{\frac{R\ln(z_0/z_t)}{\Psi_h}+1\right\}^{-1}.
  \label{eq: Ri_B0}
\end{equation}

From eqs. (\ref{eq: u_*^2}) and (\ref{eq: u_*t_*}):
\begin{equation}
  \Delta\theta_0 = \frac{R\theta_*}{k}\ln\left(\frac{z}{z_0}\right)\frac{\sqrt{F_m}}{F_h},
\end{equation}
while
\begin{equation}
  \Delta\theta_0 = \frac{\theta_*}{k}\Psi_h,
\end{equation}
from eqs. (\ref{eq: flux-gradient t}) and (\ref{eq: Psi_h}).
Therefore:
\begin{equation}
  \Psi_h = R\ln\left(\frac{z}{z_0}\right)\frac{\sqrt{F_m}}{F_h}.
  \label{eq: Psi}
\end{equation}

Because $\Psi_h$ depends on $Ri_{B0}$,
$Ri_{B0}$ cannot be calculated from $Ri_{Bt}$ with eq. (\ref{eq: Ri_B0})
directly, so numerical iteration is required to obtain $Ri_{B0}$
\footnote{In the stable case, it can be solved analytically
with eq. (\ref{eq: F_i stable}), but the solution is too complicated.}.
Starting from $Ri_{Bt}$ as the first estimation of $Ri_{B0}$,
the second estimate by the Newton-Raphson iteration becomes:
\begin{equation}
  \hat{Ri}_{B0} = Ri_{Bt} - \frac{Ri_{Bt}R\ln(z_0/z_t)}{\ln(z_0/z_t) + \hat{\Psi}_h},
  \label{eq: Ri_B0 estimation}
\end{equation}
where $\hat{\Psi}_h$ is the estimate of $\Psi_h$ using $Ri_{Bt}$ instead of $Ri_{B0}$.
Approximate values for $F_m, F_h$, and $\Psi_h$ are re-calculated
based on the $\hat{Ri}_{B0}$, and then $\Delta\theta_0$, and the surface fluxes $u_*^2$ and $u_*\theta_*$ are calculated from eqs. (\ref{eq: Delta t_0}), (\ref{eq: u_*^2}), and (\ref{eq: u_*t_*}), respectively.

\subsection{Discretization}

\def\half{\frac{1}{2}}

All the fluxes are calculated based on the velocity at the first full-level (k=1)
($z=\Delta z/2$).
The absolute velocities $U$ are:
\begin{align}
  U_{i+\half,j,1}^2 &=
    \left\{\frac{2(\rho u)_{i+\half,j,1}}{\rho_{i,j,1}+\rho_{i+1,j,1}}\right\}^2
  + \left\{\frac{(\rho v)_{i,j-\half,1} + (\rho v)_{i,j+\half,1} + (\rho v)_{i+1,j-\half,1} + (\rho v)_{i+1,j+\half,1}}{2(\rho_{i,j,1}+\rho_{i+1,j,1})}\right\}^2 \nonumber \\
 &+ \left\{\frac{(\rho w)_{i,j,1+\half} + (\rho w)_{i+1,j,1+\half}}{2(\rho_{i,j,1}+\rho_{i+1,j,1})}\right\}^2, \\
  U_{i,j+\half,1}^2 &=
    \left\{\frac{(\rho u)_{i-\half,j,1} + (\rho u)_{i+\half,j,1} + (\rho u)_{i-\half,j+1,1} + (\rho u)_{i+\half,j+1,1}}{2(\rho_{i,j,1}+\rho_{i,j+1,1})}\right\}^2 \nonumber\\
 &+ \left\{\frac{2(\rho v)_{i,j+\half,1}}{\rho_{i,j,1}+\rho_{i,j+1,1}}\right\}^2
  + \left\{\frac{(\rho w)_{i,j,1+\half} + (\rho w)_{i,j+1,1+\half}}{2(\rho_{i,j,1}+\rho_{i,j+1,1})}\right\}^2, \\
  U_{i,j,1}^2 &=
    \left\{\frac{(\rho u)_{i-\half,j,1} + (\rho u)_{i+\half,j,1}}{2\rho_{i,j,1}}\right\}^2
  + \left\{\frac{(\rho v)_{i,j-\half,1} + (\rho v)_{i,j+\half,1}}{2\rho_{i,j,1}}\right\}^2
  + \left\{\frac{(\rho w)_{i,j,1+\half}}{2\rho_{i,j,1}}\right\}^2,
\end{align}
It is here of note that $(\rho w)_{i,j,\half}=0$.
The potential temperatures $\theta$ are:
\begin{align}
  \theta_{i,j,1} &= \frac{(\rho \theta)_{i,j,1}}{\rho_{i,j,1}}, \\
  \bar{\theta}_{i+\half,j,1} &= \frac{\theta_{i,j,1}+\theta_{i+1,j,1}}{2}, \\
  \bar{\theta}_{i,j+\half,1} &= \frac{\theta_{i,j,1}+\theta_{i,j+1,1}}{2}.
\end{align}

The roughness lengths, $z_0, z_t$, and $z_q$ are calculated from
eqs. (\ref{eq: z_0}), (\ref{eq: z_t}), and (\ref{eq: z_q}),
in which the friction velocity $u_*$ is estimated as:
\begin{equation}
  u_* = \sqrt{C_{m0}} U,
\end{equation}
where $C_{m0}$ is a constant bulk coefficient,
and we use $1.0 \times 10^{-3}$ as its value.

From eq. (\ref{eq: Ri_B0}), the $Ri_{Bt}$, which is the first guess of the $Ri_{B0}$, is:
\begin{equation}
  Ri_{Bt} = \frac{gz_1(\theta_1-\theta_{sfc})}{\bar{\Theta}U^2},
\end{equation}
with the assumption that $\theta_{z_t} = \theta_{sfc}$.
The estimation of $\hat{\Psi}_h$ is calculated with $Ri_{Bt}$ from
eqs. (\ref{eq: Psi}), (\ref{eq: F_i unstable}), and (\ref{eq: F_i stable}).
The final estimation of $Ri_{B0}$ is obtained from eq. (\ref{eq: Ri_B0 estimation}),and the final estimation of $\Psi_h$ is obtained with $Ri_{B0}$.

Now we can calculate the bulk coefficients, $C_m, C_h$, and $C_e$ for moments, heat, and vapor:
\begin{align}
  C_m &= \frac{k^2}{\ln(z_1/z_0)}F_m(Ri_{B0}), \\
  C_h &= \frac{k^2}{R\ln(z_1/z_0)}F_h(Ri_{B0})\left\{\frac{R\ln(z_0/z_t)}{\Psi_h}+1\right\}^{-1}, \\
  C_e &= \frac{k^2}{R\ln(z_1/z_0)}F_h(Ri_{B0})\left\{\frac{R\ln(z_0/z_e)}{\Psi_h}+1\right\}^{-1}.
\end{align}
The fluxes are:
\begin{align}
  \overline{\rho u'w'} &= - C_m U \rho u, \\
  \overline{\rho v'w'} &= - C_m U \rho v, \\
  \overline{\rho w'w'} &= - C_m U \rho w, \\
  \overline{\rho \theta'w'} &= - C_h U \{\rho \theta - \rho \theta_{sfc}\}, \\
  \overline{\rho q'w'} &= -C_e U \rho ( q - q_{evap} ),
\end{align}
where $q_{evap}$ is the saturation value at the surface.


\section{M/D/1 Queues}
\label{sec:M-D-1-queues}

A $M/D/1$ is a queue where
(i) the arrival process is Poissonian with rate $\lambda$,
(ii) the service process is deterministic,
(iii) there is one servers,
(iv) the buffer has infinite capacity,
(v) the scheduling policy is FCFS.

\begin{figure}[tp]
\label{fig:M-D-1-queue}
	\centering
	\includegraphics{fig/M-D-1-Queue}
	\caption{An M/D/1 queue and its corresponding CTMC.}
	\end{figure}


\input{../../../doc/latex/Styles/wpg_notation_define.tex}
\chapter{WPG v.04}

This version of the pattern generator is based on triple integrator with
piece-wise constant \acs{CoP} velocity. The control input is position of the
\acs{CoP}. Apart from that it is very similar to the \acs{WPG} proposed in
\cite{Herdt2010auro}, for more information refer to \cite{Sherikov2016phd}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Variables}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Footstep positions}
Any preview horizon contains $1$ fixed and $0$ or more variable footstep
positions.  Let $M$ be the number of variable steps in the preview horizon,
$\FRAME{p_j}$ -- frame fixed to $j$-th footstep with $j = 0 \dots M$ ($0$-th
footstep is fixed), $\fp_j = (p^x_j, p^y_j)$ -- position of the $j$-th footstep
on the ground plane.

Coordinate transformation matrix from the frame fixed to the $j$-th footstep to
the global frame is defined as
%
\begin{equation}
    \M[p_j][]{R} =
    \begin{bmatrix}
        \cos{\theta_j}  &   -\sin{\theta_j} \\
        \sin{\theta_j}  &   \cos{\theta_j} \\
    \end{bmatrix}
\end{equation}
%
Orientations $\theta_j$ of the footsteps are predetermined to avoid
nolinearity. Position of the $j$-th footstep in the global frame can be found
as
%
\begin{equation}
    \fp_j = \fp_0 + \sum_{i=1}^{j}  \M[p_{i-1}][]{R} \fp[p_{i-1}]_j,
\end{equation}
%
which leads to
%
\begin{equation}
    \begin{bmatrix}
        \fp_0\\
        \fp_1\\
        \vdots\\
        \fp_M\\
    \end{bmatrix}
    =
    \V{1}_M
    \kron
%    \begin{bmatrix}
%        \M{I}\\
%        \M{I}\\
%        \vdots\\
%        \M{I}\\
%    \end{bmatrix}
    \fp_0
    +
    \begin{bmatrix}
        \M{0}           & \M{0}             & \dots & \M{0}             \\
        \M[p_{0}][]{R}  & \M{0}             & \dots & \M{0}             \\
        \vdots          & \vdots            & \dots & \vdots            \\
        \M[p_{0}][]{R}  & \M[p_{1}][]{R}    & \dots & \M[p_{M-1}][]{R}  \\
    \end{bmatrix}
    \begin{bmatrix}
        \fp[p_0]_1\\
        \vdots\\
        \fp[p_{M-1}]_M\\
    \end{bmatrix}.
\end{equation}
%
It is preferable to express variable footstep positions in a frame fixed to the
preceding footstep in order to impose simple bounds on variable footstep
positions.

The number of sampling intervals in the preview horizon is denoted by $N \ge
M$. The footstep position corresponding to $k$-th ($k = 1,\dots,N$) sampling
interval is denoted as $\fph_k = (\hat{p}^x_k, \hat{p}^y_k)$. These positions
can be found using a selection matrices as
%
\begin{equation}
\begin{split}
    \underbrace{
    \begin{bmatrix}
        \fph_1 \\
        \vdots \\
        \fph_N
    \end{bmatrix}
    }_{\FPh}
    & =
    \underbrace{
    \begin{bmatrix}
        \M{I}   &  \M{0}   &   \dots   &   \M{0} \\
        \M{I}   &  \M{0}   &   \dots   &   \M{0} \\
        \M{0}   &  \M{I}   &   \dots   &   \M{0} \\
        \M{0}   &  \M{I}   &   \dots   &   \M{0} \\
        \M{0}   &  \M{I}   &   \dots   &   \M{0} \\
        \vdots  &  \vdots  &   \ddots  &   \vdots \\
        \M{0}   &  \M{0}   &   \dots   &   \M{I} \\
    \end{bmatrix}
    }_{\M{I}_{\mathit{fps}}}
    \begin{bmatrix}
        \fp_0 \\
        \fp_1 \\
        \vdots\\
        \fp_M \\
    \end{bmatrix}
    =
    \begin{bmatrix}
        \M{I}   \\
        \M{I}   \\
        \M{0}   \\
        \M{0}   \\
        \M{0}   \\
        \vdots  \\
        \M{0}   \\
    \end{bmatrix}
    \fp_0
    +
    \begin{bmatrix}
        \M{0}   &   \dots   &   \M{0} \\
        \M{0}   &   \dots   &   \M{0} \\
        \M{I}   &   \dots   &   \M{0} \\
        \M{I}   &   \dots   &   \M{0} \\
        \M{I}   &   \dots   &   \M{0} \\
        \vdots  &   \ddots  &   \vdots \\
        \M{0}   &   \dots   &   \M{I} \\
    \end{bmatrix}
    \begin{bmatrix}
        \fp_1 \\
        \vdots\\
        \fp_M\\
    \end{bmatrix}\\
    & =
%    \underbrace{
%    \begin{bmatrix}
%        \M{I}   \\
%        \M{I}   \\
%        \M{I}   \\
%        \M{I}   \\
%        \M{I}   \\
%        \vdots  \\
%        \M{I}   \\
%    \end{bmatrix}
%    }_{\M{V}_0}
    \underbrace{
        \V{1}_N
        \kron
        \fp_0
    }_{\V{V}_0}
    +
    \underbrace{
    \begin{bmatrix}
        \M{0}   &   \dots   &   \M{0} \\
        \M{0}   &   \dots   &   \M{0} \\
        \M{I}   &   \dots   &   \M{0} \\
        \M{I}   &   \dots   &   \M{0} \\
        \M{I}   &   \dots   &   \M{0} \\
        \vdots  &   \ddots  &   \vdots \\
        \M{0}   &   \dots   &   \M{I} \\
    \end{bmatrix}
    \begin{bmatrix}
        \M[p_{0}][]{R}  & \M{0}             & \dots & \M{0}             \\
        \vdots          & \vdots            & \dots & \vdots            \\
        \M[p_{0}][]{R}  & \M[p_{1}][]{R}    & \dots & \M[p_{M-1}][]{R}  \\
    \end{bmatrix}
    }_{\M{V}}
    \underbrace{
    \begin{bmatrix}
        \fp[p_0]_1\\
        \vdots\\
        \fp[p_{M-1}]_M\\
    \end{bmatrix}
    }_{\FP},
\end{split}
\end{equation}
%
where $\M{V}$ has the following structure
%
\begin{equation}
    \M{V}
    =
    \begin{bmatrix}
        \M{0}           &   \dots   &   \M{0} \\
        \M{0}           &   \dots   &   \M{0} \\
        \M[p_{0}][]{R}  &   \dots   &   \M{0} \\
        \M[p_{0}][]{R}  &   \dots   &   \M{0} \\
        \M[p_{0}][]{R}  &   \dots   &   \M{0} \\
        \vdots          &   \ddots  &   \vdots \\
        \M[p_{0}][]{R}  &   \dots   &   \M[p_{M-1}][]{R} \\
    \end{bmatrix}
    =
    \underbrace{
        \begin{bmatrix}
            \M{0}   &   \dots   &   \M{0} \\
            \M{0}   &   \dots   &   \M{0} \\
            \M{I}   &   \dots   &   \M{0} \\
            \M{I}   &   \dots   &   \M{0} \\
            \M{I}   &   \dots   &   \M{0} \\
            \vdots  &   \ddots  &   \vdots \\
            \M{I}   &   \dots   &   \M{I} \\
        \end{bmatrix}
    }_{\M{I}_R \kron \M{I}}
    \diag{k = 0...M-1}{ \M[p_{k}][]{R} }
\end{equation}
%
where
%
\begin{equation}
    \M{I}_R
    =
    \begin{bmatrix}
        0   &   \dots   &   0 \\
        0   &   \dots   &   0 \\
        1   &   \dots   &   0 \\
        1   &   \dots   &   0 \\
        1   &   \dots   &   0 \\
        \vdots  &   \ddots  &   \vdots \\
        1   &   \dots   &   1 \\
    \end{bmatrix}.
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Positions of the CoP}
Position of the center of pressure in the end of $k$-th ($k = 1,\dots,N$)
sampling interval is denoted as $\cop_k = (z^x_k, z^y_k)$. The current
\acs{CoP} position is $\cop_0$. In order to obtain simple bounds on the
\acs{CoP} positions instead of general constraints, their positions are
expressed in the local frames fixed to the respective feet, \emph{i.e.}
%
\begin{equation}
    \cop_k = \fph_k + \M[\hat{p}_k][]{R} \cop[\hat{p}_k]_k.
\end{equation}
%
Orientation matrices $\M[\hat{p}_k][]{R}$ can also be selected with
$\M{I}_{\mathit{fps}}$
%
\begin{equation}
    \begin{bmatrix}
        \M[\hat{p}_1][]{R}\\
        \vdots\\
        \M[\hat{p}_N][]{R}\\
    \end{bmatrix}
    =
    \M{I}_{\mathit{fps}}
    \begin{bmatrix}
        \M[p_0][]{R}\\
        \vdots\\
        \M[p_M][]{R}\\
    \end{bmatrix}
\end{equation}
%
All positions of the \acs{CoP} within the preview horizon are
%
\begin{equation}
    \begin{split}
        \begin{bmatrix}
            \cop_1 \\
            \vdots \\
            \cop_N \\
        \end{bmatrix}
        & =
        \FPh
        +
        \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        \underbrace{
        \begin{bmatrix}
            \cop[\hat{p}_1]_1 \\
            \vdots \\
            \cop[\hat{p}_N]_N \\
        \end{bmatrix}
        }_{\V{Z}}
        =
        \M{V}_0
        +
        \M{V} \FP
        +
        \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        \CoP\\
        & =
        \V{1}_N
        \kron
        \fp_0
        +
        \left(
            \M{I}_R \kron \M{I}
        \right)
        \diag{k = 0...M-1}{ \M[p_{k}][]{R} }
        \FP
        +
        \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        \CoP
    \end{split}
\end{equation}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Model of the system}

The model has the following form
%
\begin{align}
    \cstate_{k+1} =& \M{A} \cstate_k + \M{B} \cop_{k+1}\\
    \dcop_k =& \M{D} \cstate_k + \M{E} \cop_{k+1}.
\end{align}
%

After condensing we obtain
%
\begin{align}
    \begin{bmatrix}
        \cstate_1 \\
        \vdots\\
        \cstate_{N}\\
    \end{bmatrix}
    =&
    \M{U}_x \cstate_0
    +
    \M{U}_u
    \begin{bmatrix}
        \cop_1 \\
        \vdots \\
        \cop_N \\
    \end{bmatrix} \\
%
    \underbrace{
    \begin{bmatrix}
        \dcop_0 \\
        \vdots\\
        \dcop_{N-1}\\
    \end{bmatrix}
    }_{\dCoP}
    =&
    \M{O}_x \cstate_0
    +
    \M{O}_u
    \begin{bmatrix}
        \cop_1 \\
        \vdots \\
        \cop_N \\
    \end{bmatrix} \\
\end{align}
%
or
%
\begin{align}
    \cState
    =&
    \M{U}_x \cstate_0
    +
    \M{U}_u
    \left(
        \M{V}_0
        +
        \M{V} \FP
        +
        \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        \CoP
    \right)\\
%
    \dCoP
    =&
    \M{O}_x \cstate_0
    +
    \M{O}_u
    \left(
        \M{V}_0
        +
        \M{V} \FP
        +
        \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        \CoP
    \right)\\
\end{align}
%

The unknowns $\CoP$ and $\FP$ can be grouped together
%
\begin{align}
    \cState
    =&
    \underbrace{
    \begin{bmatrix}
        \M{U}_u \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}   &   \M{U}_u \M{V} \\
    \end{bmatrix}
    }_{\M{S}}
    \underbrace{
    \begin{bmatrix}
        \CoP\\
        \FP\\
    \end{bmatrix}
    }_{\V{X}}
    +
    \underbrace{
    \M{U}_x \cstate_0
    +
    \M{U}_u \M{V}_0
    }_{\V{s}}\\
%
    \dCoP
    =&
    \underbrace{
    \begin{bmatrix}
        \M{O}_u \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}   &   \M{O}_u \M{V} \\
    \end{bmatrix}
    }_{\M{S}_{\dot{z}}}
    \underbrace{
    \begin{bmatrix}
        \CoP\\
        \FP\\
    \end{bmatrix}
    }_{\V{X}}
    +
    \underbrace{
    \M{O}_x \cstate_0
    +
    \M{O}_u \M{V}_0
    }_{\V{s}_{\dot{z}}}\\
\end{align}
%
or
%
\begin{align}
    \cState
    =&
    \begin{bmatrix}
        \left(\M{I} \bkron \M{U}_u^x \right) \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        &
        \left(\M{I} \bkron \M{U}_u^x \right)
        \left(
            \M{I}_R \kron \M{I}
        \right)
        \diag{k = 0...M-1}{ \M[p_{k}][]{R} }\\
    \end{bmatrix}
    \V{X}
    \\
    &
    +
    \left(\M{I} \bkron \M{U}_x^x \right)
    \cstate_0
    +
    \left(\M{I} \bkron \M{U}_u^x \right)
    \left(\V{1}_N \kron \fp_0 \right)
    \\
    =&
    \begin{bmatrix}
        \left(\M{I} \bkron \M{U}_u^x \right) \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        &
        \left(
            \M{I}
            \bkron
            \left(
                \M{U}_u^x
                \M{I}_R
            \right)
        \right)
        \diag{k = 0...M-1}{ \M[p_{k}][]{R} }\\
    \end{bmatrix}
    \V{X}
    \\
    &
    +
    \left(\M{I} \bkron \M{U}_x^x \right)
    \cstate_0
    +
    \left(
        \M{I}
        \bkron
        \left(
            \M{U}_u^x
            \V{1}_N
        \right)
    \right)
    \fp_0
    \\
\end{align}
%
and
%
\begin{align}
    \dCoP
    =&
    \begin{bmatrix}
        \left(\M{I} \bkron \M{O}_u^x \right) \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        &
        \left(\M{I} \bkron \M{O}_u^x \right)
        \left(
            \M{I}_R \kron \M{I}
        \right)
        \diag{k = 0...M-1}{ \M[p_{k}][]{R} }\\
    \end{bmatrix}
    \V{X}
    \\
    &
    +
    \left(\M{I} \bkron \M{U}_x^x \right) \cstate_0
    +
    \left(\M{I} \bkron \M{O}_u^x \right)
    \left(\V{1}_N \kron \fp_0 \right)
    \\
    = &
    \begin{bmatrix}
        \left(\M{I} \bkron \M{O}_u^x \right) \diag{k = 1 \dots N}{\M[\hat{p}_k][]{R}}
        &
        \left(
            \M{I}
            \bkron
            \left(
                \M{O}_u^x
                \M{I}_R
            \right)
        \right)
        \diag{k = 0...M-1}{ \M[p_{k}][]{R} }\\
    \end{bmatrix}
    \V{X}
    \\
    &
    +
    \left(\M{I} \bkron \M{U}_x^x \right) \cstate_0
    +
    \left(
        \M{I}
        \bkron
        \left(
            \M{O}_u^x
            \V{1}_N
        \right)
    \right)
    \fp_0
    \\
\end{align}
%

Velocity of the \acs{CoM} can be expressed as
%
\begin{equation}
    \cVel =
        \diag{N}{\M{I}_{v}} \cState =
        \diag{N}{\M{I}_{v}} \left( \M{S}\V{X} + \V{s} \right)=
        \M{S}_v \V{X} + \V{s}_v
\end{equation}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Constraints}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{CoP positions}
Simple bounds in the case when supports are rectangular.

\begin{equation}
    \ubarV{z}_k \le \cop[\hat{p}_k]_k \le \barV{z}_k, \quad k = 1 \dots N\\
\end{equation}

\begin{equation}
    \ubarV{Z} \le \CoP \le \barV{Z}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Foot positions}
Simple bounds when feasible regions are rectangular.

\begin{equation}
    \ubarV{p}_j \le \fp[p_{j-1}]_j \le \barV{p}_j, \quad j = 1 \dots M
\end{equation}

\begin{equation}
    \ubarV{P} \le \FP \le \barV{P}
\end{equation}

Only initial and final double supports are handled, the respective constraints
can also be represented as simple bounds provided that the feet are aligned.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Objectives}
Three objectives are minimized: difference between the actual and reference
\acs{CoM} velocity
%
\begin{equation}
    \NORME{\cVel - \cVel_{ref}} = \NORME{\M{S}_v \V{X} + \V{s}_v - \cVel_{ref}},
\end{equation}
%
the \acs{CoP} velocity
%
\begin{equation}
    \NORME{\dCoP} = \NORME{\M{S}_{\dot{z}} \V{X} + \V{s}_{\dot{z}}},
\end{equation}
%
distance between the \acs{CoP} positions and the centers of the feet
%
\begin{equation}
    \NORME{\CoP}.
\end{equation}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{QP}
\begin{equation}
\begin{split}
    \MINIMIZE{\CoP, \FP}  & \frac{\alpha}{2} \NORM{\cVel - \cVel_{ref}}^2 +
                              \frac{\beta}{2}  \NORM{\dCoP}^2 +
                              \frac{\gamma}{2} \NORM{\CoP}^2\\
    \SUBJECTTO          & \ubarV{Z} \le \CoP \le \barV{Z} \\
                        & \ubarV{P} \le \FP \le \barV{P}
\end{split}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Reference velocity}
\begin{equation}
\begin{split}
    &\NORM{\cVel - \cVel_{ref}}^2
    =
    \NORM{\M{S}_v \V{X} + \V{s}_v   -  \cVel_{ref}}^ 2
    = \\
    &
    \V{X}^T \M{S}_v^T \M{S}_v \V{X}
    +
    \V{X}^T \M{S}_v^T \V{s}_v
    -
    \V{X}^T \M{S}_v^T \cVel_{ref}\\
    &
    +
    \V{s}_v^T \M{S}_v \V{X}
    +
    \cancel{\V{s}_v^T \V{s}_v}
    -
    \cancel{\V{s}_v^T \cVel_{ref}} \\
    &
    -
    \cVel_{ref}^T \M{S}_v \V{X}
    -
    \cancel{\cVel_{ref}^T \V{s}_v}
    +
    \cancel{\cVel_{ref}^T \cVel_{ref}}
\end{split}
\end{equation}

Omitting the  constant terms we obtain
\begin{equation}
    \frac{\alpha}{2} \V{X}^T \M{S}_v^T \M{S}_v \V{X}
    -
    \alpha \cVel_{ref}^T \M{S}_v \V{X}
    +
    \alpha \V{s}^T_v \M{S}_v \V{X}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{CoP velocity}
\begin{equation}
    \NORM{\dCoP}^2 =
    \NORM{\M{S}_{\dot{z}} \V{X} + \V{s}_{\dot{z}}}^2 =
        \V{X}^T \M{S}_{\dot{z}}^T \M{S}_{\dot{z}} \V{X}
        +
        \V{X}^T \M{S}_{\dot{z}}^T \V{s}_{\dot{z}}
        +
        \V{s}_{\dot{z}}^T \M{S}_{\dot{z}} \V{X}
        +
        \cancel{\V{s}_{\dot{z}}^T \V{s}_{\dot{z}}}
\end{equation}

Omitting the constant terms we obtain
\begin{equation}
    \frac{\beta}{2}
    \V{X}^T \M{S}_{\dot{z}}^T \M{S}_{\dot{z}} \V{X}
    +
    \beta
    \V{s}_{\dot{z}}^T \M{S}_{\dot{z}} \V{X}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Displacement from the reference CoP}
\begin{equation}
    \frac{\gamma}{2} \NORM{\CoP}^2
        = \frac{\gamma}{2} \CoP^T \CoP
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Objective in the matrix form}
\begin{equation}
\begin{split}
    \MINIMIZE{\V{X}}    & \frac{1}{2} \V{X}^T\M{H}\V{X} + \V{h}^T \V{X}
\end{split}
\end{equation}

\begin{equation}
    \M{H} =
        \alpha \M{S}_v^T \M{S}_v
        +
        \beta  \M{S}_{\dot{z}}^T \M{S}_{\dot{z}}
        +
        \gamma
            \begin{bmatrix}
                \M{0} & \M{0} & \M{0}\\
                \M{0} & \M{I} & \M{0}\\
                \M{0} & \M{0} & \M{0}\\
            \end{bmatrix}\\
\end{equation}

\begin{equation}
    \V{h} =
        -
        \alpha \cVel_{ref}^T \M{S}_v
        +
        \alpha \V{s}_v^T \M{S}_v
        +
        \beta  \V{s}_{\dot{z}}^T \M{S}_{\dot{z}}
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Hierarchical least squares problem}
\begin{description}
    \item[Level 1:]
        \begin{equation}
        \begin{split}
            & \ubarV{Z} \le \CoP \le \barV{Z} \\
            & \ubarV{P} \le \FP \le \barV{P}
        \end{split}
        \end{equation}

    \item[Level 2:]
        \begin{equation}
        \begin{split}
            & \sqrt{\frac{\alpha}{2}} \M{S}_v \V{X} = \sqrt{\frac{\alpha}{2}} \left(\cVel_{ref} - \V{s}_v\right) \\
            & \sqrt{\frac{\beta}{2}} \M{S}_{\dot{z}} \V{X} = \sqrt{\frac{\beta}{2}} \V{s}_{\dot{z}}\\
            & \sqrt{\frac{\gamma}{2}} \CoP = 0\\
        \end{split}
        \end{equation}
\end{description}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Swing foot trajectory}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Polynomial and boundary conditions}
Trajectory is generated using cubic polynomial of the form
\begin{equation}
    at^3 + bt^2 + ct + d = y_{swing},
\end{equation}
where $t$ is time instance; $a,b,c,d$ are coefficients; and $y_{swing}$ is position of the swing
foot at time $t$.

Derivatives of the cubic polynomial are
\begin{equation}
\begin{split}
    & 3at^2 + 2bt + c = \dot{y}_{swing},\\
    & 6at + 2b = \ddot{y}_{swing},\\
    & 6a = \dddot{y}_{swing}.\\
\end{split}
\end{equation}

There are four boundary conditions for the polynomial, the first two are defined for
the current swing foot state at $t_i = 0$:
\begin{equation}\label{wpg04.eq.swtraj_bc1}
\begin{split}
    & d = y_{swing,i}, \\
    & c = \dot{y}_{swing,i}, \\
\end{split}
\end{equation}
where $y_{swing,i}$ and $\dot{y}_{swing,i}$ are initial position and velocity; the other two
conditions for landing time instance $t_f$ are:
\begin{equation}\label{wpg04.eq.swtraj_bc2}
\begin{split}
    & at_f^3 + bt_f^2 + ct_f + d = y_{swing,f},\\
    & 3at^2 + 2bt + c = \dot{y}_{swing,f},\\
\end{split}
\end{equation}
where $y_{swing,f}$ and $\dot{y}_{swing,f}$ are final position and velocity.
Trajectories along $z$ axis and $x,y$ axes are computed separately. Final position
$y_{swing,f}^z$ for trajectory along $z$ axis is set to the step height during the first
half of the support and to $0$ during the second half:
\begin{equation}
    y_{swing,f}^z =
    \left\{
        \begin{array}{ll}
            h_{step}    & t \le \frac{1}{2}T_{support}; \\
            0           & t > \frac{1}{2}T_{support}. \\
        \end{array}
    \right.
\end{equation}
The final $x,y$ positions are set to the next landing position computed as
\begin{equation}
    \begin{bmatrix}
        y_{swing,f}^x\\
        y_{swing,f}^y\\
    \end{bmatrix}
    =
    \M{V}_{land}\FP,
\end{equation}
where
\begin{equation}
    \M{V}_{land} =
    \begin{bmatrix}
        \M[p_0][]{R} & \M{0}
    \end{bmatrix}.
\end{equation}
Velocity at the end of trajectory is set to zero.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Computation of the desired acceleration}

Whole body control requires current acceleration (at time $t_i$) of the swing foot,
which can be found as
\begin{equation}\label{wpg04.eq.swtraj_acc1}
    2b = \ddot{y}_{swing,i}.
\end{equation}
Hence it is necessary to find coefficient $b$ from equations~\eqref{wpg04.eq.swtraj_bc1}
and~\eqref{wpg04.eq.swtraj_bc2}.

Substitution of~\eqref{wpg04.eq.swtraj_bc1} to~\eqref{wpg04.eq.swtraj_bc2} using $\dot{y}_{swing,f} = 0$
yields
\begin{equation}\label{wpg04.eq.swtraj_bc3}
\begin{split}
    & at_f^3 + bt_f^2 + \dot{y}_{swing,i}t_f + y_{swing,i} = y_{swing,f},\\
    & 3at_f^2 + 2bt_f + \dot{y}_{swing,i} = 0.\\
\end{split}
\end{equation}

Trivial algebraic operations on~\eqref{wpg04.eq.swtraj_bc3} and~\eqref{wpg04.eq.swtraj_acc1}
lead to the following equation:
\begin{equation}\label{wpg04.eq.swtraj_acc2}
    \ddot{y}_{swing,i}
    =
    \frac{6(y_{swing,f} - y_{swing,i})}{t_f^2} - \frac{4\dot{y}_{swing,i}}{t_f}
    =
    \frac{6}{t_f^2}y_{swing,f} -
    \underbrace{
        \frac{6}{t_f^2}y_{swing,i} - \frac{4}{t_f} \dot{y}_{swing,i}
    }_{\mbox{constant}}.
\end{equation}

Consequently
\begin{equation}
    \V{\ddot{y}}_{swing}
    =
    \begin{bmatrix}
        \ddot{y}_{swing,i}^x\\
        \ddot{y}_{swing,i}^y\\
        \ddot{y}_{swing,i}^z\\
    \end{bmatrix}
    =
    \underbrace{
        \frac{6}{t_f^2}
        \begin{bmatrix}
            \M{V}_{land} \\
            \M{0}
        \end{bmatrix}
    }_{\M{V}_{sa}}
    \FP
    +
    \underbrace{
        \frac{6}{t_f^2}
        \begin{bmatrix}
            \M{0} \\
            y_{swing,f}^z
        \end{bmatrix}
        -
        \frac{6}{t_f^2}
        \V{y}_{swing,i}
        -
        \frac{4}{t_f}
        \V{\dot{y}}_{swing,i}
    }_{\V{b}_{sa}},
\end{equation}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Computation of the initial jerk}
Jerk at the beginning of the swing foot trajectory characterizes behaviour of the
polynomial near this point. High values of the jerk indicate rapid change of
acceleration, which in turn increases error in trajectory tracking using piece-wise
constant acceleration. Due to this reason we penalize the jerk at the starting point
of trajectory. Obviously, only $x,y$ components are penalized, since $z$ component
is directly computed.

The jerk can be computed as:
\begin{equation}\label{wpg04.eq.swtraj_jerk}
    \dddot{y}_{swing,i}
    =
    - \frac{12(y_{swing,f} - y_{swing,i})}{t_f^3} + \frac{6\dot{y}_{swing,i}}{t_f^2}
    =
    - \frac{12}{t_f^3}y_{swing,f}
    +
    \underbrace{
        \frac{12}{t_f^3}y_{swing,i} + \frac{6}{t_f} \dot{y}_{swing,i}
    }_{\mbox{constant}}.
\end{equation}

Therefore $x,y$ components of the jerk are expressed as
\begin{equation}
    \V{\dddot{y}}_{swing}^{x,y}
    =
    \begin{bmatrix}
        \dddot{y}_{swing,i}^x\\
        \dddot{y}_{swing,i}^y\\
    \end{bmatrix}
    =
    \underbrace{
        -
        \frac{12}{t_f^3}
        \M{V}_{land}
    }_{\M{V}_{sj}}
    \FP
    +
    \underbrace{
        \frac{12}{t_f^3}
        \V{y}_{swing,i}
        +
        \frac{6}{t_f^2}
        \V{\dot{y}}_{swing,i}
    }_{\V{b}_{sj}}
    =
    \underbrace{
        \begin{bmatrix}
            \M{0}   &   \M{0}   &   \M{V}_{sj}
        \end{bmatrix}
    }_{\M{A}_{sj}}
    \V{X}_{mpc}
    +
    \V{b}_{sj}
    .
\end{equation}
\input{../../../doc/latex/Styles/wpg_notation_undefine.tex}