# Partial derivatives tricks in derivation of Lagrange equation of motion

While deriving Lagrange equation of motion we may see two equations.

The first one is $\frac{\partial \mathbf{r}_i}{\partial q_j} = \frac{\partial \mathbf{\dot r}_i}{\partial \dot q_j}.$ How is this true?

AFAK $\mathbf{r}_i = \mathbf{r}_i(q_1, q_2, \cdots, q_m),$ where in turn every $q$ is some function of $t.$ So first i need to know what is $\mathbf{\dot r}_i.$ Is it $$\sum_{j=1}^m \frac{d \mathbf{r}_i}{d q_j}\frac{dq_j}{dt}?$$

If true, then we can write $$\frac{\partial \mathbf{\dot r}_i}{\partial \dot q_j} = \frac{\partial \bigg(\sum_{k=1}^m \frac{d \mathbf{r}_i}{d q_k}\frac{dq_k}{dt}\bigg)}{\partial \dot q_j} = \frac{\partial \bigg(\frac{d \mathbf{r}_i}{d q_j} \dot q_j\bigg)}{\partial \dot q_j} = \frac{d \mathbf{r}_i}{d q_j} = \frac{\partial \mathbf{r}_i}{\partial q_j}.$$

The second one is $$\frac{d}{dt}\bigg(\frac{\partial \mathbf r_i}{\partial q_j}\bigg) = \frac{\partial \mathbf{\dot r}_i}{\partial q_j}$$ In this case i don't even know how to start.

$$\frac{\partial}{\partial \dot{q}_{j}} \frac{d q_{k}}{dt} = \delta^{k}_{j}$$
Answer for the second one $$\frac{d}{dt}\bigg(\frac{\partial \mathbf r_i}{\partial q_j}\bigg) = \frac{\partial \mathbf{\dot r}_i}{\partial q_j}$$
$$\frac{\partial \mathbf{\dot r}_i}{\partial q_j} = \frac{\partial \bigg(\sum_{k=1}^m \frac{\partial \mathbf{r}_i}{\partial q_k}\frac{dq_k}{dt}\bigg)}{\partial q_j} = \sum_{k=1}^m \frac{\partial \bigg(\frac{\partial \mathbf{r}_i}{\partial q_k} \dot q_k\bigg)}{\partial q_j} = \sum_{k=1}^m \frac{\partial \bigg(\frac{\partial \mathbf{r}_i}{\partial q_k}\bigg)}{\partial q_j}\dot q_k = \sum_{k=1}^m \frac{\partial^2 \mathbf{r}_i}{\partial q_j \partial q_k}\dot q_k = \frac{d}{dt}\bigg(\frac{\partial \mathbf r_i}{\partial q_j}\bigg).$$