Differentiation of a Bilinear Form In classical mechanics you have, in many cases, $\mathcal{L}(t,y,y') = T(y') - V(y) = \tfrac{1}{2}my'^2 - V(y)$.
My goal is to get used to mathematically incorporating a metric into this result, first a constant metric then a non-constant metric.
As I see it, I could incorporate vectors by setting $\vec{v} = (y')$ & write the above result in terms of the standard euclidean inner product $<\vec{v},\vec{v}> = g(\vec{v},\vec{v})$ as
$$\mathcal{L}(t,y,y')= T(y') - V(y) = \tfrac{1}{2}my'^2 - V(y) = \tfrac{1}{2}m<\vec{v},\vec{v}> - V(y) = \tfrac{1}{2}mg(\vec{v},\vec{v}) - V(y)$$
But now when I want to find the Euler-Lagrange equations, what does it mean to differentiate a bilinear form, mathematically? In detail:
First I want $\tfrac{d}{dt}\tfrac{\partial \mathcal{L}}{\partial y'} - \tfrac{\partial \mathcal{L}}{\partial y} = 0$ but apparently $\tfrac{d}{dt}\tfrac{\partial (\tfrac{1}{2}mg(\vec{v},\vec{v}) - V(y))}{\partial y'} - \tfrac{\partial (\tfrac{1}{2}mg(\vec{v},\vec{v}) - V(y))}{\partial y} = 0$ makes no sense because $g$ is not a function of $y'$ it's equal to $y'^2$. What do I do? How do I say this with nice notation? I should end up with $2y'$, but I don't see how to get this in terms of general formalism.
Second, if I express my bilinear form in terms of matrices I have $g(\vec{v},\vec{v}) = [y'][1][y']$, how do you differentiate that in a way that makes sense when you generalize this to higher-dimensional vectors & matrices?
Third, could you be a bit careful to point out how to do the above two questions when the metric is not constant? I'm trying to prepare for GR & small linear algebra/advanced calculus problems like these are holding me back, much appreciated!
 A: It might help you (and any readers) to unpack all the abuses of notation going on here. First, you should really think about the Lagrangian $\mathcal{L}$, a priori, as a function $\mathcal{L}(t,q,v)$ of one scalar variable $t$ (time) and two vector variables, $q$ (position) and $v$ (velocity). Then, the Euler-Lagrange equations for a trajectory $t \mapsto \gamma(t)$ is perhaps most clearly written as
$$
 \frac{d}{dt} \left( \frac{\partial \mathcal{L}}{\partial v}(t,\gamma(t),\dot{\gamma}(t))\right) - \frac{\partial \mathcal{L}}{\partial q}(t,\gamma(t),\dot{\gamma}(t)) = 0,
$$
where the notation is now unambiguous.
Now, in light of your more general interests, let's suppose that your Lagrangian takes the form
$$
 \mathcal{L}(t,q,v) = \frac{1}{2} g(q)(v,v) - V(q), 
$$
where for each $q$, $g(q)$ is a bilinear form; we can get much greater generality for free if we just absorb $m$ into $g$. Supposing that the variables $q$ and $v$ live in $\mathbb{R}^n$, we can really view $g$ as a function
$$
 g : \mathbb{R}^n \times \mathbb{R}^n \times \mathbb{R}^n \to \mathbb{R}, \quad (q,v_1,v_2) \mapsto g(q)(v_1,v_2),
$$
so that we can form
$$
 \frac{\partial g}{\partial q},  \frac{\partial g}{\partial v_1},\frac{\partial g}{\partial v_2} : \mathbb{R}^n \times \mathbb{R}^n \times \mathbb{R}^n \to \mathbb{R}^n
$$
in the normal way. 


*

*First, the dependence on $q$ is in a certain sense straightforward, so that
$$
 \frac{\partial \mathcal{L}}{\partial q}(t,q,v) = \frac{1}{2} \frac{\partial g}{\partial q}(v,v) - \frac{\partial{V}}{\partial q}(q).
$$

*Now, let's look at the $v$ dependence, which in some sense is a bit trickier. Since $g(q,\cdot,\cdot)$ is bilinear for each fixed $q$, we'll have that
$$
 \left\langle \frac{\partial g}{\partial v_1}(q,a,v_2),v\right\rangle = g(q,v,v_2), \quad \left\langle \frac{\partial g}{\partial v_2}(q,v_1,b),v\right\rangle = g(q,v_1,v).
$$
Now, observe that for fixed $q$ and $v$,
$$
 g(q,v+h,v+h) - g(q,v,v) = g(q,v,h) + g(q,h,v) + g(q,h,h)\\
= g(q,v,h) + g(q,h,v) + O(\|h\|^2)\\
= \left\langle \frac{\partial g}{\partial v_1}(q,v,v),h\right\rangle + \left\langle \frac{\partial g}{\partial v_2}(q,v,v),h\right\rangle + O(\|h\|^2)\\
= \left\langle \frac{\partial g}{\partial v_1}(q,v,v) + \frac{\partial g}{\partial v_2}(q,v,v),h\right\rangle + O(\|h\|^2),
$$
so that by definition of $\tfrac{\partial}{\partial v}(g(q,v,v))$ as the gradient of $v \mapsto g(q,v,v)$ with respect to $v$ is
$$
 \frac{\partial}{\partial v}(g(q,v,v)) = \frac{\partial g}{\partial v_1}(q,v,v) + \frac{\partial g}{\partial v_2}(q,v,v).
$$
Thus,
$$
 \frac{\partial \mathcal{L}}{\partial v}(t,q,v) = \frac{1}{2} \left(\frac{\partial g}{\partial v_1}(q,v,v) + \frac{\partial g}{\partial v_2}(q,v,v)\right);
$$
if you're handy with the musical isomorphisms (i.e., raising and lowering indices) between $\mathbb{R}^n$ and its dual $(\mathbb{R}^n)^\ast$ defined by the usual inner product, then you can write
$$
 \frac{\partial \mathcal{L}}{\partial v}(t,q,v) = \frac{1}{2}(g(q)(\cdot,v)^\#+g(q)(v,\cdot)^\#),
$$
which simplifies, if $g$ is symmetric, to
$$
 \frac{\partial \mathcal{L}}{\partial v}(t,q,v) = g(q)(v,\cdot)^\#.
$$


And now I'm going to strongly suggest we  work in coordinates, so that
$$
 g(q)(v_1,v_2) = g_{ij}(q)v_1^i v_2^j.
$$
Then
$$
 \frac{\partial g}{\partial q^k}(q,v_1,v_2) = \frac{\partial g_{ij}}{\partial q^k}(q) v_1^i v_2^j,\\ 
 \frac{\partial g}{\partial v_1^k}(q,v_1,v_2) = g_{ij}(q) \delta^i_k v_2^j = g_{kj}(q)v_2^j,\\
 \frac{\partial g}{\partial v_2^k}(q,v_1,v_2) = g_{ij}(q) v^i_k \delta_k^j = g_{ik}(q)v_1^j,
$$
and hence
$$
 \frac{\partial \mathcal{L}}{\partial q^k}(t,q,v) = \frac{1}{2}\frac{\partial g_{ij}}{\partial q^k}(q) v^i v^j - \frac{\partial V}{\partial q^k}(q),\\
 \frac{\partial \mathcal{L}}{\partial v^k}(t,q,v) =  \frac{g_{ik}(q)+g_{ki}(q)}{2}v^i;
$$
in particular, if $g$ is symmetric, we just get
$$
 \frac{\partial \mathcal{L}}{\partial v^k}(t,q,v) = g_{ik}(q) v^i,
$$
which tells us something very interesting about the relation between velocity and momentum.
