Consider a function where is a point in spacetime. If we assume that the Lagrangian is dependent on and its derivative . The action is then given by,

According to the principle of least action, we have:

According to product rule,

Therefore,

The second term in that equation is zero because the end points of the path are fixed i.e

This then leads to the Euler-Lagrange equation for a field as :