Hamiltonian formalism in Goldstein's matrix representation, chap. 8.1 There are several points over which I stumble when studying Goldstein, 3rd ed., chap 8.1, concerning the matrix representation of the hamiltonian formalism. In (8.22) he assumes the lagrangian to be (with Einstein's convention)
$ L(q_i,\dot{q}_i,t)=L_0(q,t)+ \dot{q}_i a_i (q,t)+ \dot{q}^2_i T_i(q,t). \qquad \qquad $ (1)
From this he derives the corresponding matrix representation
$ L(q_i,\dot{q}_i,t)=L_0(q,t)+ \mathbf{\tilde{\dot{q}}} \mathbf{a} + \frac{1}{2} \mathbf{\tilde{\dot{q}}} \mathbf{T} \mathbf{\dot{q}} \qquad \qquad $ (2)
with the row vectors being denoted by a tilde and $ \mathbf{T} $ being an $ n \times n $ matrix. I understand the term $ \dot{q}^2_i T_i(q,t) $ to be a quadratic form representing the kinetic energy of the system. In matrix representation this can be written as $ \mathbf{\tilde{\dot{q}}} \mathbf{T} \mathbf{\dot{q}} $.
Q1: But where does the factor $ \frac{1}{2}  $ in (2) come from?
Q2: Goldstein says that the symmetrical matrix $ \mathbf{T} $ is most often a diagonal matrix, but not always. But according to the term $ \dot{q}^2_i T_i(q,t) $, it must be a diagonal matrix, doesn't it? So what does Goldstein mean here? In which cases is it not diagonal?
From (2) Goldstein derives the hamiltonian to be
$ H = \mathbf{\tilde{\dot{q}}} (\mathbf{p}-\mathbf{a}) - \frac{1}{2} \mathbf{\tilde{\dot{q}}} \mathbf{T} \mathbf{\dot{q}} -L_0.  \qquad \qquad $ (3)
Q3: But it remains totally unclear to me how from this he gets
$ \mathbf{p} = \mathbf{T} \mathbf{\dot{q}} + \mathbf{a}  $.
Goldstein's wording here is obscure to me, too.
Finally, Goldstein says that $ \mathbf{T} $ is invertible because of the "positive definite property of the kinetic energy". I assume he means that with respect to the quadratic form $ \dot{q}^2_i T_i(q,t) $, and I assume that this means, the corresponding matrix $ \mathbf{T} $ is positive definite, too (although I cannot find this equivalence in wikipedia).
Q4: Do we see the positive definite property directly from this term $ \dot{q}^2_i T_i(q,t) $, and if yes, how? Or are we making additional assumptions here about the kinetic energy? I also cannot find in wikipedia the relationship between a positive definite matrix and its invertability.
Can anyone help me back on the track?
 A: *

*Qmechanic is correct, eq. (1) has a typo and should have a factor of $1/2$ in front of the $T$. If you don't find this satisfactory, then you might also argue that the $T$ in (1) has not been properly defined yet, so that multiplicative factors are irrelevent. In eq. (2), we then choose $\mathbf{T}$ to have a coefficient of $1/2$. This is handy for calculations such as
$$
\frac{\partial}{\partial\dot{\mathbf{q}}}\left(\dot{\mathbf{q}}^T\mathbf{T}\dot{\mathbf{q}}\right) = 2\mathbf{T}\dot{\mathbf{q}}
$$
as the factors of $2$ will cancel. I promise there is nothing physical about the erroneous factor!


*$\mathbf{T}$ is positive definite and symmetric and so it is always possible to find a basis $\mathbf{q}$ in which it is diagonal. In the diagonal basis we can write $\mathbf{T} = \text{diag}(T_{11}, \ldots, T_{nn})$ and then the quadratic form is
$$
\dot{\mathbf{q}}^T\mathbf{T}\dot{\mathbf{q}} = \dot{q}_i T_{ij} \dot{q}_j = \sum_i  \dot{q}_i T_{ii} \dot{q}_i \sim \dot{q}_i^2 T_{i}(q, t)
$$
where the last part is simply a shorthand for a diagonal quadratic form.
In summary, the answer to your questions 1 and 2 is that Goldstein's equation (8.22) is really a shorthand for the more technically correct
$$
L(q_i, \dot{q}_i, t) = L_0(q, t) + \dot{q}_i a_i(q, t) + \frac{1}{2}\dot{q}_i T_{ij}(q, t) \dot{q}_j.
$$


