(snip)
Looking at your non-TEX formulae it looks like you are solving normal equations. Your problem is linear.
[$]Ax = b[$]
least squares solution solve
[$]A^{\rm T} Ax = A^{\rm T}b[$]
in your case K = A, P = x, Y = x, yes?
as cuch said, with least squares, you solve [$]A^{\rm T} Ax = A^{\rm T}b[$] and [$]A^{\rm T} A[$] IS square1) As I understand this, in this example the matrix to be factored or inverted isn't square.
you can solve the linear system [$]A^{\rm T} Ax = A^{\rm T}b[$] by matrix inversion if you want to, but it's a lot quicker to use row-reduction techniques (Gauss-Jordan).