The normalization of the formula is wrong, but let me propose a fix. Let
$$K_n=\int_{B\subset\Bbb{R^n}}x_1^2\,d\mu$$
be the integral we would get with $T=e_{11}$, the matrix with $1$ at position $(1,1)$ and zeros elsewhere. I think that we then have for all linear transformations $T:\Bbb{R}^n\to\Bbb{R}^n$ that
$$
tr(T)=\frac1{K_n}\int_{B}\langle Tx,x\rangle\,d\mu.
$$
I will think of $T$ as a matrix (use the natural basis). We can equally well use the symmetrized version of $T$, i.e. $(T+T^t)/2$ because the quadratic form $\langle Tx,x\rangle$ stays the same, and the symmetrized version shares the same trace.
Given that $T$ is symmetric the rest is easy. By linear algebra there exists an orthogonal matrix $P$ such that $P^tTP=D$ is a diagonal matrix. Furthermore, $P^t=P^{-1}$ and $\det P=1$. Also, the linear substitution $x\mapsto Px$ preserves the unit ball, because $P$ is length preserving. What this means is that it suffices to prove the formula for a diagonal matrix $D=diag(d_1,d_2,\ldots,d_n)$.
Obviously
$$I_i=\int_{B\subset\Bbb{R^n}}x_i^2\,d\mu=K_n$$
for all $i=1,2,\ldots,n$ by the symmetries of the sphere. By linearity of the integral we then get that
$$
\begin{aligned}
\int_{B\subset\Bbb{R^n}}\langle Dx,x\rangle\,d\mu
&=\int_{B\subset\Bbb{R^n}}(d_1x_1^2+d_2x_2^2+\cdots+d_nx_n^2)\,d\mu\\
&=\sum_{i=1}^nd_i I_i\\
&=tr(D) K_n,
\end{aligned}
$$
and we are done.
In other words, instead of the measure of the $n$-dimensional ball you should factor out the integral of $x_1^2$ over that ball. I'm sure the exact value of $K_n$ is known. May be a friendly physicist calculated the moments of inertia of the $n$-dimensional homogeneous ball? Or a probability person has calculated the expected value of $x_1^2$ of a random point uniformly distributed over that ball?
Orthonormal expansion says that $$x = \sum_{k=1}^n \langle x,e_k\rangle e_k$$for all $x \in V$, provided the basis $\mathcal{B} = (e_k)_{k=1}^n$ is orthonormal (proof: write $x = \sum_{i=1} x_ie_i$ for some coefficients $x_i$ and hit both sides with $\langle \cdot, e_k\rangle$ to obtain $x_k = \langle x,e_k\rangle$). That said, you should recall how the trace is defined:
- pick any basis $\mathcal{B}$ for $V$.
- write each $T(e_j)$ as a combination $\sum_{i=1}^k a_{ij} e_i$, so that you have a matrix $[T]_{\mathcal{B}} = (a_{ij})_{i,j=1}^n$.
- define ${\rm tr}(T) = {\rm tr}[T]_{\mathcal{B}}$, where in the right we have a matrix trace.
- show that the definition above does not depend on the choice of $\mathcal{B}$, by using that the matrix trace is invariant under conjugation.
Now you just want to exploit the fact that the chosen $\mathcal{B}$ is orthonormal. Orthonormal expansion gives $$T(e_j) = \sum_{i=1}^n \langle T(e_j),e_i\rangle e_i.$$So $[T]_{\mathcal{B}} = (\langle T(e_j),e_i\rangle)_{i,j=1}^n$. Then $${\rm tr}(T) = \sum_{i=1}^n \langle T(e_i),e_i\rangle.$$
If the basis is not orthonormal, one needs to write $g_{ij} = \langle e_i,e_j\rangle$ (and $(g_{ij})_{i,j=1}^n$ is no longer necessarily the identity matrix). Then $$x = \sum_{i=1}^n x_i e_i \implies \langle x,e_j\rangle = \sum_{i=1}^n x_i g_{ij} \implies x_i = \sum_{j=1}^n g^{ij}\langle x,e_j\rangle,$$where $(g^{ij})_{i,j=1}^n$ is the inverse matrix of $(g_{ij})_{i,j=1}^n$. So in general we'll have $${\rm tr}(T) = \sum_{i,j=1}^n g^{ij}\langle T(e_i),e_j\rangle.$$This is not a mistake: the trace is given in terms of the inner product by a double sum, which now accounts for the fact that the basis may be non-orthonormal.
Best Answer
Let $A$ be the matrix representation of $f$ with respect to the basis $\{e_i\}$. Then, the trace of $f$ is the sum of the diagonal entries of $A$, of which the $i$-th diagonal entry is $e_i^T A e_i = (e_i^T A) e_i = (A e_i)^T e_i = \langle A e_i, e_i\rangle = \langle f(e_i),e_i\rangle$.
So, you sum up all the $\langle f(e_i),e_i\rangle $'s to get the trace.