Apply two iteration of the QR method to the matrix that was given $$ A=\left[\begin{array}{lll} 3 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 & 3 \end{array}\right] $$
Solution: $$ P_1=\left[\begin{array}{ccc} \cos \theta & \sin \theta & 0 \\ -\sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \end{array}\right] \text { so } P_1 A=\left[\begin{array}{ccc} 3 \cos \theta+\sin \theta & \cos \theta+3 \sin \theta & \sin \theta \\ -3 \sin \theta+\cos \theta & -\sin \theta+3 \cos \theta & \cos \theta \\ 0 & 1 & 3 \end{array}\right] $$ The angle $\theta$ is chosen so that $-3 \sin \theta+\cos \theta=0$, that is, so that $\tan \theta=\frac{1}{3} .$ Hence $$ \cos \theta=\frac{3 \sqrt{10}}{10} . \quad \sin \theta=\frac{\sqrt{10}}{10} $$ and $$ P_1 A=\left[\begin{array}{ccc} \frac{3 \sqrt{10}}{10} & \frac{\sqrt{10}}{10} & 0 \\ -\frac{\sqrt{10}}{10} & \frac{3 \sqrt{10}}{10} & 0 \\ 0 & 0 & 1 \end{array}\right]\left[\begin{array}{ccc} 3 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 & 3 \end{array}\right]=\left[\begin{array}{ccc} \sqrt{10} & \frac{3}{5} \sqrt{10} & \frac{1}{10} \sqrt{10} \\ 0 & \frac{4}{5} \sqrt{10} & \frac{3}{10} \sqrt{10} \\ 0 & 1 & 3 \end{array}\right]=A_2 $$ Continuing, we have $$ s=0.36761 \quad \text { and } \quad c=0.92998 $$ So $$ \begin{aligned} R^{(1)} \equiv A_{3}=P_{2} A_{2} &=\left[\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 0.92998 & 0.36761 \\ 0 & -0.36761 & 0.92998 \end{array}\right]\left[\begin{array}{ccc} \sqrt{10} & \frac{3}{5} \sqrt{10} & \frac{\sqrt{10}}{10} \\ 0 & \frac{4 \sqrt{10}}{5} & \frac{3 \sqrt{10}}{10} \\ 0 & 1 & 3 \end{array}\right] \\ &=\left[\begin{array}{ccc} \sqrt{10} & \frac{3}{5} \sqrt{10} & \frac{\sqrt{10}}{10} \\ 0 & 2.7203 & 1.9851 \\ 0 & 0 & 2.4412 \end{array}\right] \end{aligned} $$
I understood how they get values for those rotation matrices but couldn't understand how to determine the form of those matrices like first $P_1=\left[\begin{array}{ccc} \cos \theta & \sin \theta & 0 \\ -\sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \end{array}\right]$ and $P_2=\left[\begin{array}{ccc} 1 & 0 & 0 \\ 0 & \cos \theta & -\sin \theta \\ 0 & \sin \theta & \cos \theta \end{array}\right]$. Is there any general form (like to decompose $m\times n$ matrix) to remember?
Like what will be the form if I want to zero the $d,g$ and $h$ respectively. $$ \left[\begin{array}{lll} a & b & c \\ d & e & f \\ g & h & i \end{array}\right] $$