TITLE: Is there a smooth polar decomposition for non-invertible matrices?
QUESTION [5 upvotes]: Every $n \times n$ real matrix $A$ has a polar decomposition $A=OP$, where $O \in O_n, P$ is symmetric positive semi-definite.
$P$ is uniquely determined by $A$, by $P(A)=\sqrt{A^TA}$,
and when $A$ is invertible $O$ is also unique, given by $O=A(\sqrt{A^TA})^{-1}$.
When $A$ is not invertible, then $O$ is non-unique.
Question:
Can we choose a smooth polar factor $O(A)$ for all non-zero matrices $A$ with non-negative determinant? 
More precisely, denote by $M_n^+$ the set of matrices with non-negative determinant. 
Is there a smooth function $O:M_n^+ \setminus \{0\} \to O_n $ such that for every $A \in M_n^+ \setminus \{0\}$, $A=O(A)P(A)=O(A)\sqrt{A^TA}$?
Remarks:
1) We know that such a function, if exists, must give to each $A \in GL_n^+$ its unique polar factor. 
2) The reason we exluded the zero matrix is that continuity implies two contradictory evaluations:
$O(0)=\lim_{t \to 0^+} O(\left(\begin{matrix}t & 0 \\ 0 & t\end{matrix}\right))=I$, 
$O(0)=\lim_{t \to 0^+}=O(\left(\begin{matrix}0 & -t \\ t & 0\end{matrix}\right))=\left(\begin{matrix}0 & -1 \\ 1 & 0\end{matrix}\right)$
3) The reason we had to restrict to $M_n^+ \setminus \{0\}$ (instead of working with all $M_n \setminus \{0\}$) is connectedness issues. 
$M_n\setminus \{0\}$ is connected (for $n >1$). However for $O|_{O_n}=Id_{O_n}$, so if we insisted to take the domain to be all $M_n \setminus \{0\}$, the image would be $O_n$ which is disconnected.
The restriction in fact implies that $O$ is a function into $SO_n$.

REPLY [6 votes]: To take user35593's comment to fruition:

There is a unique continuous extension of the polar decomposition from $GL^+_n$ to the portion of its boundary consisting of matrices with nullity 1. 

Why is the polar decomposition non-unique when $A$ is non-invertible?
Suppose $A = OP$ and $P$ has non-trivial kernel. Then if $\Omega$ is any orthogonal matrix that acts as the identity on $\mathrm{ker}(P)^\perp$, then $O\Omega P$ is another polar decomposition. And it is easy to see that this freedom is the extent of non-uniqueness: if $A = OP = \tilde{O} P$, then $O^{-1} \tilde{O}$ is an orthogonal matrix that acts as the identity on $\mathrm{ker}(P)^\perp$. 
When the kernel of $A$ (equivalently kernel of $P$) is one dimensional, then the only possibility for $\Omega$ is the matrix that is the identity on $\mathrm{ker}(P)^\perp$ and $-1$ on $\mathrm{ker}(P)$. 
Proof of claim
Now, since $\det A = \det O \det P$ and we know that $\det P \geq 0$, when we restrict to $GL_n^+$ we must have that $\det O > 0$. That is, on $M_n^+$ we can require the matrix $O$ in the polar decomposition to be not only orthogonal, but in fact in $SO_n$. And for rank $n-1$ matrices only one of $O$ and $O\Omega$ can fulfill that criterion. And it is easy to check that this is the continuous extension from $GL_n^+$. 
Remark: if you extend from $GL_n^-$ you will pick up the other one. An illustrative example is the rank $1-1 = 0$ matrix $(0)\in M_1$. Approaching from $M_1^+$ the continuous limit of the polar decomposition gives $$ (0) = (1)(0)$$
while approaching from $M_1^-$ the continuous limit of the polar decomposition gives 
$$ (0) = (-1)(0). $$
Differential geometry
To answer this question in the comments: no, when $n > 1$ the set $M_n^+$ is should not be thought of as a (smooth) submanifold with boundary; it is better described as a manifold with corners. This is precisely what you outlined in your post with the different limiting directions approaching the zero matrix. 
But in a neighborhood of (topological) boundary points which have rank $n-1$, the set $M_n^+$ does look like a manifold with boundary: in a neighborhood of a rank $n-1$ matrix, the function $\det: M_n\to \mathbb{R}$ has non-vanishing derivative, and so can be used as a defining function for a hypersurface.