**The setting-a "linear algebra" fact:**

Let $A$ be a real $n \times n$ matrix, and suppose that $\det A<0$ and that the singular values of $A$ are *distinct*. Then, there exist a *unique* matrix $Q(A) \in \text{SO}_n$ which is closest to $A$.

(Closest w.r.t the Frobenius norm, i.e. the standard Euclidean distance). Furthermore, if we define $$V=\{ A \in \mathbb{R}^{n^2} \, | \,\, A \in \text{GL}_n^- \, \, \text{and has distinct singular values}\},$$ then the map $A \to Q(A)$, considered as a map $V \to \text{SO}_n$, is smooth. (There is explanation at the end, if you are interested).

**Differential geometry:**

Let $\mathbb{D}^n$ be the closed $n$-dimensional unit ball ,and let $f:\mathbb{D}^n \to \mathbb{R}^n$ be real-analytic . Set $$U= \{ p \in \mathbb{D}^n \, | \, df_p \in \text{GL}_n^- \, \, \text{and has distinct singular values.}\}$$

**Assume that $U$ has full measure in $ \mathbb{D}^n$.**

For every $p \in U$, let $q_p:=Q(df_p) \in \text{SO}_n$ be the unique special orthogonal matrix which is closest to $df_p$. By our assumption, $q$ is well-defined a.e. on $\mathbb{D}^n$.

Question:Can we say something non-trivial about the distributional gradient of $q$? What can we say about the difference between the distributional gradient and the classical gradient, which is defined everywhere on $U$? e.g. does it have a definite sign?

As I will now explain, $q$ does not always lie in a Sobolev space, even though $q|_U$ is smooth; when we approach points where $df$ has repeating singular values, bad "jumps" can occur: Indeed, set

$A=\begin{pmatrix} -\sigma_1 & 0 \\\ 0 & \sigma_2 \end{pmatrix}$. Then $$Q(A) = \begin{cases} \text{Id}, & \text{if } \, 0<\sigma_1 < \sigma_2 \\ -\text{Id}, & \text{if } \, 0<\sigma_2 < \sigma_1 \end{cases},$$ thus when $\sigma_1,\sigma_2$ "cross" each other, we get a jump in $Q$.

Here is a concrete example: Consider $f(x,y)=(-x-\frac{x^2}{2},y+\frac{y^2}{2})$ as a function on $B_{\epsilon}(0)$ (the ball with radius $\epsilon$ centered at the origin): Then $$df(x,y)=\begin{pmatrix} -(1+x) & 0 \\\ 0 & 1+y \end{pmatrix},$$

hence $q=Q(df)=\begin{cases} \text{Id}, & \text{if } \, x < y \\ -\text{Id}, & \text{if } \, y < x \end{cases}$

does not belong to $W^{1,p}(B_{\epsilon} (0),\mathbb{R}^{4})$ for any $p \ge 1$.

*Explanation on why $q$ is smooth on $U$:*

For $p \in U$, $q_p$ can be expressed as follows: Let $df=U\Sigma V^T$ be the SVD of $df$. Then $q=UD V^T$, where $D$ is a diagonal matrix obtained from $\Sigma$, by replacing the smallest singular value with $-1$, and all other singular values by $1$. Since locally, we can choose the matrices $U,V$ smoothly, this implies that $q$ is smooth on $U$.