How to solve the least squares for A with both X and Y as matrices?

88 Views Asked by At

I’m trying to solve the following problem: I have a series of n-dimensional vectors x and another of m-dimensional vectors y, so that y = Ax, with A being a m,n matrix. I have to solve the least squared problem ||AX-Y||^2 for A. X is a matrix with its columns being x vectors, and the same happens with Y.

The problem I have comes with derivation ||AX-Y||^2. I am not very experienced with matrix calculus, so I have resorted to doing a sort of reverse engineering approach by creating some matrices of my own and working backwards. I have obtained that the derivative of ||AX-Y||^2 = 2X[AX-Y], though I am not really sure if that is the correct result. I have tried searching for any kind of solution online but I have found none. Could someone confirm if what I have is right or wrong and explain to me the proper way to solve it?