# How is the kinetic matrix of a Lagrangian defined?

A broad class of Lagrangians is of the form $$L(\mathbf q,\dot{\mathbf q})= \frac{1}{2}\sum_{i,j}g_{ij} \dot q^i \dot q^j - V(\mathbf q)$$

where $g_{ij}$ are the components of a (generally $\mathbf q$-dependent) symmetric bilinear form; this is the "kinetic matrix" to which the other question refers. In this class of Lagrangians, the canonical momentum components are given by

$$p_i = \frac{\partial L}{\partial \dot q^i} = g_{ij} \dot q^j$$

In order for the Legendre transform to be well-defined, $g_{ij}$ must be non-degenerate (and hence invertible), in which case the Hamiltonian is given by

$$H(\mathbf q,\mathbf p) = \frac{1}{2} (g^{-1})^{ij}p_i p_j + V(\mathbf q)$$ In the case that $g_{ij}$ is degenerate, the naive Legendre transform fails to be well-defined (as is the case in your linked question) and one must be more careful.

I totally concur with J. Murray's explanation, which is excellent, IMO. But because you seem to be somewhat in the darkness about where the need for a matrix *comes from* in the Lagrangian formalism, let me add an approach which is to be understood as complementary of the previous one.
Let's say your mechanical system has $n$ Cartesian coordinates.
The Lagrangian is $T-V$, $T$ being the kinetic energy, and $V$ the potential energy. You can convince yourself that the Lagrangian formalism gives you Newton's equations quite easily.
Now, suppose you want to describe your system's motion in terms of more convenient variables, say $q_i$. These are generally called "generalised coordinates".
If you change variables and use basic results of calculus, you get,
$$
\frac{1}{2}\sum_{i}m_{i}\dot{x}_{i}^{2}=
$$
$$\frac{1}{2}\sum_{i}m_{i}\dot{x}_{i}\dot{x}_{i}=\frac{1}{2}\sum_{i=1}^{n}m_{i}\sum_{j=1}^{r}\frac{\partial x_{i}}{\partial q_{j}}\dot{q}_{j}\sum_{k=1}^{r}\frac{\partial x_{i}}{\partial q_{k}}\dot{q}_{k}=
$$
$$
=\frac{1}{2}\sum_{j,k=1}^{r}\left(\sum_{i=1}^{n}m_{i}\frac{\partial x_{i}}{\partial q_{j}}\frac{\partial x_{i}}{\partial q_{k}}\right)\dot{q}_{j}\dot{q}_{k}
$$
By calling,
$$
g_{jk}=\sum_{i=1}^{n}m_{i}\frac{\partial x_{i}}{\partial q_{j}}\frac{\partial x_{i}}{\partial q_{k}}
$$
you can see that a matrix naturally arises in the kinetic part when you try to free Newton's formalism from the chains of having to express everything in terms of Cartesian coordinates. I hope that helps explain the *raison d'être* you're looking for.

PS: In general $r\leq n$ (the number of generalised coordinates is less or equal than $n$, the number of Cartesian coordinates, because there may be constraints.)