Example (geodesic on R2)
We want to find the shortest path between two points $(x_1,y_1),(x_2,y_2)$ on $\R^2$. Parametrise the curve by $(x,y(x))$ and fix $y(x_1) = y_1$ and $y(x_2) = y_2$. We seek to minimise $$ \begin{align*} D[y] = \int_{x_1}^{x_2} \underbrace{ \sqrt{1+(y')^2}}_{f(y')}\, dx. \end{align*} $$
We use the first integral when $f$ does not depend on $y$: $$ \begin{align*} \text{const.} = \pdfd{f}{y'} = \frac{y'}{\sqrt{1+(y')^2}} \implies y'=\text{const.} \end{align*} $$ so we get a straight line.
We use the second variation to determine whether this is a minimum. We compute $$ \begin{align*} P &= \pdfd[2]{f}{y'} \\ &= \pdd{y'}\left(\frac{y'}{\sqrt{1+(y')^2}}\right) \\ &= \frac{1+(y')^2 - (y')^2}{(1+(y')^2)^{3/2}} \\ &=(1+(y')^2)^{3/2} > 0, \\ Q &= \pdfd[2]{f}{y} - \dd{x}\left(\frac{\partial^2 f}{\partial y\partial y'}\right) = 0. \end{align*} $$ $P,Q\geq 0$ is sufficient to conclude this is a minimum.