# Derivatives in Euler-Lagrange for fields

Starting with the lagrangian density $$L=\frac{1}{2}((\partial_\lambda\phi)(\partial^\lambda \phi) + \mu^2\phi^2),$$ Chen and Li yield the Klein Gordon equation $$(\partial_\lambda \partial^\lambda + \mu^2)\phi=0$$ using Euler-Lagrange formalism.

Looking at the first term, we have $$\partial_{\lambda}\frac{\delta L}{\delta\left(\partial_{\lambda}\phi\right)} = \partial_\lambda \frac{1}{2}\frac{\delta((\partial_\lambda\phi)(\partial^\lambda \phi))}{\delta(\partial_\lambda \phi)}$$

And then I guess by assuming product rule we get $\partial_\lambda \partial^\lambda\phi$. I think I'm missing some understanding in definitions. Shouldn't the covariant and contravariant tensors be formally different objects, so that the partial derivative with respect to $\partial_\lambda \phi$ would consider $\partial^\lambda \phi$ as a constant?

I guess not, but I don't understand what the formal treatment of the partial derivative is, when we differentiate with respect to a tensor of one type and inspect a tensor of the other type.

For example, if we have $$f=a\cdot x_\mu$$for some scalar constant $a$, does $\delta f/\delta x^\mu = a$?

Specifically, the question also holds for the conjugate momentum $$\pi\left(x\right)=\frac{\delta L}{\delta\left(\partial_{0}\phi\right)}=?=\partial_0\phi$$

And how does this partial derivative generalize to a tensor of rank $(n,m)$?

Varying $\phi$ satisfies $$\delta\partial_\lambda\phi=\partial_\lambda\phi,\,\delta\partial^\lambda\phi=\partial^\lambda\delta\phi=g^{\lambda \mu}\delta\partial_\mu\phi$$ so $\frac{\partial\partial_\mu\phi}{\partial\partial_\lambda \phi}=\delta_\mu^\lambda, \,\frac{\partial\partial^\mu\phi}{\partial\partial_\lambda \phi}=g^{\mu\lambda}$. Hence $$\frac{\partial L}{\partial\partial_\lambda\phi}=\frac{1}{2}\left(\delta_\mu^\lambda\partial^\mu\phi+g^{\mu\lambda}\partial_\mu\phi\right)=\partial^\lambda\phi.$$The rest of your questions are addressed the same way.
They are different objects but not independent objects. In particular, they are related to each other via the metric as $$\partial_\mu\phi=\eta_{\mu\nu}\partial^\nu\phi$$$$\partial^\lambda\phi=\eta^{\lambda\kappa}\partial_\kappa\phi$$Thus, the way the variational differentiation of $$\partial_\mu\phi\partial^\mu\phi$$ with respect to $$\partial_\lambda \phi$$ works is a bit more multi-stepped than you seem to imagine. Also, if you are using $$\lambda$$ as a free index then use a different dummy index in the kinetic term, i.e., write $$\partial_\mu\phi\partial^\mu\phi$$ rather than $$\partial_\lambda\phi\partial^\lambda\phi$$ for the sake of clarity and also, because, while you can work with $$\partial_\lambda\phi\partial^\lambda\phi$$ if you are careful enough, it is really wrong. (Treat the dummy indices as if they are in a really spontaneous chemical reaction which just flares up the moment you write down the dummy indices and sums over them but a free index is like an inert element that just stably exists for eternity ;-) So the two cannot be the same as the dummy indices are actually burnt--it looks like they are there but they really are gone!)
Anyway, so here is how that calculation actually works out. $$\frac{\delta(\partial_\mu\phi\partial^\mu\phi)}{\delta(\partial_\lambda\phi)}=\frac{\delta(\partial_\mu\phi\eta^{\mu\nu}\partial_\nu\phi)}{\delta(\partial_\lambda\phi)}$$
$$=\eta^{\mu\nu}\frac{\delta(\partial_\mu\phi\partial_\nu\phi)}{\delta(\partial_\lambda\phi)}$$
$$=\eta^{\mu\nu}\frac{\delta(\partial_\mu\phi)}{\delta(\partial_\lambda\phi)}\partial_\nu\phi+\partial_\mu\phi\frac{\delta(\partial_\nu\phi)}{\delta(\partial_\lambda\phi)}\eta^{\mu\nu}$$ $$=\eta^{\mu\nu}\delta^\lambda_\mu\partial_\nu\phi+\partial_\mu\phi\delta^\lambda_\nu\eta^{\mu\nu}$$ $$=\eta^{\lambda\nu}\partial_\nu\phi+\partial_\mu\phi\eta^{\mu\lambda}$$ $$=\partial^\lambda\phi+\partial^\lambda\phi$$ $$=2\partial^\lambda\phi$$ Neat, right?!
To make the relevant point distinctly clear, I would reemphasize the part you were confused about. Since the covariant and the contravariant derivatives are different but not independent, $$\frac{\delta(\partial^\mu\phi)}{\delta(\partial_\lambda\phi)}=\eta^{\mu\nu}\frac{\delta(\partial_\nu\phi)}{\delta(\partial_\lambda\phi)}=\eta^{\mu\nu}\delta^\lambda_\nu=\eta^{\mu\lambda}$$