# Using tensors on Lagrangian and Hamiltonian

We can write the Lagrangian (with $n$ generalized coordinates) using the following expression:

$$\mathcal{L(q_i,\dot{q_i},t)}=\mathcal{L}_0(q_i,t)+\mathcal{L}_1(q_i,\dot{q_i},t)+\mathcal{L}_2(q_i,\dot{q_i},t)$$

where $$\mathcal{L}_0=\vec{k_1}.\vec{q}+k_2,$$ is a function with no $\dot{q_i}$ terms,($k_1\in\mathbb{R}^n,k_2\in \mathbb{R}$), $$\mathcal{L}_1=\vec{a}.\vec{\dot{q}},$$ is a linear function on $\dot{q_i}$,$\left(a=a(q_i,t)\right)$, and $$\mathcal{L}_2=b_i\dot{q_i}^2+c_i\dot{q_i}\dot{q_j},$$ is a quadratic function on $\dot{q_i}$, ($b=b(q_i,t),c=c(q_i,t), i=1,2,...n,j=1,2,...n$).

By this way I can transform the previous expression for $\mathcal{L}$ on:

$$\mathcal{L(q_i,\dot{q_i},t)}=\mathcal{L}_0(q_i,t)+{a}.{\dot{q}}+\frac{1}{2}\dot{q}^tT\dot{q}$$

where $T$ is the kinectic energy tensor.

We have the pre-hamiltonian as,

$$\mathcal{h(q_i,\dot{q_i},p_i,t)}=\vec{\dot{q}}.\vec{p}-\mathcal{L(q_i,\dot{q_i},t)}$$

which can be written as

$$\mathcal{H(q_i,p_i,t)}=\frac{1}{2}(p-a)^tT^{-1}(p-a)-\mathcal{L}_0(q_i,t)$$

My question is about the procedure to go from the Lagrangian tensor to this last expression, in a way of algebric operations. Could you write this algebric operations?

• Your equation involding $q^tTq$ does not follow from the previous. Perhaps you meant $\dot{q}^tT\dot{q}$ with $T$ a constant tensor (rather than a kinetic energy tensor, whatever that is). Commented Jun 3, 2015 at 20:28
• you're right! sorry.. Commented Jun 3, 2015 at 20:30

## 1 Answer

If $$\mathcal{L} = \boldsymbol{a}\dot{\boldsymbol{q}} + \tfrac{1}{2}\dot{\boldsymbol{q}}^t\mathsf{\boldsymbol{T}}\dot{\boldsymbol{q}} - U(\boldsymbol{q})$$ with some constant vector $\boldsymbol{a}$ and constant symmetric tensor $\mathsf{\boldsymbol{T}}$, then $$\boldsymbol{p}=\frac{\partial\mathcal{L}}{\partial\dot{\boldsymbol{q}}}=\boldsymbol{a}+\mathsf{\boldsymbol{T}}\dot{\boldsymbol{q}}.$$ Hence, $$\dot{\boldsymbol{q}}=\mathsf{\boldsymbol{T}}^{-1}(\boldsymbol{p}-\boldsymbol{a})$$ and \begin{align} \mathcal{H} &= \boldsymbol{p}\dot{\boldsymbol{q}} - \mathcal{L} \\ &= (\boldsymbol{p}-\boldsymbol{a})\dot{\boldsymbol{q}} - \tfrac{1}{2}\dot{\boldsymbol{q}}^t\mathsf{\boldsymbol{T}}\dot{\boldsymbol{q}} + U(\boldsymbol{q}) \\ &= (\boldsymbol{p}-\boldsymbol{a})\mathsf{\boldsymbol{T}}^{-1}(\boldsymbol{p}-\boldsymbol{a}) - \tfrac{1}{2}(\boldsymbol{p}-\boldsymbol{a})^t\mathsf{\boldsymbol{T}}^{-1}\mathsf{\boldsymbol{T}}\mathsf{\boldsymbol{T}}^{-1}(\boldsymbol{p}-\boldsymbol{a}) + U(\boldsymbol{q}) \\ &= \tfrac{1}{2}(\boldsymbol{p}-\boldsymbol{a})^t\mathsf{\boldsymbol{T}}^{-1}(\boldsymbol{p}-\boldsymbol{a}) + U(\boldsymbol{q}). \end{align}

Edit. You seem to have difficulty with the vector notation, so let's try index notation (using Einstein's sum convention) $$\mathcal{L} = a_i\dot{q}_i + \tfrac{1}{2}\dot{q}_iT_{ij}\dot{q}_j - U(q_i)$$ such that $$p_k = \frac{\partial\mathcal{L}}{\partial\dot{q}_k} = a_k + \tfrac{1}{2}T_{kj}\dot{q}_j+\tfrac{1}{2}\dot{q}_iT_{ik} = a_k + \tfrac{1}{2}(T_{ki}+T_{ik})\dot{q}_i.$$ and the rest as before.