I am reading the lecture notes of EE263 of stanford university. I came across these 2 slides (Please see attached images).
I understand every step up to the second slide where it says "residual with optimal x is".
My question is: why is $Ax_{ls} -y = -Q_2 Q^T_2y$ ? I do not know how this is derived. Can someone show me how this is derived ?

