KAK decomposition of $SL(2,\mathbb{R})$ I am trying to understand the proof of KAK decomposition of $SL(2,\mathbb{R})$ from the following text:

I am a bit confused about the rotation around $i$ part. How exactly do we know what amount of stretching needs to be done and after that how do we determine the $U_1$ matrix? A detailed explanation is most welcome. Thanks.
 A: $D_K(i)=Ki$ must be the same (hyperbolic) distance from $i$ that $Ai$ is, so $K=d(i,Ai)$.
The geodesic between $i$ and $Ai$ intersects the imaginary axis at the angle $\theta$ which defines $U_1$, and lies as an arc on a semicircle whose diameter is on the real axis. Say the center of the semicircle is $c\in\mathbb{R}$; you can solve for $c$ by setting the (Euclidean) distance between $c$ and $i$ equal to that of $c$ and $Ai$ (this yields a quadratic equation). Once you have $c$, you can determine the angle $\theta$: drawing the right triangle between $0,i,c$ you see that $\theta=\cot^{-1}c$.
A: I want to add an answer which uses similar computations in the Poincare disk model.
We want to prove that given any $A\in SL(2,\mathbb{R}),\exists P,Q\in SO(2,\mathbb{R})$ and a diagonal matrix $\Delta\in SL(2,\mathbb{R})$ with diagonal entries $e^{t/2},e^{-t/2}$ for some $t\geq 0$ such that $A=P\Delta Q.$
We know that $SL(2,\mathbb{R})$ acts transitively on the upper half plane $\mathbb{H}.$ Moreover w.r.t. this action Stab$(i)=SO(2,\mathbb{R}):$
$M=\begin{pmatrix}a&b\\c&d\end{pmatrix}$ fixes $i\Leftrightarrow \frac{ai+b}{ci+d}=i\Leftrightarrow ai+b=-c+di\Leftrightarrow a=d,c=-b\Leftrightarrow M=\begin{pmatrix}a&b\\-b&a\end{pmatrix}\in SO(2,\mathbb{R}).$
Now using the Cayley transform $\tau:\mathbb{H}\rightarrow \mathbb{D},\hspace{0.5 ex} z\mapsto \frac{z-i}{z+i},$ we'll see this action on $\mathbb{D}.$ $\tau$ is the Möbius transformation associated to the matrix $C=\begin{pmatrix}1&-i\\1&i\end{pmatrix}.$ Now elements of $SL(2,\mathbb{R})$ acts on $\mathbb{D}$ by conjugation. Let's see what an element $A=\begin{pmatrix}a&b\\c&d\end{pmatrix}$ corresponds to under this conjugation.
$A=\begin{pmatrix}a&b\\c&d\end{pmatrix}\mapsto CAC^{-1}=\frac{1}{2i}\begin{pmatrix}1&-i\\1&i\end{pmatrix}\begin{pmatrix}a&b\\c&d\end{pmatrix}\begin{pmatrix}i&i\\-1&1\end{pmatrix}$
$\Delta=\begin{pmatrix}e^{t/2}&0\\0&e^{-t/2}\end{pmatrix}\mapsto \frac{1}{2i}\begin{pmatrix}1&-i\\1&i\end{pmatrix}\begin{pmatrix}e^{t/2}&0\\0&e^{-t/2}\end{pmatrix}\begin{pmatrix}i&i\\-1&1\end{pmatrix}=\frac{1}{2}\begin{pmatrix}e^{t/2}+e^{-t/2}&e^{t/2}-e^{-t/2}\\e^{t/2}-e^{-t/2}&e^{t/2}+e^{-t/2}\end{pmatrix}$
$P_\theta:=\begin{pmatrix}\text{cos}\theta&-\text{sin}\theta\\\text{sin}\theta&\text{cos}\theta\end{pmatrix}\mapsto\frac{1}{2i}\begin{pmatrix}1&-i\\1&i\end{pmatrix}\begin{pmatrix}\text{cos}\theta&-\text{sin}\theta\\\text{sin}\theta&\text{cos}\theta\end{pmatrix}\begin{pmatrix}i&i\\-1&1\end{pmatrix}=\begin{pmatrix}e^{-i\theta}&0\\0&e^{i\theta}\end{pmatrix}$
Now the Cayley transform takes $i$ to $0$. So, under this induced action, Stab$(0)=SO(2,\mathbb{R}).$ We notice that $\Delta\cdot  0=\frac{e^{t/2}-e^{-t/2}}{e^{t/2}+e^{-t/2}}=\frac{e^t-1}{e^t+1}$ and for any $z\in\mathbb{D},P_\theta\cdot z=e^{-2i\theta}z.$ So, the elements of $SO(2,\mathbb{R})$ correspond to rotations by the elements of $S^1$ on $\mathbb{D}.$ Now for $|A\cdot 0|=r<1,$ we choose $t\geq0,$ namely $t=\text{log}\big(\frac{1+r}{1-r}\big)$ such that $\frac{e^t-1}{e^t+1}=r.$ Then we apply an appropriate rotation such that $P_\theta\cdot\big(\Delta\cdot 0\big)=A\cdot 0.$ So, $A^{-1}P_\theta \Delta$ takes $0$ to $0$. Hence $A^{-1}P_\theta \Delta\in SO(2,\mathbb{R}).$ $\therefore\exists\hspace{0.5 ex} P,Q\in SO(2,\mathbb{R})$ such that $A=P\Delta Q.$
