<s>[INST] Geometry problem (find QS) Could someone help with this one? Been trying it for days, no success until now. 

Consider the picture above, in which $ABCD$ is a square, $\angle DCQ = 45^\circ$, $\overline{AS} = 12$ and $\overline{DS} = 6$. Calculate the length of $\overline{QS}$.
(a) $6+ 3\sqrt{6}$
(b) $2+3\sqrt{6}$
(c) $6+\sqrt{6}$
(d) $3+6\sqrt{6}$
(e) $3+3\sqrt{6}$
 [/INST] Hint.
Given $L$ the square side and $\theta$ the square rotation
$$
L\cos(\theta)+L_0\cos(\theta+45^{\circ})=12\\
\left(L\sin(\theta)\right)^2+\left(L_0\cos(\theta+45^{\circ})\right)^2 = 6^2
$$
solving this you have the values for $L$ and $\theta$
so
$$
QS = L\sin(\theta)+L_0\sin(\theta+45^{\circ})
$$
NOTE
Here $L_0 = \frac{L}{\sqrt 2}$
To solve this we have
$$
\frac{3}{2} L \cos (\theta )-\frac{1}{2} L \sin (\theta )=12\\
\frac{1}{2} L^2 \sin ^2(\theta )-\frac{1}{2} L^2 \cos ^2(\theta )-\frac{1}{2} L^2 \sin (\theta ) \cos (\theta )+\frac{3 L^2}{4}=36
$$
or
$$
\frac{3 c}{2}-\frac{s}{2}=\frac{12}{L}\\
\frac{s^2}{2}-\frac{1}{2} c^2-\frac{1}{2} s c+\frac{3}{4}=\frac{36}{L^2}
$$
solving for $s, c$ we have
$$
\left(
\begin{array}{cc}
c & s \\
 \frac{12}{L}-\frac{\sqrt{\frac{3}{10}} \sqrt{-L^2 \left(L^2-144\right)}}{L^2} & -\frac{3 \left(\sqrt{30} \sqrt{-L^2 \left(L^2-144\right)}-40
   L\right)}{10 L^2} \\
 \frac{\sqrt{\frac{3}{10}} \sqrt{-L^2 \left(L^2-144\right)}}{L^2}+\frac{12}{L} & \frac{3 \left(40 L+\sqrt{30} \sqrt{-L^2
   \left(L^2-144\right)}\right)}{10 L^2} \\
\end{array}
\right)
$$
now using $c^2+s^2=1$ we have
$$
\left\{
\begin{array}{rcl}
 -\frac{48 \sqrt{\frac{6}{5}} \sqrt{-L^2 \left(L^2-144\right)}}{L^3}+\frac{720}{L^2}-4&=&0 \\
 \frac{48 \left(75 L+\sqrt{30} \sqrt{-L^2 \left(L^2-144\right)}\right)}{5 L^3}-4&=&0 \\
\end{array}
\right.
$$
giving
$$
L = \left\{
\begin{array}{c}
 \sqrt{\frac{1}{5} \left(13-2 \sqrt{6}\right)} \\
 \sqrt{\frac{468}{5}+\frac{72 \sqrt{6}}{5}} \\
\end{array}
\right.
$$
finally substititing the values for $c,s,L$ in
$$
QS = \frac{c L}{2}+\frac{3s L}{2}
$$
we obtain
$$
QS = 6+3\sqrt 6
$$
</s>