Why do I get three different results for the first variation of $J(x(t)) = \int_{t_0}^{t_f} x^2(t) dt$

calculuscalculus-of-variationsclassical-mechanicseuler-lagrange-equationoptimal control

Background

From a book on Optimal Control that I am reading,
I know that the increment $\Delta J$ of a functional $J(x(t))$ can be written using a Taylor Series Expansion as:

$$
\Delta J = \delta J + \delta^2J + \cdots
$$

where $\delta J = \frac{\partial J}{\partial x}\delta x(t)$ is the first variation and $\delta^2 J = \frac{1}{2!}\frac{\partial^2 J}{\partial x^2}(\delta x(t))^2$ is the second variation.

Now if we consider the functional $J(x(t)) = \int_{t_0}^{t_f} x^2(t) dt$, we can form the increment as follows:

\begin{align}
\Delta J &= J(x(t) + \delta x(t)) – J(x(t))\\
&= \int_{t_0}^{t_f} (x(t) + \delta x(t))^2 dt – \int_{t_0}^{t_f} x^2(t) dt\\
&= \int_{t_0}^{t_f}\left[ x^2(t) + 2x(t)\delta x(t) + (\delta x)^2 – x^2(t)\right]dt\\
&= \int_{t_0}^{t_f}\left[2x(t)\delta x(t) + (\delta x)^2\right]dt.
\end{align}

Question

Result 1:

Following an example in the book, if we consider only the first order terms in the increment $\Delta J = \int_{t_0}^{t_f}\left[2x(t)\delta x(t) + (\delta x)^2\right]dt$,
we should be able to write

$$
\delta J = \int_{t_0}^{t_f}2x(t)\delta x(t) dt.
$$

Result 2:

However, I get a different result when using the definition $\delta J = \frac{\partial J}{\partial x}\delta x(t)$

\begin{align}
\delta J &= \frac{\partial J}{\partial x}\delta x(t)\\
&= \frac{\partial}{\partial x}\left(\int_{t_0}^{t_f} x^2(t) dt\right)\delta x(t)\\
&= \left(\int_{t_0}^{t_f} \frac{\partial}{\partial x}x^2(t) dt\right)\delta x(t)\\
&= \left(\int_{t_0}^{t_f} 2x(t) dt\right)\delta x(t).
\end{align}

Since, $\delta x(t)$ is a function of $t$, I cannot just take it inside the integral.

Result 3:

As suggested by a helpful commenter, I also tried to evaluate the first
variation from the definition using the Gateaux derivative of the functional:

\begin{align}
\delta J &= \frac{d}{d\epsilon}J(x(t)+\epsilon h(t))\Bigr|_{\epsilon = 0}\\
&= \frac{d}{d\epsilon}\int_{t_0}^{t_f} (x(t) + \epsilon h(t))^2 dt\Bigr|_{\epsilon = 0}\\
&= \frac{d}{d\epsilon}\int_{t_0}^{t_f} \left(x^2(t) + 2x(t)\epsilon h(t) + \epsilon^2h^2(t)\right) dt\Bigr|_{\epsilon = 0}\\
&= \int_{t_0}^{t_f} \left(x^2(t) + 2x(t)h(t) + 2\epsilon h^2(t)\right) dt\Bigr|_{\epsilon = 0}\\
&= \int_{t_0}^{t_f} \left(x^2(t) + 2x(t)h(t)\right) dt
\end{align}

which gives yet another different result. I believe the relation between $\delta x(t)$ and $h(t)$ in this last approach is $\delta x(t) = \epsilon h(t)$.

So my question is which one of these three results is correct and why are the other two incorrect? I would deeply appreciate any answers!

Best Answer

$J(x)$ is a functional, it takes a function as argument and returns a number. The same holds then true for $δJ(x;δx)$ which takes the two functions as arguments and is additionally linear in the second argument. Your variant 2) is nowhere supported by the theory. Think of the integral as a scalar product $f\cdot g=⟨f,g⟩=\int_{t_i}^{t_f}f(t)g(t)\,dt$, then writing $δJ(x)\cdot δx=\langle δJ(x), δx\rangle$ can also make sense.


Summary:

Result 1 - Correct answer

Result 2 - This can be corrected to match Result 1 by realizing that $\frac{δJ(x)}{δx(t)}$ is sometimes written as $\frac{∂F}{∂x}(t,x(t))$ and that $\delta J(x) = \frac{\partial F}{\partial x}(t,x(t))\delta x(t) = \int_I \frac{\partial F}{\partial x}(t,x(t))\delta x(t)dt$ in a variational context.

Result 3 - This can be corrected to match Result 1 by realizing that $\frac{dx^2(t)}{d\epsilon} = 0$.

Related Question