Solution $X$ for $X(X^TX)^{-1}=X(Y^TY)^{-1}$

I have a square matrix $$Y$$ and I would like to find the solution $$X$$ for the following equation: $$X(X^TX)^{-1}=X(Y^TY)^{-1}$$

In this equation, we can suppose that $$Y^TY$$ is invertible. We could also rewrite the equation as: $$X\left(I-(Y^TY)^{-1}X^TX\right)=0$$ if this could be useful, at least there is no requirement that $$X^TX$$ is invertible in this form.

Is this a common equation or one where the solution is straightforward to write?

EDIT

As suggested in the comments, $$X=Y$$ will probably work!

• How about using X=Y? Commented Sep 4, 2022 at 23:37
• Probably worth a try! Indeed I am sometimes looking for a complex answer to a so simple question...
– PC1
Commented Sep 5, 2022 at 0:03
• There is more than one solution; for instance, $X = QY$ for every orthonormal $Q$. So it would be better to specify if you want a solution, or to describe all solutions. Commented Sep 5, 2022 at 11:43
• I am looking for any solution as the important matrix is $X^TX$. So the ease of computation is more my concern here. Any solution is acceptable (so $X=Y$ is good).
– PC1
Commented Sep 5, 2022 at 17:53

Notice that $$X(X^T X)^{-1}$$ is the Moore-Penrose inverse of $$X^T$$. Using properties of pseudo-inverse we get
$$(Y^TY)(X^T X)^\dagger = I$$
For instance $$X=Y$$ or $$X=\text{Cholesky}(Y^T Y)$$