Let $G:\mathbb{R}^n\to\mathrm{Mat}_n(\mathbb{R})$ be a matrix field (taking values in positive matrices) and define for any curve $\gamma:[0,1]\to\mathbb{R}^n$ the following number: $$ Q_G(\gamma) := \int\limits_0^1\langle\gamma',G(\gamma)\gamma'\rangle\,\mathrm{d}t.\label{1}\tag{1} $$
This expression appears for example, when calculating the kinetic energy on a manifold (this would the expression already in a coordinate chart, in which $G$ is the metric).
What I am looking for is the following: what is the appropriate procedure to diagonalize this when $G\neq I$? When $G$ is just the constant identity-matrix field, then we can employ integration by parts to obtain (assuming $\gamma(0)=\gamma(1)=0$): $$ Q_I(\gamma)=\int\limits_0^1\langle\gamma,-\gamma''\rangle\,\mathrm{d}t. $$ Then we can plug in an orthonormal basis of $-\partial^2$ with Dirichlet boundary conditions on $(0,1)$ to rewrite this as $$ Q_I(\gamma)=\sum_n a_n^2E_n $$ where $E_n$ are the eigenvalues of $-\partial^2$ and $a_n$ are the expansion coefficients of $\gamma$.
How to proceed in a similar way for equation \eqref{1}? What is the formalism one employs in that non-linear scenario?