How to prove the equation below? [closed]

Consider a matrx $X_{n\times p}$, how to prove equation as follow: $$X(X^{T}X+\lambda^{-1}I_p)^{-1}X^{T}=XX^{T}(XX^{T}+\lambda^{-1}I_n)^{-1}$$

Thanks a lot.


Hint: One approach is as follows. Observe that for any polynomial $f$, we have $$ Xf(X^TX)X^T = XX^Tf(XX^T). $$ Because $X^TX$ and $XX^T$ are diagonalizable with the same non-zero eigenvalues, the minimal polynomial of one divides the other, which means that we will have $$ (XX^T + \lambda^{-1}I_n)^{-1} = f(XX^T)\\ (X^TX + \lambda^{-1}I_p)^{-1} = f(X^TX) $$ for some polynomial $f$.


Another approach, if you'd instead like to use an explicit function instead of an undetermined polynomial, is to note that $$ (X^TX + \lambda^{-1}I_p)^{-1} = \lambda(\lambda X^TX + I_p)^{-1} = \lambda\sum_{k=0}^\infty (-1)^k(\lambda X^TX)^k\\ (XX^T + \lambda^{-1}I_n)^{-1} = \lambda(\lambda XX^T + I_n)^{-1} = \lambda\sum_{k=0}^\infty (-1)^k(\lambda XX^T)^k $$ it is important, however, to note that the infinite series above can only be guaranteed to converge for sufficiently small $\lambda$.


Yet another approach: by the Woodbury matrix identity, we have $$ (X^TX + \lambda^{-1}I_p)^{-1} = \lambda I_p - \lambda^{2}X^T(I_n + \lambda XX^T)^{-1}X $$ It follows that $$ \begin{align*} X(X^TX + \lambda^{-1}I_p)^{-1}X^T &= \lambda XX^T - \lambda^{2}(XX^T)(I_n + \lambda XX^T)^{-1}(XX^T)\\ &= XX^T[\lambda I_n - \lambda(I_n + \lambda XX^T)^{-1}(\lambda XX^T)]\\ &= XX^T[\lambda I_n - \lambda(I_n + \lambda XX^T)^{-1}((I_n + \lambda XX^T) - I_n)]\\ &= XX^T[\lambda I_n - \lambda(I_n + \lambda XX^T)^{-1}(I_n + \lambda XX^T) + \lambda(I_n + XX^T)^{-1}]\\ &= XX^T[\lambda I_n - \lambda I_n + \lambda (I_n + \lambda XX^T)^{-1}]\\ &= XX^T [\lambda (I_n + \lambda XX^T)^{-1}]\\ &= XX^T (\lambda^{-1} I_n + XX^T)^{-1} \end{align*} $$