*This follows directly from the definition
$$
\mathbf{p} = \frac{\partial L}{\partial \dot{\mathbf{q}}}
$$
and equation (1). In case you aren't too comfortable with index manipulations, the calculation is
\begin{align}
p_k &= \frac{\partial L}{\partial \dot{q}_k} =  \frac{\partial}{\partial \dot{q}_k} \left(L_0(q, t) + \dot{q}_i a_i(q, t) + \frac{1}{2}\dot{q}_i T_{ij}(q, t) \dot{q}_j \right) \\
&= \delta_{ik}a_i(q, t) + \frac{1}{2}\left(\delta_{ik}T_{ij}q_{j} + q_i T_{ij}\delta{jk}\right) \\
&= a_k(q, t) + T_{kj}q_j.
\end{align}


*Physically, the kinetic energy must be positive or bad things will happen e.g. infinitely accelerated motion. This means that the quadratic form $\dot{q}_i T_{ij}(q, t) \dot{q}_j$ must be positive definite, which is equivalent to all the eigenvalues $\lambda_i$ of $T$ being positive. Since $T$ is symmetric, it has a basis of eigenvectors. Thus $\det \mathbf{T} = \prod_i \lambda_i >0$ which is non-zero so $\mathbf{T}$ is invertible.
A: The Hamiltonian is:
$$H=\boldsymbol p^T\,\dot{\boldsymbol{q}}-L(\boldsymbol q~,\boldsymbol p)$$
with
$$L=L_0(\boldsymbol q)+\dot{\boldsymbol{q}}^T\,\boldsymbol a+\frac 12 \dot{\boldsymbol{q}}^T\,\boldsymbol T\,\dot{\boldsymbol{q}}$$
Step I
$$\boldsymbol p=\frac{\partial L}{\partial \dot{\boldsymbol{q}}}=\boldsymbol T\,\dot{\boldsymbol{q}}+\boldsymbol a$$
$\Rightarrow$
$$\dot{\boldsymbol{q}}=\boldsymbol T^{-1}(\boldsymbol p-\boldsymbol a)$$
Step II
$$L(\boldsymbol p~,\boldsymbol q)=
L_0(\boldsymbol q)+\boldsymbol a^T\,\boldsymbol T^{-1}(\boldsymbol p-\boldsymbol a)\,+\frac 12 \dot{\boldsymbol{q}}^T\,\boldsymbol T\,\dot{\boldsymbol{q}}$$
Thus:
$$H=\underbrace{(\boldsymbol T\,\dot{\boldsymbol{q}}+\boldsymbol a)^T\,(\boldsymbol T^{-1}(\boldsymbol p-\boldsymbol a))}_{Z}\,
-\left[L_0(\boldsymbol q)+\boldsymbol a^T\,\boldsymbol T^{-1}(\boldsymbol p-\boldsymbol a)\,+\frac 12 \dot{\boldsymbol{q}}^T\,\boldsymbol T\,\dot{\boldsymbol{q}}\right]$$
$$Z=(\dot{\boldsymbol{q}}^T\,\boldsymbol T^T+\boldsymbol a^T)\,\boldsymbol T^{-1}(\boldsymbol p-\boldsymbol a)=\dot{\boldsymbol{q}}^T\,(\boldsymbol p-\boldsymbol a)
+\boldsymbol a^T\,\boldsymbol T^{-1}(\boldsymbol p-\boldsymbol a)$$
with $~\boldsymbol T^T=\boldsymbol T~,\boldsymbol T~$ is symetric.
thus:
$$H=\dot{\boldsymbol{q}}^T\,(\boldsymbol p-\boldsymbol a)-\left[L_0(\boldsymbol q)+
\frac 12 \dot{\boldsymbol{q}}^T\,\boldsymbol T\,\dot{\boldsymbol{q}}\right]~\surd$$
remarks:
the kinetic for particle is:
$$T_K=m\,\frac 12\boldsymbol v^T\,\boldsymbol v$$
where $~v$ is the velocity
$$\boldsymbol v=\underbrace{\frac{\partial \boldsymbol R(\boldsymbol{q})}{\partial \boldsymbol q}}_{\boldsymbol J}\,\dot{\boldsymbol{q}}$$
where $\boldsymbol R$ is the position vector of the particle
thus
$$T_K=m\,\frac 12\dot{\boldsymbol{q}}^T\,\boldsymbol J^T\,\boldsymbol J\,\dot{\boldsymbol{q}}$$
so $~\boldsymbol T=\,\boldsymbol J^T\,\boldsymbol J~$ symmetric and positive definite
I use this notation  $~(..)^T~$ T stay for transpose  , for a column vector you get row vector, for a matrix changing rows with column.
