# Trace of "quadratic form"-like expression involving orthonormal vector fields and their Jacobian

Let $$f\in C^{\infty}(\mathbb{R}^D, \mathbb{R}^K)$$ be a smooth function whose Jacobian matrix $$Df$$ has full rank on $$M=\{x\in \mathbb{R}^D: f(x)=\vec{0}\}$$. We take the convention that the rows of the Jacobian are the transposes of the gradients of the components of $$f$$. Let $$N(x)$$ be the matrix obtained by orthonormalizing the rows of of $$Df(x)$$, so that $$N(x)N(x)^T=I_{K\times K}$$.

Question: Is it always true that $$\operatorname{Tr}(N D[n_r] N^T)=0$$?

When $$K=1$$, we can prove this is indeed true. In this case, we have $$n=\nabla f/\|\nabla f\|$$ and we just have to show $$n^T D[n]n=0$$. It is relatively straightforward to show that $$D[n]n = \frac{1}{\|\nabla f\|} (\nabla^2 f) n- \frac{1}{\|\nabla f\|}\left(n^T (\nabla^2 f)n\right)n.$$ Multiplying this on the right by $$n^T$$ gives $$n^T D[n]n = \frac{1}{\|\nabla f\|} n^T(\nabla^2 f) n- \frac{1}{\|\nabla f\|}n^T\left(n^T (\nabla^2 f)n\right)n.$$ $$=:\frac{1}{\|\nabla f\|} v- \frac{1}{\|\nabla f\|}n^Tvn.$$ where we have written $$v:=n^T(\nabla^2 f)n$$ for convenience. Now, $$v$$ is just a scalar, so we can rewrite the second term as $$\frac{1}{\|\nabla \|} vn^T n = \frac{v}{\|\nabla f\|},$$ since $$n^Tn=1$$ due to $$n$$ being a unit-normal vector. Thus we obtain $$n^T D[n]n = \frac{1}{\|\nabla f\|} v - \frac{1}{\|\nabla f\|} v=0,$$ as claimed.

When $$K>1$$, it is a lot more difficult to follow one's nose here...

Update 8/31/2023 Fix $$r$$ and $$r'$$ in $$\{1,2,\dotsc, K\}$$. Using linearity and product rule, we can show that, since $$n_r^Tn_{r'} = \delta_{rr'}$$ $$D[n_r]^Tn_{r'}=-D[n_{r'}]^Tn_r,$$ hence $$D[n_r]^T n_r = \vec{0}$$. It follows that $$(ND[n_r]N^T)_{ij} = -n_r^T D[n_i]n_j,$$ hence $$\operatorname{Tr}(ND[n_r]N^T) = -\sum_{j=1}^K n_r^T D[n_j]n_j$$ $$=-\sum_{j\neq r} n_r^T D[n_j]n_j,$$ since $$D[n_r]^T n_r=\vec{0}$$, hence we know $$n_r^T D[n_r]n_r = (D[n_r]^T n_r)^T n_r = \vec{0}^T n_r = 0$$. But it is difficult for me to see anything else.

Update 9/1/2023 Let's assume there exists a vector $$v(x)$$ such that $$P(x)v(x) = \sum_{k=1}^K D[n_k(x)]n_k(x),$$ where $$P(x)=I-N(x)^T N(x)$$ is the orthogonal projection onto $$T_xM$$ the tangent space of $$M$$ at $$x$$. Then from the previous update, we have with $$r=i$$ and $$r'=k$$, $$n_k^TD[n_i] = -n_i^T D[n_k]$$ hence multiplying on the right by $$n_k$$ gives $$n_k^T D[n_i] n_k = -n_i^T D[n_k]n_k,$$ so that summing from $$k=1$$ to $$K$$ gives $$\operatorname{Tr}(N D[n_i] N^T) = -n_i^T \left(\sum_{k=1}^K D[n_k]n_k\right)$$ $$= -n_i^T Pv,$$ but $$Pv$$ lies in $$T_xM$$ and obviously $$n_i \perp u$$ for any $$u\in T_xM$$. Thus $$-n_i^T Pv = 0$$ hence this trace term is zero, $$\operatorname{Tr}(ND[n_i]N^T)=0,$$ for $$i=1,2,\dotsc, K$$.

So, now my questions are:

1. taking the assumption for granted, is this argument sound and valid?
2. Is the assumption true? I have essentially already asked it in this question and just made the connection today between the two. There $$v=\nabla \log p$$ where $$p$$ solves the steady-state Fokker-Planck equation of the process satisfying $$dX_t = P(X_t)\circ dB_t$$. I have proven it in the case $$K=1$$, in which then $$p$$ is proportional to $$\|\nabla f\|$$.