\chapter{hjgad}
\begin{abox}
	Problem set-1
\end{abox}
\begin{enumerate}[label=\color{ocre}\textbf{\arabic*.}]
	\item Consider the matrix $M=\left(\begin{array}{lll}1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1\end{array}\right)$\\
	\textbf{A.} The eigenvalues of $M$ are
	{\exyear{NET/JRF(JUNE-2011)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $0,1,2$
		\task[\textbf{B.}] $0,0,3$
		\task[\textbf{C.}] $1,1,1$
		\task[\textbf{D.}] $-1,1,3$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{For eigen values }\left[\begin{array}{ccc}1-\lambda & 1 & 1 \\ 1 & 1-\lambda & 1 \\ 1 & 1 & 1-\lambda\end{array}\right]&=0\\
		(1-\lambda)\left((1-\lambda)^{2}-1\right)-(1-\lambda-1)+1(1-(1-\lambda))&=0\\
		(1-\lambda)\left(1+\lambda^{2}-2 \lambda-1\right)+\lambda+\lambda=0 \Rightarrow \lambda^{2}-2 \lambda-\lambda^{3}+2 \lambda^{2}+2 \lambda&=0\\
		\lambda^{3}-3 \lambda^{2}=0 \Rightarrow \lambda^{2}(\lambda-3)=0 \Rightarrow \lambda&=0,0,3
		\intertext{For any $n \times n$ matrix having all elements unity eigenvalues are $0,0,0, \ldots, n$.}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\textbf{B.} The exponential of $M$ simplifies to ( $I$ is the $3 \times 3$ identity matrix)
	\begin{tasks}(2)
		\task[\textbf{A.}] $e^{M}=I+\left(\frac{e^{3}-1}{3}\right) M$
		\task[\textbf{B.}] $e^{M}=I+M+\frac{M^{2}}{2 !}$
		\task[\textbf{C.}] $e^{M}=I+3^{3} M$
		\task[\textbf{D.}] $e^{M}=(e-1) M$
	\end{tasks}
	\begin{answer}
		\begin{align*}
	\intertext{We know that}
	e^x&=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+.....\\
	e^M&=1+M+\frac{M^2}{2!}+\frac{M^3}{3!}+.....\\
	M&=\left[\begin{array}{lll}1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1\end{array}\right] \Rightarrow M^{2} =\left[\begin{array}{lll}3 & 3 & 3 \\ 3 & 3 & 3 \\ 3 & 3 & 3\end{array}\right]=3 M\\
	\text{similarly}\quad M^{3}&=9 M=3^{2} M
	\intertext{we can rewrite $e^M$ as,}
	e^{M}&=I+M+\frac{3 M}{2 !}+\frac{3^{2} M}{3 !}+\frac{3^{3} M}{4 !}+\cdots\\
	&=I+\frac{M}{3}\left[3+\frac{3^{2}}{2 !}+\frac{3^{3}}{3 !}+\frac{3^{4}}{4 !}+\cdots\right]\\
	&=I+\frac{M}{3}\left[e^{3}-1\right]
		\end{align*}
	\end{answer}
	\item A $3 \times 3$ matrix $M$ has $\operatorname{Tr}[M]=6, \operatorname{Tr}\left[M^{2}\right]=26$ and $\operatorname{Tr}\left[M^{3}\right]=90$. Which of the following can be a possible set of eigenvalues of $M ?$
	{\exyear{NET/JRF(DEC-2011)}}
\begin{tasks}(4)
\task[\textbf{A.}] $\{1,1,4\}$
\task[\textbf{B.}] $\{-1,0,7\}$
\task[\textbf{C.}] $\{-1,3,4\}$
\task[\textbf{D.}] $\{2,2,2\}$
\end{tasks}
\begin{answer}
\begin{align*}
T_r[M]&=\text{sum of eigen values}\\
T_r[M^2]&=\text{sum of square of eigen values}\\
\operatorname{Tr}\left[M^{2}\right]&=(-1)^{2}+(3)^{2}+(4)^{2}\text{ also } \operatorname{Tr}\left[M^{3}\right]\\&=(-1)^{3}+(3)^{3}+(4)^{3}=90
\end{align*}
So the correct answer is \textbf{Option (C)}
\end{answer}
\item The eigen values of the matrix $A=\left(\begin{array}{lll}1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9\end{array}\right)$ are
{\exyear{NET/JRF(JUNE-2012)}}
\begin{tasks}(4)
	\task[\textbf{A.}] $(1,4,9)$
	\task[\textbf{B.}] $(0,7,7)$
	\task[\textbf{C.}] $(0,1,13)$
	\task[\textbf{D.}] $(0,0,14)$
\end{tasks}
\begin{answer}

	\begin{align*}
	\intertext{The given matrix $A$ has identical rows and columns}
	\intertext{So it's eigen values are,}
	\lambda=0,0\ \text{Trace}=0,0,14
	\intertext{Another solution}
	\text{For eigenvalues }|A-\lambda I|=0 \Rightarrow\left[\begin{array}{ccc}1-\lambda & 2 & 3 \\ 2 & 4-\lambda & 6 \\ 3 & 6 & 9-\lambda\end{array}\right]&=0\\
	(1-\lambda)[(4-\lambda)(9-\lambda)-36]-2[2(9-\lambda)-18]+3[12-3(4-\lambda)]&=0\\
	(1-\lambda)(4-\lambda)(9-\lambda)-36(1-\lambda)-4(9-\lambda)+36+9 \lambda&=0\\
	\lambda^{3}-14 \lambda^{2}=0 \Rightarrow \lambda^{2}(\lambda-14)=0 \Rightarrow \lambda&=0,0,14
	\end{align*}
	So the correct answer is \textbf{Option (D)}
\end{answer}
	\item The eigenvalues of the antisymmetric matrix,
	$$
	A=\left(\begin{array}{ccc}
	0 & -n_{3} & n_{2} \\
	n_{3} & 0 & -n_{1} \\
	-n_{2} & n_{1} & 0
	\end{array}\right)
	$$
	where $n_{1}, n_{2}$ and $n_{3}$ are the components of a unit vector, are
	{\exyear{NET/JRF(JUNE-2012)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $0, i,-i$
		\task[\textbf{B.}] $0,1,-1$
		\task[\textbf{C.}] $0,1+i,-1,-i$
		\task[\textbf{D.}]  $0,0,0$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		A&=\left[\begin{array}{ccc}0 & -n_{3} & n_{2} \\ n_{3} & 0 & -n_{1} \\ -n_{2} & n_{1} & 0\end{array}\right] \Rightarrow-A^{T}=\left[\begin{array}{ccc}0 & -n_{3} & n_{2} \\ n_{3} & 0 & -n_{1} \\ -n_{2} & n_{1} & 0\end{array}\right]\\
		(A-\lambda I)&=0,\left[\begin{array}{ccc}0-\lambda & -n_{3} & n_{2} \\ n_{3} & 0-\lambda & -n_{1} \\ -n_{2} & n_{1} & 0-\lambda\end{array}\right]=0\\
		\Rightarrow \lambda_{1}&=0 \Rightarrow \lambda_{2}=-\sqrt{-n_{1}^{2}-n_{2}^{2}-n_{3}^{2}} \Rightarrow \lambda_{3}\\&=\sqrt{-n_{1}^{2}-n_{2}^{2}-n_{3}^{2}}\\
		\text{but }&\sqrt{n_{1}^{2}+n_{2}^{2}+n_{3}^{2}}=1\\
		\intertext{For an antisymmetric matrix the eigen values are}
		\lambda &=0,\pm i
		\intertext{sum of sqares of non diagonal elements}
		&=0,\pm i \sqrt{n_1^2+n_2^2+n_3^2}=0, \pm i\\
		\therefore &n_1, n_2, n_3 \text{are components of a unit vector}\\
		\text{	so, }\quad \lambda_{1}&=0, \lambda_{2}=i, \lambda_{3}=-i\\
		A&=-A^{T}\text{ (Antisymmetric). Eigenvalues are either zero or purely imaginary.}
		\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item Consider an $n \times n(n>1)$ matrix $A$, in which $A_{i j}$ is the product of the indices $i$ and $j$ $\left(\right.$ namely $\left.A_{i j}=i j\right)$. The matrix $A$
{\exyear{NET/JRF(DEC-2013)}}
	\begin{tasks}(1)
		\task[\textbf{A.}]  Has one degenerate eigevalue with degeneracy $(n-1)$
		\task[\textbf{B.}] Has two degenerate eigenvalues with degeneracies 2 and $(n-2)$
		\task[\textbf{C.}] Has one degenerate eigenvalue with degeneracy $n$
		\task[\textbf{D.}] Does not have any degenerate eigenvalue
	\end{tasks}
	\begin{answer}
	\begin{align*}
	\intertext{The matrix $A$ will be like, }
	A_{i j}=\left[\begin{array}{ccccccc}1 & 2 & 3 & 4 & \cdots & n \\ 2 & 4 & 6 & 8 & \cdots & \cdots & \\ 3 & 6 & 9 & 12 & \cdots & \cdots \\ 4 & 8 & 12 & 16 & \cdots & \cdots \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\ n & \vdots & \vdots & \vdots & & \end{array}\right]
	\intertext{The matrix $A$ is having identical rows and columns then it's eigen values will be, $(n-1)$ number of zeros and it's trace.}
	\lambda&=0,0,.......,[1^2+2^2+....n^2]
	\intertext{Thus the matrix has one degenerate eigen value with $n-1$  degeneracy}
	\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item Consider the matrix
	$$
	M=\left(\begin{array}{ccc}
	0 & 2 i & 3 i \\
	-2 i & 0 & 6 i \\
	-3 i & -6 i & 0
	\end{array}\right)
	$$
	The eigenvalues of $M$ are
	{\exyear{NET/JRF(JUNE-2014)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $-5,-2,7$
		\task[\textbf{B.}] $-7,0,7$
		\task[\textbf{C.}] $-4 i, 2 i, 2 i$
		\task[\textbf{D.}] $2,3,6$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		M&=\left(\begin{array}{ccc}0 & 2 i & 3 i \\ -2 i & 0 & 6 i \\ -3 i & -6 i & 0\end{array}\right), M^{+}=\left(\begin{array}{ccc}0 & 2 i & 3 i \\ -2 i & 0 & 6 i \\ -3 i & -6 i & 0\end{array}\right)\\
		M^{+}&=M
		\intertext{Matrix is Hermitian so roots are real and }
		\lambda&=0,\pm i\sqrt{(2i)^2+(3i)^2+(6i)^2}\quad\text{property of antisymmetric matrix}\\
		&=0,\pm i\sqrt{-49}\\
		&=0,\pm 7=-7,0,7
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item The column vector $\left(\begin{array}{l}a \\ b \\ a\end{array}\right)$ is a simultaneous eigenvector of $A=\left(\begin{array}{ccc}0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0\end{array}\right)$ and $B=\left(\begin{array}{lll}0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0\end{array}\right)$ if
	{\exyear{NET/JRF(DEC-2014)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $b=0$ or $a=0$
		\task[\textbf{B.}] $b=a$ or $b=-2 a$
		\task[\textbf{C.}] $b=2 a$ or $b=-a$
		\task[\textbf{D.}] $b=a / 2$ or $b=-a / 2$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{Let }b&=a\\
		\left(\begin{array}{lll}0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0\end{array}\right)\left(\begin{array}{l}a \\ a \\ a\end{array}\right)&=\left(\begin{array}{l}a \\ a \\ a\end{array}\right)\text{ and } \left(\begin{array}{lll}0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0\end{array}\right)\left(\begin{array}{l}a \\ a \\ a\end{array}\right)=2\left(\begin{array}{l}a \\ a \\ a\end{array}\right)\\
		\text{	Let }b&=-2 a\\
		\left(\begin{array}{ccc}0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0\end{array}\right)\left(\begin{array}{c}a \\ -2 a \\ a\end{array}\right)&=\left(\begin{array}{c}a \\ -2 a \\ a\end{array}\right)\text{ and } \left(\begin{array}{ccc}0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0\end{array}\right)\left(\begin{array}{c}a \\ -2 a \\ a\end{array}\right)\\&=\left(\begin{array}{c}-a \\ 2 a \\ -a\end{array}\right)=-1\left(\begin{array}{c}a \\ -2 a \\ a\end{array}\right)
		\intertext{For other combination above relation is not possible.}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item The matrix $M=\left(\begin{array}{ccc}1 & 3 & 2 \\ 3 & -1 & 0 \\ 0 & 0 & 1\end{array}\right)$ satisfies the equation
	{\exyear{NET/JRF(DEC-2016)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $M^{3}-M^{2}-10 M+12 I=0$
		\task[\textbf{B.}] $M^{3}+M^{2}-12 M+10 I=0$
		\task[\textbf{C.}] $M^{3}-M^{2}-10 M+10 I=0$
		\task[\textbf{D.}] $M^{3}+M^{2}-10 M+10 I=0$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{he characteristic equation is}
		&\left|\begin{array}{ccc}(1-\lambda) & 3 & 2 \\ 3 & (-1-\lambda) & 0 \\ 0 & 0 & (1-\lambda)\end{array}\right|=0\\
		&\Rightarrow \quad(1-\lambda)(-1-\lambda)(1-\lambda)-(3) \times 3(1-\lambda)=0\\
		&\Rightarrow \quad-\left(\lambda^{2}-1\right)(\lambda-1)-9(1-\lambda)=0 \\&\Rightarrow \lambda^{3}-10 \lambda-\lambda^{2}+10=0
		\intertext{Thus the matrix $M$ satisfies the equation}
		&M^{3}-M^{2}-10 M+10 I=0
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item   Which of the following can not be the eigen values of a real $3 \times 3$ matrix
	{\exyear{NET/JRF(JUNE-2017)}}
	\begin{tasks}(4)
		\task[\textbf{A.}]  $2 i, 0,-2 i$
		\task[\textbf{B.}] $1,1,1$
		\task[\textbf{C.}] $e^{i \theta}, e^{-i \theta}, 1$
		\task[\textbf{D.}] $i, 1,0$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{If the matrix is real then the complex eigen values always occurs with its complex conjugate. In option (d) if $i$ is an eigen value then $-i$ must also be an eigen value. But $-i$ is not given in option, hence option (d) is incorrect.}
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item  Let $\sigma_{x}, \sigma_{y}, \sigma_{z}$ be the Pauli matrices and $x^{\prime} \sigma_{x}+y^{\prime} \sigma_{y}+z^{\prime} \sigma_{z}=\exp \left(\frac{i \theta \sigma_{z}}{2}\right) \times$
	$$
	\left[x \sigma_{x}+y \sigma_{y}+z \sigma_{z}\right] \exp \left(-\frac{i \theta \sigma_{z}}{2}\right)
	$$
	Then the coordinates are related as follows
	{\exyear{NET/JRF(JUNE-2017)}}
	\begin{tasks}(1)
		\task[\textbf{A.}] $\left(\begin{array}{l}x^{\prime} \\ y^{\prime} \\ z^{\prime}\end{array}\right)=\left(\begin{array}{ccc}\cos \theta & -\sin \theta & 0 \\ \sin \theta & \cos \theta & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{l}x \\ y \\ z\end{array}\right)$
		\task[\textbf{B.}] $\left(\begin{array}{l}x^{\prime} \\ y^{\prime} \\ z^{\prime}\end{array}\right)=\left(\begin{array}{ccc}\cos \theta & \sin \theta & 0 \\ -\sin \theta & \cos \theta & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{l}x \\ y \\ z\end{array}\right)$
		\task[\textbf{C.}] $\left(\begin{array}{l}x^{\prime} \\ y^{\prime} \\ z^{\prime}\end{array}\right)=\left(\begin{array}{ccc}\cos \frac{\theta}{2} & \sin \frac{\theta}{2} & 0 \\ -\sin \frac{\theta}{2} & \cos \frac{\theta}{2} & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{l}x \\ y \\ z\end{array}\right)$
		\task[\textbf{D.}] $\left(\begin{array}{l}x^{\prime} \\ y^{\prime} \\ z^{\prime}\end{array}\right)=\left(\begin{array}{ccc}\cos \frac{\theta}{2} & -\sin \frac{\theta}{2} & 0 \\ \sin \frac{\theta}{2} & \cos \frac{\theta}{2} & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{l}x \\ y \\ z\end{array}\right)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\sigma_{x}&=\left(\begin{array}{ll}0 & 1 \\ 1 & 0\end{array}\right), \sigma_{y}=\left(\begin{array}{cc}0 & -i \\ i & 0\end{array}\right)\text{ and } \sigma_{z}=\left(\begin{array}{cc}1 & 0 \\ 0 & -1\end{array}\right)\\
		\text{Hence, }x \sigma_{x}+y \sigma_{y}+z \sigma_{z}&=\left(\begin{array}{cc}z & x-i y \\ x+i y & -z\end{array}\right)\\
		x^{\prime} \sigma_{x}+y^{\prime} \sigma_{y}+z^{\prime} \sigma_{z}&=\left(\begin{array}{cc}z^{\prime} & x^{1}-i y^{\prime} \\ x^{\prime}+i y^{\prime} & -z^{\prime}\end{array}\right)\\
		\exp \left(\frac{i \theta \sigma_{z}}{z}\right)&=\left(\begin{array}{cc}e^{i \theta / 2} & 0 \\ 0 & e^{-i \theta / 2}\end{array}\right)\text{ and exp }\left(\frac{-i \theta \sigma_{z}}{2}\right)=\left(\begin{array}{cc}e^{-i \theta / 2} & 0 \\ 0 & e^{i \theta / 2}\end{array}\right)\\
		\text{Hence, }\left(\begin{array}{cc}z^{\prime} & x^{\prime}-i y^{\prime} \\ x^{\prime}+i y^{\prime} & -z^{\prime}\end{array}\right)&=\left(\begin{array}{cc}e^{i \theta / 2} & 0 \\ 0 & e^{-i \theta / 2}\end{array}\right)\left(\begin{array}{cc}z & x-i y \\ x+i y & -z\end{array}\right)\left(\begin{array}{cc}e^{-i \theta / 2} & 0 \\ 0 & e^{i \theta / 2}\end{array}\right)\\
		\Rightarrow\left(\begin{array}{cc}z^{\prime} & x^{\prime}-i y^{\prime} \\ x^{\prime}+i y^{\prime} & -z^{\prime}\end{array}\right)&=\left(\begin{array}{cc}z & e^{i \theta}(x-i y) \\ e^{-i \theta}(x+i y) & -z\end{array}\right)\\
		\text{Hence, }z^{\prime}&=z\text{ and }x^{\prime}-i y^{\prime}=e^{i \theta}(x-i y)\\
		\text{Thus }x^{\prime}-i y^{\prime}&=[(\cos \theta) x+(\sin \theta) y]-i[(\cos \theta) y-(\sin \theta) x]\\
		\text{Thus }x^{\prime}&=(\cos \theta) x+(\sin \theta) y\\
		\text{And }y^{\prime}&=(-\sin \theta) x+(\cos \theta) y\\
		\text{Thus, }\left(\begin{array}{l}x^{\prime} \\ y^{\prime} \\ z^{\prime}\end{array}\right)&=\left(\begin{array}{ccc}\cos \theta & \sin \theta & 0 \\ -\sin \theta & \cos \theta & 0 \\ 0 & 0 & 1\end{array}\right)\left(\begin{array}{l}x \\ y \\ z\end{array}\right)
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item  Let $A$ be a non-singular $3 \times 3$ matrix, the columns of which are denoted by the vectors $\vec{a}, \vec{b}$ and $\vec{c}$, respectively. Similarly, $\vec{u}, \vec{v}$ and $\vec{w}$ denote the vectors that form the corresponding columns of $\left(A^{T}\right)^{-1}$. Which of the following is true?
	{\exyear{NET/JRF(DEC-2017)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\vec{u} \cdot \vec{a}=0, \vec{u} \cdot \vec{b}=0, \vec{u} \cdot \vec{c}=1$
		\task[\textbf{B.}]  $\vec{u} \cdot \vec{a}=0, \vec{u} \cdot \vec{b}=1, \vec{u} \cdot \vec{c}=0$
		\task[\textbf{C.}] $\vec{u} \cdot \vec{a}=1, \vec{u} \cdot \vec{b}=0, \vec{u} \cdot \vec{c}=0$
		\task[\textbf{D.}]  $\vec{u} \cdot \vec{a}=0, \vec{u} \cdot \vec{b}=0, \vec{u} \cdot \vec{c}=0$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{We can take any $3 \times 3$ non singular matrix in order to avoid long calculation.}
		\text{Take }A&=\left[\begin{array}{ccc}1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \\ \downarrow & \downarrow & \downarrow \\ \vec{a} & \vec{b} & \vec{c}\end{array}\right] \Rightarrow\left(A^{T}\right)^{-1}=\left[\begin{array}{ccc}1 & 0 & 0 \\ 0 & 1 / 2 & 0 \\ 0 & 0 & 1 / 3 \\ \downarrow & \downarrow & \downarrow \\ \vec{u} & \vec{v} & \vec{w}\end{array}\right]
		\intertext{We see that}
		\vec{u} \cdot \vec{a}&=1.1+0.0+0.0=1\\
		\vec{u} \cdot \vec{b}&=1.0+0.2+0.0=0\\
		\vec{u} \cdot \vec{C}&=1.0+0.0+0.3=0
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item Consider the matrix equation
	$$
	\left(\begin{array}{llc}
	1 & 1 & 1 \\
	1 & 2 & 3 \\
	2 & b & 2 c
	\end{array}\right)\left(\begin{array}{l}
	x \\
	y \\
	z
	\end{array}\right)=\left(\begin{array}{l}
	0 \\
	0 \\
	0
	\end{array}\right)
	$$
	The condition for existence of a non-trivial solution and the corresponding normalised solution (upto a sign) is
	{\exyear{NET/JRF(DEC-2017)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $b=2 c$ and $(x, y, z)=\frac{1}{\sqrt{6}}(1,-2,1)$
		\task[\textbf{B.}] $c=2 b$ and $(x, y, z)=\frac{1}{\sqrt{6}}(1,1,-2)$
		\task[\textbf{C.}] $c=b+1$ and $(x, y, z)=\frac{1}{\sqrt{6}}(2,-1,-1)$
		\task[\textbf{D.}] $b=c+1$ and $(x, y, z)=\frac{1}{\sqrt{6}}(1,-2,1)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{Solution: We know that the matrix equation, $A X=0$, where $A$ is the given matrix and $X$ is a column vector has a non-zero solution if and only if $|A|=0$}
		\left|\begin{array}{lll}1 & 1 & 1 \\ 1 & 2 & 3 \\ 2 & b & 2 c\end{array}\right|&=0 \Rightarrow 4 c-3 b-2 c+6+b-4=0\\
		\Rightarrow 2 c-2 b+2&=0 \Rightarrow b=c+1
		\intertext{we do not need to perform further calculation,}
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item  Which of the following statements is true for a $3 \times 3$ real orthogonal matrix with determinant $+1 ?$
	{\exyear{NET/JRF(JUNE-2018)}}
	\begin{tasks}(1)
		\task[\textbf{A.}] The modulus of each of its eigenvalues need not be 1, but their product must be 1
		\task[\textbf{B.}] At least one of its eigenvalues is $+1$
		\task[\textbf{C.}] All of its eigenvalues must be real
		\task[\textbf{D.}]  None of its eigenvalues must be real
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{Solution: The characteristic equation of any $3 \times 3$ matrix is of thee form $\lambda^{3}+a \lambda^{2}+b \lambda+c=0$ which implies that at least one of the eigenvalues must be real. It is a proven fact that modulus of each eigenvalues of an orthogonal matrix is 1 .}
		\intertext{If all eigenvalues of $3 \times 3$ orthogonal matrix are real then only possibilities for eigenvalues are}
		\lambda_{1}&=1, \lambda_{2}=1\text{ and }\lambda_{3}=1\text{ or }\\\lambda_{1}&=-1, \lambda_{2}=-1, \lambda_{3}=1\text{ or }\\\lambda_{1}&=-1, \lambda_{2}=1, \lambda_{3}=-1\\
		\intertext{Thus we see that at least one eigenvalue is $+1$. Suppose one eigenvalues is real and other two eigenvalues are complex conjugates. Now}
		\lambda_{1} \lambda_{2} \lambda_{3}&=1\\
		\Rightarrow \lambda_{1}(a+i b)(a-i b)&=1 \Rightarrow \lambda_{1}\left(a^{2}+b^{2}\right)=1\\
		\text{	Since }a^{2}+b^{2}\text{ is always positive hence }\lambda_{1}&=1
		\intertext{In this case also we see that at least one eigenvalue must be $+1$}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item One of the eigenvalues of the matrix $e^{A}$ is $e^{a}$, where $A=\left(\begin{array}{ccc}a & 0 & 0 \\ 0 & 0 & a \\ 0 & a & 0\end{array}\right)$. The product of the other two eigenvalues of $e^{A}$ is
	{\exyear{NET/JRF(DEC-2018)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $e^{2 a}$
		\task[\textbf{B.}] $e^{-a}$
		\task[\textbf{C.}]  $e^{-2 a}$
		\task[\textbf{D.}] 1
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{ Eigenvalues of matrix $A$ are $a, a$ and $-a$. The product of two other eigenvalues of $A$ are $e^{a} a^{-a}=1$}
		\intertext{Alternativety}
		e^{\text {TraceA }}&=e^{\lambda_{1}+\lambda_{2}+\lambda_{3}}=\operatorname{det} e^{A}\\
		\Rightarrow e^{\lambda_{1}} \cdot e^{\lambda_{2}+\lambda_{3}}&=\operatorname{det} e^{A} \Rightarrow e^{a} \cdot e^{\lambda_{2}} \cdot e^{\lambda_{3}}=e^{a}\\
		\Rightarrow e^{\lambda_{2}} \cdot e^{\lambda_{3}}&=1
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item A $4 \times 4$ complex matrix $A$ satisfies the relation $A^{\dagger} A=4 I$, where $I$ is the $4 \times 4$ identity matrix. The number of independent real parameters of $A$ is
	{\exyear{NET/JRF(DEC-2018)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] 32
		\task[\textbf{B.}] 10
		\task[\textbf{C.}] 12
		\task[\textbf{D.}] 16
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{Given that }A^{\dagger} A&=4 I \Rightarrow \frac{1}{4}\left(A^{\dagger} A\right)=I\\
		\text{Let }A&=2 B\text{ then}\\
		A^{\dagger}&=2 B^{\dagger}\\
		\text{Therefore, }B^{\dagger} B&=I
		\intertext{This shows that $B$ is a unitary matrix. The number of independent real parameters needed to specify an $n \times n$ unitary matrix is $n^{2}$. Thus, the number of independent parameter needed to specify matrix $B$ is $4^{2}=16$.}
		\intertext{Now, the number of independent parameters needed to specify matrix $A$ is same as that of matrix $B$.}
		\intertext{Thus the number of independent parameters needed to specify $A$ is 16}
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item  The element of a $3 \times 3$ matrix $A$ are the products if its row and column indices $A_{i j}=i j$ (where $i, j=1,2,3)$. The eigenvalues of $A$ are
	{\exyear{NET/JRF(JUNE-2019)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $(7,7,0)$
		\task[\textbf{B.}]  $(7,4,3)$
		\task[\textbf{C.}] $(14,0,0)$
		\task[\textbf{D.}] $\left(\frac{14}{3}, \frac{14}{3}, \frac{14}{3}\right)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{Since }A_{i j}&=i j
		(\text{where }i, j=1,2,3, )\\
		\text{We obtain the matrix }A&=\left[\begin{array}{lll}1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9\end{array}\right]\\
		\text{For calculating eigen values }&\left|\begin{array}{ccc}1-\lambda & 2 & 3 \\ 2 & 4-\lambda & 6 \\ 3 & 6 & 9-\lambda\end{array}\right|=0
		\intertext{$(1-\lambda)[(4-\lambda)(9-\lambda)-36]-2[2(9-\lambda)-18]+3(12-3(4-\lambda))=0$}
		\intertext{$\Rightarrow-\lambda^{3}+\lambda^{2} \cdot 14=0 \Rightarrow \lambda^{2}(-\lambda+14)=0 \quad \Rightarrow \lambda=0,0,14$}
		\intertext{Also, directly for a $3 x 3$ matrix we can write $(0,0$, Trace of A) as Eigen values.}
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item  The operator $A$ has a matrix representation $\left(\begin{array}{ll}2 & 1 \\ 1 & 2\end{array}\right)$ in the basis spanned by $\left(\begin{array}{l}1 \\ 0\end{array}\right)$ and $\left(\begin{array}{l}0 \\ 1\end{array}\right) .$ In another basis spanned by $\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)$, the matrix representation of $A$ is
	{\exyear{NET/JRF(JUNE-2019)}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $\left(\begin{array}{ll}2 & 0 \\ 0 & 2\end{array}\right)$
		\task[\textbf{B.}] $\left(\begin{array}{ll}3 & 0 \\ 0 & 1\end{array}\right)$
		\task[\textbf{C.}] $\left(\begin{array}{ll}3 & 1 \\ 0 & 1\end{array}\right)$
		\task[\textbf{D.}] $\left(\begin{array}{ll}3 & 0 \\ 1 & 1\end{array}\right)$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{The given vector $\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)$ are eigen vectors of operator $A$,}
		\intertext{Hence in this basis matrix $A$ is represented by diagonal matrix $D$ consisting of eigenvalues of matrix $A$ on the main diagonal. Therefore,}
		D&=\left[\begin{array}{ll}3 & 0 \\ 0 & 1\end{array}\right]
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item  If the rank of an $n \times n$ matrix $A$ is $m$, where $m$ and $n$ are positive integers with $1 \leq m \leq n$, then the rank of the matrix $A^{2}$ is
	{\exyear{NET/JRF(DEC-2019)}}
	\begin{tasks}(4)
		\task[\textbf{A.}]  $m$
		\task[\textbf{B.}] $m-1$
		\task[\textbf{C.}] $2 \mathrm{~m}$
		\task[\textbf{D.}] $m-2$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{	Let }\sigma_{1}&=\left[\begin{array}{ll}0 & 1 \\ 1 & 0\end{array}\right]_{2 \times 2 \atop n=2}=A \quad m=2\\
		1& \leq 2 \leq 2 \quad 1 \leq m \leq n\\
		A^{2}&=\left[\begin{array}{ll}1 & 0 \\ 0 & 1\end{array}\right]_{2 \times 2} m=2
		\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item   The eigenvalues of the $3 \times 3$ matrix $M=\left(\begin{array}{lll}a^{2} & a b & a c \\ a b & b^{2} & b c \\ a c & b c & c^{2}\end{array}\right)$ are
	{\exyear{NET/JRF(JUNE-2020)}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $a^{2}+b^{2}+c^{2}, 0,0$
		\task[\textbf{B.}] $b^{2}+c^{2}, a^{2}, 0$
		\task[\textbf{C.}] $a^{2}+b^{2}, c^{2}, 0$
		\task[\textbf{D.}] $a^{2}+c^{2}, b^{2}, 0$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		M&=\left(\begin{array}{lll}a^{2} & a b & a c \\ a b & b^{2} & b c \\ a c & b c & c^{2}\end{array}\right)
		\intertext{To make it simple, Let $a=1, b=1, c=1$ so $\quad M=\left[\begin{array}{lll}1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1\end{array}\right]_{3 \times 3}$}
		\Rightarrow \lambda&=3,0,0
		\end{align*}
		So the correct answer is \textbf{Option (A)}
	\end{answer}
\end{enumerate}
\newpage
\begin{abox}
	Problem set-2
\end{abox}
\begin{enumerate}[label=\color{ocre}\textbf{\arabic*.}]
	\item The eigenvalues of the matrix $\left(\begin{array}{lll}2 & 3 & 0 \\ 3 & 2 & 0 \\ 0 & 0 & 1\end{array}\right)$ are
	{\exyear{GATE 2010}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $5,2,-2$
		\task[\textbf{B.}] $-5,-1,-1$
		\task[\textbf{C.}]  $5,1,-1$
		\task[\textbf{D.}] $-5,1,1$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{The characteristic equation of the matrix $A,|A-\lambda I|=0$}
		\Rightarrow|A-\lambda I|=\left|\begin{array}{ccc}2-\lambda & 3 & 0 \\ 3 & 2-\lambda & 0 \\ 0 & 0 & 1-\lambda\end{array}\right|&=0 \\\Rightarrow(1-\lambda)\left[(2-\lambda)^{2}-9\right]&=0 \\\Rightarrow \lambda=1,2-\lambda&=\pm 3\\
		\Rightarrow \lambda&=5,1,-1
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item Two matrices $A$ and $B$ are said to be similar if $B=P^{-1} A P$ for some invertible matrix $P$.Which of the following statements is NOT TRUE?
	{\exyear{GATE 2011}}
	\begin{tasks}(2)
		\task[\textbf{A.}] Det $A=\operatorname{Det} B$
		\task[\textbf{B.}]  Trace of $A=$ Trace of $B$
		\task[\textbf{C.}] $A$ and $B$ have the same eigenvectors
		\task[\textbf{D.}] $A$ and $B$ have the same eigenvalues
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\intertext{If $A$ and $B$ be square matrices of the same type and if $P$ be invertible matrix, then matrices $A$ and $B=P^{-1} A P$ have the same characteristic roots.}
		\intertext{Then, $B-\lambda I=P^{-1} A P-P^{-1} \lambda I P=P^{-1}(A-\lambda I) P$ where $I$ is identity matrix.}
		|B-\lambda I|&=\left|P^{-1}(A-\lambda I) P\right|=\left|P^{-1}\|A-\lambda I\| P\right|\\&=\left|A-\lambda I\left\|P^{-1}\right\| P\right|=\left|A-\lambda I \| P P^{-1}\right|\\&=|A-\lambda I|
		\intertext{Thus, the matrices $A$ and $B\left(=P^{-1} A P\right)$ have the same characteristic equation and hence
			same characteristic roots or eigen values. Since, the sum of the eigen values of a matrix and product of eigen values of a matrix is equal to the determinant of matrix, hence third alternative is incorrect.}
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item A $3 \times 3$ matrix has elements such that its trace is 11 and its determinant is 36 . The eigenvalues of the matrix are all known to be positive integers. The largest eigenvalues of the matrix is
	{\exyear{GATE 2011}}
	\begin{tasks}(4)
		\task[\textbf{A.}] 18
		\task[\textbf{B.}]  12
		\task[\textbf{C.}] 9
		\task[\textbf{D.}] 6
	\end{tasks}
	\begin{answer}
		We know that for any matrix\\
		1. The product of eigenvalues is equals to the determinant of that matrix.\\
		2. $\lambda_{1}+\lambda_{2}+\lambda_{3}+\ldots \ldots=$ Trace of matrix\\
		$\lambda_{1}+\lambda_{2}+\lambda_{3}=11$ and $\lambda_{1} \lambda_{2} \lambda_{3}=36$. Hence, the largest eigen value of the matrix is $6 .$\\\\
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item  The number of independent components of the symmetric tensor $A_{i j}$ with indices $i, j=1,2,3$ is
	{\exyear{GATE 2012}}
	\begin{tasks}(4)
		\task[\textbf{A.}] 1
		\task[\textbf{B.}] 3
		\task[\textbf{C.}] 6
		\task[\textbf{D.}] 9
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{	For symmetric tensor, }A_{i j}&=\left[\begin{array}{ccc}A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \\ A_{31} & A_{32} & A_{33}\end{array}\right]\\
		\because A_{12}=A_{21}, \quad A_{23}&=A_{32}, A_{13}=A_{31},\text{ hence there are six independent components.}
		\end{align*}
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item  The eigenvalues of the matrix $\left(\begin{array}{lll}0 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 0\end{array}\right)$ are
	{\exyear{GATE 2012}}
	\begin{tasks}(4)
		\task[\textbf{A.}] $0,1,1$
		\task[\textbf{B.}] $0,-\sqrt{2}, \sqrt{2}$
		\task[\textbf{C.}]  $\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, 0$
		\task[\textbf{D.}] $\sqrt{2}, \sqrt{2}, 0$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		|A-\lambda I|&=0 \Rightarrow\left|\begin{array}{ccc}-\lambda & 1 & 0 \\ 1 & -\lambda & 1 \\ 0 & 1 & -\lambda\end{array}\right|\\&=0 \Rightarrow-\lambda\left(\lambda^{2}-1\right)+\lambda=0 \Rightarrow \lambda\\&=0,+\sqrt{2},-\sqrt{2}
		\end{align*}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
	\item    The degenerate eigenvalue of the matrix $\left[\begin{array}{ccc}4 & -1 & -1 \\ -1 & 4 & -1 \\ -1 & -1 & 4\end{array}\right]$ is (your answer should be an
	integer)---
	{\exyear{GATE 2013}}
	\begin{answer}
		\begin{align*}
		\left[\begin{array}{ccc}4-\lambda & -1 & -1 \\ -1 & 4-\lambda & -1 \\ -1 & -1 & 4-\lambda\end{array}\right]&=0 \Rightarrow(2-\lambda)\left[\begin{array}{ccc}1 & -1 & -1 \\ 0 & 5-\lambda & 0 \\ 0 & 0 & 5-\lambda\end{array}\right]\\&=(2-\lambda)(5-\lambda)^{2}=0 \Rightarrow \lambda\\&=2,5,5
		\end{align*}
	\end{answer}
	\item  The matrix
	$$
	A=\frac{1}{\sqrt{3}}\left[\begin{array}{cc}
	1 & 1+i \\
	1-i & -1
	\end{array}\right] \text { is }
	$$
	{\exyear{GATE 2014}}
	\begin{tasks}(4)
		\task[\textbf{A.}] Orthogonal
		\task[\textbf{B.}] Symmetric
		\task[\textbf{C.}]  Anti-symmetric
		\task[\textbf{D.}]  Unitary
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{	Unitary }A^{\dagger} A=I
		\end{align*}
		So the correct answer is \textbf{Option (D)}
	\end{answer}
	\item  Let $X$ be a column vector of dimension $n>1$ with at least one non-zero entry. The number of non-zero eigenvalues of the matrix $M=X X^{T}$ is
	{\exyear{GATE 2017}}
	\begin{tasks}(4)
		\task[\textbf{A.}] 0
		\task[\textbf{B.}] $n$
		\task[\textbf{C.}] 1
		\task[\textbf{D.}] $n-1$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\text{	Let }X&=\left[\begin{array}{l}0 \\ 0 \\ a \\ 0 \\ 0 \\ 0\end{array}\right],\text{ then} X^{T}=\left[\begin{array}{llll}0 & 0 & a \ldots & 0\end{array}\right]
		\intertext{Here, $X$ is an $n \times 1$ column vector with the entry in the $i$ th row equal to a. $X^{T}$ is a row vector having entry in the $i$ th column equal to a. Then, $X X^{T}$ is an $n \times 1$ matrix having the entry in the $i$ th row and $i$ th column equal to $a^{2}$.}
		\end{align*}
		Hence
		\begin{figure}[H]
			\centering
			\includegraphics[height=4cm,width=6cm]{diagram-20210823(3)-crop}
		\end{figure}
		Since this matrix is diagonal, its eigenvalues are $a^{2}, 0,0 \ldots \ldots 0 .$ Hence, the number of non zero eigenvalues of the matrix $X X^{T}$ is 1 .\\\\
		So the correct answer is \textbf{Option (C)}
	\end{answer}
	\item The eigenvalues of a Hermitian matrix are all
	{\exyear{GATE 2018}}
	\begin{tasks}(4)
		\task[\textbf{A.}]  Real
		\task[\textbf{B.}] Imaginary
		\task[\textbf{C.}] Of modulus one
		\task[\textbf{D.}] Real and positive
	\end{tasks}
	\begin{answer}
		Eigenvalue of Hermitian matrix must be real.\\\\
		So the correct answer is \textbf{Option (A)}
	\end{answer}
	\item During a rotation, vectors along the axis of rotation remain unchanged. For the rotation matrix $\left(\begin{array}{ccc}0 & 1 & 0 \\ 0 & 0 & -1 \\ -1 & 0 & 0\end{array}\right)$, the vector along the axis of rotation is
	{\exyear{GATE 2019}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\frac{1}{3}(2 \hat{i}-\hat{j}+2 \hat{k})$
		\task[\textbf{B.}]  $\frac{1}{\sqrt{3}}(\hat{i}+\hat{j}-\hat{k})$
		\task[\textbf{C.}] $\frac{1}{\sqrt{3}}(\hat{i}-\hat{j}-\hat{k})$
		\task[\textbf{D.}] $\frac{1}{3}(2 \hat{i}+2 \hat{j}-\hat{k})$
	\end{tasks}
	\begin{answer}
		So the correct answer is \textbf{Option (B)}
	\end{answer}
\end{enumerate}
\colorlet{ocre1}{ocre!70!}
\colorlet{ocrel}{ocre!30!}
\setlength\arrayrulewidth{1pt}
\begin{table}[H]
	\centering
	\arrayrulecolor{ocre}
	\begin{tabular}{|p{1.5cm}|p{1.5cm}||p{1.5cm}|p{1.5cm}|}
		\hline
		\multicolumn{4}{|c|}{\textbf{Answer key}}\\\hline\hline
		\rowcolor{ocrel}Q.No.&Answer&Q.No.&Answer\\\hline
		1&\textbf{C} &2&\textbf{C}\\\hline
		3&\textbf{D} &4&\textbf{C} \\\hline
		5&\textbf{B} &6&\textbf{-} \\\hline
		7&\textbf{D}&8&\textbf{C}\\\hline
		9&\textbf{A}&10&\textbf{B}\\\hline

	\end{tabular}
\end{table}

CSIR- Mathematical Physics/chapter/Matrix Problem set Solutions.tex


\chapter{Greedy}

\section{Introduction}
Philosophy: choose the best options at the current state without reverting the choice in the future.

A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum.

Greedy algorithm is a degenerated dp since the the past substructure is not remembered.

\subsection{Proof}
The proof technique for the correctness of the greedy method.

Proof by contradiction, the solution of greedy algorithm is $\mat{G}$ and the optimal solution is $\mat{O}$, $\mat{O}\neq \mat{G}$ (or relaxed to $|\mat{O}|\neq |\mat{G}|$).

Two general technique it is impossible to have $\mat{O}\neq \mat{G}$:
\begin{enumerate}
\item Exchange method
\item Stays-head method
\end{enumerate}

\section{Extreme First}
\runinhead{Rearranging String $k$ distance apart.} Given a non-empty string $s$ and an integer $k$, rearrange the string such that the same characters are at least distance
$k$ from each other.

\textbf{Core clues.}
\begin{enumerate}
\item The char with the most count put to the result first - greedy.
\item Fill every $k$ slots as cycle - greedily fill high-count char as many as possible.
\end{enumerate}

\textbf{Implementations.}
\begin{enumerate}
\item Use a heap as a way to get the char of the most count.
\item \pyinline{while} loop till exhaust the heap
\end{enumerate}

\begin{python}
def rearrangeString(self, s, k):
  if not s or k == 0: return s

  d = defaultdict(int)
  for c in s:
    d[c] += 1

  h = []
  for char, cnt in d.items():
    heapq.heappush(h, Val(cnt, char))

  ret = []
  while h:
    cur = []
    for _ in xrange(k):
      if not h:
        return "".join(ret) if len(ret) == len(s) else ""

      e = heapq.heappop(h)
      ret.append(e.val)
      e.cnt -= 1
      if e.cnt > 0:
        cur.append(e)

    for e in cur:
      heapq.heappush(h, e)

  return "".join(ret)

\end{python}


% !TEX root = main.tex

%-------------------------------------------------
\section{One-sample tests}\label{sec:nhst_one_sample_tests}

%-----------------------------
\begin{example}[Binomial test]
 Let $X_1,X_2,\ldots,X_n$ be a random sample from the $\text{Bernoulli}(\theta)$ distribution, where $\theta$ is unknown.
\ben
\it Find a critical region of size $\alpha$ to test $H_0:\theta=\theta_0$ against $H_1:\theta<\theta_0$.
\it Find the power function of the test.
\een
\end{example}

\begin{solution}
\bit
\it The sample space is $D = \{0,1\}^n$, which consists of all binary vectors of length $n$.
\eit
Let $\mathbf{X}=(X_1,X_2,\ldots,X_n)$ denote the random sample, and consider the test statistic
\[
\begin{array}{rccl}
S: & D & \to & \R \\
 & \mathbf{x} & \mapsto & \sum_{i=1}^n x_i
\end{array}
\]
\bit
\it $S(\mathbf{X})$ is the total number of successes in the sample.
\it Under the null hypothesis, $S(\mathbf{X})\sim\text{Binomial}(n,\theta_0)$,
\eit

\ben
\it % size
To test $H_0:\theta=\theta_0$ against $H_1:\theta<\theta_0$, we define the critical region
\[
C = \{\mathbf{x} : S(\mathbf{x}) \leq k\},
\]
where $k$ is chosen so that $\prob_{\theta_0}\big(S(\mathbf{X})\leq k\big) = \alpha$.

\bit
\it Because $S$ is \emph{discrete}, it is unlikely that $\prob_{\theta_0}\big(S(\mathbf{X})\leq k\big) = \alpha$ has an integer solution $k$.
\it The cautious approach would be to take the largest value of $k$ satisfying $\prob_{\theta_0}\big(S(\mathbf{X})\leq k\big) \leq \alpha$.
\eit

\it % power
The power function of the test is
\[
\gamma(\theta)
	= \prob_{\theta}(S\leq k)
	= \sum_{j=1}^k\binom{n}{j}\theta^j(1-\theta)^{n-j} \quad\text{for all $\theta < \theta_0$.}
\]
%\begin{align*}
%\gamma(\theta)
%	& = \prob_{\theta}\big[S(\mathbf{X})\leq k\big] \\
%	& = \sum_{j=1}^k\binom{n}{j}\theta^j(1-\theta)^{n-j}\text{\quad for\quad $\theta\in [0,\theta_0]$.}
%\end{align*}
\een
If we increase the size of the test, its power also increases: for example, if we take the critical region
\[
C^{*} = \{\mathbf{x} : S(\mathbf{x}) \leq k+1 \}
\]
then $\gamma^{*}(\theta) > \gamma(\theta)$ for all $\theta\in(0,1)$:
\[
\gamma^{*}(\theta)
	= \prob(S\leq k+1;\theta)
	> \prob(S\leq k;\theta)
	= \gamma(\theta) \text{\quad for all $\theta\in(0,1)$.}
\]
\end{solution}

%-----------------------------
\begin{example}[$z$-test]
Let $X\sim N(\mu,\sigma^2)$ where $\mu$ is unknown but $\sigma^2$ is known.
\ben
\it Find a critical region for testing $H_0:\mu=\mu_0$ against $H_1:\mu > \mu_0$
\it Find the power function $\gamma(\mu)$ of the test.
\it Show that the power function is strictly increasing for $\mu>\mu_0$. %Comment on your answer.
\een
\end{example}

\begin{solution}
\ben
\it % size
Let $X_1,X_2,\ldots,X_n$ be a random sample from the distribution of $X$
\bit
\it The sample mean $\bar{X}$ is an unbiased estimator for $\mu$.
\it If $\bar{X}-\mu_0$ is large, we would be inclined to reject $H_0$ in favour of $H_1$.
\eit
An appropriate test statistic $Z:\R^n\to\R$ is given by
\[
Z(X_1,X_2,\ldots,X_n) = \sqrt{n}\left(\frac{\bar{X}-\mu_0}{\sigma}\right)
\]
Because the $X_i$ are normally distributed, under $H_0$ we have that $Z\sim N(0,1)$.

\bigskip
The critical region for the test is
$C=\{\mathbf{x}:Z(\mathbf{x})> z_c\}$, i.e.
\[
C=\left\{\mathbf{x}: \sqrt{n}\left(\frac{\bar{x}-\mu}{\sigma}\right) > z_c\right\}
\]
where $z_c$ is the solution of $\prob_{\mu_0}(Z > z)=\alpha$, or equivalently the solution of $\Phi(z)=1-\alpha$ where $\Phi$ is the CDF of the standard normal distribution.

\it % power
For $\mu > \mu_0$, the power function is
\begin{align*}
\gamma(\mu)
%	& = \prob_{\mu}(Z\geq z_c) \\
	= \prob_{\mu}\left[\sqrt{n}\left(\frac{\bar{X}-\mu_0}{\sigma}\right) > z_c\right]
	& = \prob_{\mu}\left[\bar{X} > \frac{\sigma}{\sqrt{n}}z_c+\mu_0\right] \\
	& = \prob_{\mu}\left[\bar{X}-\mu > \frac{\sigma}{\sqrt{n}}z_c + (\mu_0-\mu)\right] \\
	& = \prob_{\mu}\left[\sqrt{n}\left(\frac{\bar{X}-\mu}{\sigma}\right) > z_c + \frac{\sqrt{n}(\mu_0-\mu)}{\sigma}\right] \\
	& = 1 - \prob_{\mu}\left[\sqrt{n}\left(\frac{\bar{X}-\mu}{\sigma}\right) \leq z_c + \frac{\sqrt{n}(\mu_0-\mu)}{\sigma}\right] \\
	& = \prob\left[Z \geq \frac{\sqrt{n}(\mu_0-\mu)}{\sigma} + z_c\right] \text{\quad where $Z\sim(0,1)$},\\
	& = 1 - \Phi\left(z_c + \frac{\sqrt{n}(\mu_0-\mu)}{\sigma}\right)
\end{align*}
where $\Phi$ is the CDF of the standard normal distribution $N(0,1)$.

\it % power
$\gamma(\mu)$ is an increasing function for $\mu>\mu_0$, because
\[
\gamma'(\mu) = \frac{\sqrt{n}}{\sigma} \phi\left(z_c + \frac{\sqrt{n}(\mu_0-\mu)}{\sigma}\right) > 0,
\]
where $\phi$ is the PDF of the standard normal distribution $N(0,1)$. This shows that the power to detect the simple alternative $H_1:\mu=\mu_1$ increases as $\mu_1$ increases away from $\mu_0$.
\een
\end{solution}

%-----------------------------
\begin{example}[$t$-test]
Let $X\sim N(\mu,\sigma^2)$ where $\mu$ and $\sigma^2$ are both unknown. Find a critical region of size $\alpha$ for testing $H_0:\mu=\mu_0$ against $H_1:\mu < \mu_0$
\end{example}

\begin{solution}
Let $X_1,X_2,\ldots,X_n$ be a random sample from the distribution of $X$, and let $\bar{X}$ and $S^2$ denote the sample mean and sample variance respectively.

\bigskip
The appropriate test statistic $T:\R^n\to\R$ is given by
\[
T(X_1,X_2,\ldots,X_n) = \sqrt{n}\left(\frac{\bar{X}-\mu_0}{S}\right)
\]

Under the null hypothesis $H_0:\mu=\mu_0$, this has \emph{Student's $t$-distribution} with $n-1$ degrees of freedom.

The critical region for our test is
\[
C=\left\{\mathbf{x}:\sqrt{n}\left(\frac{\bar{x}-\mu}{s}\right) \leq t_c\right\}
\]
where $t_c$ is the $\alpha$th quantile of Student's $t$ distribution with $n-1$ degrees of freedom.
\end{solution}

%-----------------------------
\begin{example}[Normal approximation]
Let $X_1,X_2,\ldots,X_n$ be a random sample from the $\text{Bernoulli}(\theta)$ distribution, where $\theta$ is unknown. We reject the null hypothesis $H_0:\theta=1/2$ in favour of $H_1:\theta>1/2$ if the observed number of successes exceeds some constant value $c>0$. Using a normal approximation, find values of $n$ and $c$ for which the size of the test is $0.1$ and whose power at $\theta=2/3$ is $0.95$.
\end{example}

\begin{solution}
Let $X\sim\text{Binomial}(n,\theta)$ be the number of successes.
\bit
\it By the central limit theorem, $X\sim N\big[n\theta,n\theta(1-\theta)\big]$ approx. provided $n$ is sufficiently large.
\eit

(1) If $H_0:\theta=1/2$ is correct, then $X\sim N(n/2,n/4)$ approx, so under $H_0$ we have
\[
Z 	= \frac{X-\expe(X)}{\sqrt{\var(X)}}
	= \frac{X-n/2}{\sqrt{n/4}}
	= \frac{2X-n}{\sqrt{n}} \sim N(0,1) \text{\quad approx.}
\]

For a test of size $\prob_{1/2}(X>c) = 0.1$ we need that
\[
\prob\left(Z > \frac{2c-n}{\sqrt{n}}\right) = 0.1,
\quad\text{and hence}\quad
\frac{2c-n}{\sqrt{n}} = 1.282 \text{\quad (from tables).}
\]

(2) If $H_1:\theta=2/3$ is correct, then $X\sim N(2n/3,2n/9)$ approx, so under $H_1$ we have
\[
Z 	= \frac{X-2n/3}{\sqrt{2n/9}}
	= \frac{3X-2n}{\sqrt{2n}} \sim N(0,1) \text{ approx.}
\]
For a test with power $\prob_{2/3}(X>c) = 0.95$  we need that
\[
\prob\left(Z > \frac{3c-2n}{\sqrt{2n}}\right) = 0.95,
\quad\text{and hence}\quad
\frac{3c-2n}{\sqrt{2n}} = -1.645 \text{\quad (from tables).}
\]

Thus we have two equations in two unknowns:
\[
2c = n + 1.282\sqrt{n} \text{\quad and\quad} 3c = 2n - 1.645\sqrt{2n}.
\]

\bit
\it Solving for $n$ and $c$, we find that $n=72.24$ and $c=41.56$.
\it Thus a sample of size $72$ and a rejection threshold of $42$ would approximately meet the stated requirements.
\eit
\end{solution}

%-----------------------------
\begin{exercise}
\begin{questions}
\question
Let $X\sim\text{Binomial}(10,\theta)$ where $\theta$ is either equal to $0.25$ or $0.5$. The simple mull hypothesis $H_0:\theta=0.5$ is rejected in favour of the simple alternative $H_1:\theta=0.25$ if the observed value of $X$ is at most equal to $3$. Find the size and power of the test.
\begin{answer}
\bit
\it The critical region is $C = \{X\leq 3\}$. Under the null hypothesis, $X\sim\text{Binomial}(10,0.5)$. The significance level of the test is therefore
\[
\alpha = \prob_{0.5}(X\leq 3) = \prob\big[X\leq 3\text{ when } X\sim\text{Binomial}(10,0.5)\big] = 0.1719 \quad\text{(from tables).}
\]
\it Under the alternative hypothesis $H_1:\theta=0.25$ we have $X\sim\text{Binomial}(10,0.25)$. The power of the test to detect $H_1$ is therefore
\[
\gamma(0.25) = \prob_{0.25}(X\leq 3) = \prob\big[X\leq 3\text{ when } X\sim\text{Binomial}(10,0.25)\big] = 0.7759 \quad\text{(from tables).}
\]
\eit
\end{answer}

\question
Adult males diagnosed with lung cancer have a mortality rate of $70\%$ within one year of the initial diagnosis. A research laboratory claims that a new treatment reduces this rate. Based on a random sample of $20$ patients, find a critical region of size $\alpha=0.15$ to test the claim, and compute the power of the test to detect a $20\%$ reduction in the mortality rate.
\begin{answer}
Let $\theta$ be the probability that a patient dies within one year of the initial diagnosis.
\bit
\it We wish to test the null hypothesis $H_0:\theta=0.7$ against the alternative $H_1:\theta<0.7$.
\eit
Let $X_1,X_2,\ldots,X_{20}$ be a random sample from the $\text{Bernoulli}(\theta)$ distribution
\bit
\it In this context, `success' corresponds to death within one year of the initial diagnosis!
\eit
Let $S=\sum_{i=1}^{20} X_i$ be the total number of deaths within one year of the initial diagnosis.
\bit
\it Under the null hypothesis, $S\sim\text{Binomial}(20,0.7)$.
\eit
A critical region for the test is $C=\{\mathbf{x}:S(\mathbf{x})\leq k\}$, where $k$ is chosen so that
\[
\prob_{0.7}(S\leq k) = 0.15.
\]
Tabulated values of the $\text{Binomial}(20,0.7)$ distribution yield
\[
\prob_{0.7}(S\leq 11) = 0.1133 \text{\quad and\quad}\prob_{0.7}(S\leq 12) = 0.2277.
\]
\bit
\it It is not possible to find a critical region of size $\alpha=0.15$ exactly.
\eit
The conservative approach would be to take $k=11$ and $\alpha=0.1133$.
\bit
\it A $20\%$ reduction in the mortality rate corresponds to $H_1:\theta=0.5$.
\eit
For the test of size $\alpha=0.1133$, its power to detect $H_1:\theta=0.5$ is
\begin{align*}
\prob_{0.5}(S\leq 11)
	& = \prob(S\leq 11) \text{ where } S\sim\text{Binomial}(20,0.5) \\
	& = 0.7483 \text{\quad (from tables)}.
\end{align*}
For the test of size $\alpha=0.2277$, its power to detect $H_1:\theta=0.5$ is
\begin{align*}
\prob_{0.5}(S\leq 12)
	& = \prob(S\leq 12) \text{ where } S\sim\text{Binomial}(20,0.5) \\
	& = 0.8684 \text{\quad (from tables)}.
\end{align*}
\end{answer}

\question
Let $X_1,X_2,\ldots,X_5$ be a random sample from the $\text{Bernoulli}(\theta)$ distribution. We wish to test the null hypothesis $H_0:\theta\leq 0.5$ against the alternative $H_1:\theta> 0.5$. $H_0$ is rejected by test $A$ only if all five trials result in `success', and rejected by test $B$ if at least at least three trials result in `success'. Find the size and power function of each test.
\begin{answer}
The sample space is $D=\{0,1\}^5$, the set of binary vectors of length $5$. \\
Let $Y=\sum_{i=1}^5 X_i$ be the number of successes: $Y\sim\text{Binomial}(5,\theta)$.
\ben
\it For test $A$,
\begin{align*}
\alpha 			& = \max_{0\leq\theta\leq 0.5}\prob_{\theta}(Y=5) = 0.5^5 = 0.0312. \\[2ex]
\gamma(\theta)	& = \prob_{\theta}(Y=5) = \theta^5.
\end{align*}
\it For test $B$,
\begin{align*}
\alpha 			& = \max_{0.5\leq\theta\leq 1}\prob(Y\geq 5)
				= 10(0.5)^3(0.5)^2 + 5(0.5)^4(0.5) + (0.5)^5 = 16(0.5)^5 = 0.5, \\
\gamma(\theta)	& = \prob(Y\geq 3;\theta)
				= 10\theta^3(1-\theta)^2 + 5\theta^4(1-\theta) + \theta^5.
\end{align*}
Thus Test B is more powerful than Test A, but its size is greater that of Test A.
\een
\end{answer}

\question
Let $X$ be a random sample of size $1$ from the $\text{Exponential}(\theta)$ distribution, where $\theta>0$ is a rate parameter. The null hypothesis $H_0:\theta=1/2$ is rejected in favour of the simple alternative $H_1:\theta = 1$ if the observed value $x$ is such that
\[
\frac{f(x;1/2)}{f(x;1)} \leq \frac{3}{4}.
\]
where $f(x;\theta)$ is the PDF of $X$. (This is defined to be $f(x;\theta) = \theta e^{-\theta x}$ for $x>0$, and zero otherwise.)
\ben
\it Show that the size of the test is $\alpha=1/3$.
\it Find the power of the test at $\theta=1$.
\een
\begin{answer}
Let $T$ denote the test statistic:
\[
T(X) = \frac{f(X;1/2)}{f(X;1)} = \frac{1}{2}e^{X/2}
\]
\ben
\it The size of the test is
\begin{align*}
\alpha = \prob_{H_0}(T\leq 3/4)
	& = \prob_{H_0}(e^{X/2} \leq 3/2) \\
	& = \prob_{H_0}\big[X\leq 2\log(3/2)\big] \\
	& = 1 - e^{-\log 3/2} \\
	& = 1 - 2/3 = 1/3.
\end{align*}
\it The power of the test when $\theta=1$ is
\begin{align*}
\gamma(1) = \prob_{H_1}(T\leq 3/4)
	& = \prob_{H_1}\big[X\leq 2\log(3/2)\big] \\
	& = 1 - e^{-2\log 3/2} \\
	& = 1 - (2/3)^2 = 5/9.
\end{align*}
\een
\end{answer}
\end{questions}
\end{exercise}