# Some questions about the pseudoinverse of a matrix

For every mxn-matrix A with real entries, there exist a unique nxm-matrix B, also with real entries, such that

$$ABA = A$$ $$BAB = B$$ $$AB = (AB)^T$$ $$BA = (BA)^T$$

B is called the pseudoinverse of A. There is also a complex version, but I am only interested in the real one. Now my questions :

• If A has rational entries, must B also have rational entries ?
• How can I calculate the pseudoinverse of a matrix with PARI/GP ?
• Is there a simple method to calculate the pseudoinverse by hand for small matrices ?
• Under which condition are the entries of the pseudoinverse integers ?

I know some special properties, for instance, that for invertible square matrices A, the pseudoinverse is simply $A^{-1}$ , or that the pseudoinverse of a zero-matrix is its transposition, but I have not much experience with general pseudoinverses.

For your first question, by elementary row and column operations, every matrix $A$ over the rationals can be written as a matrix product of the form $PDQ$, where $P$ and $Q$ are products of elementary matrices with rational entries and $D$ is a rectangular diagonal matrix over the rationals. It follows that $A^+ = Q^{-1}D^+P^{-1}$ and you are essentially asking if $D^+$ is rational. The answer should be trivial.
For your third question, if $A$ is at most $3\times3$, you may try the formula $$A^+ = \lim_{\delta \searrow 0} (A^\top A + \delta I)^{-1} A^\top = \lim_{\delta \searrow 0} A^\top (A A^\top + \delta I)^{-1}.$$