I am trying to understand the second order linear differential equation and the answer here (Finnish) that I have translated below.
Translation
Problem
What is the value of $x(t)$ where the functional
$$\int_0^\infty e^{-rt}( x^2+2x+\dot x^2)dt$$
has the largest value when $x(0)=1$?
Solution
Problem is autonomous where integrand explicitly depends on time only with respect to the discount factor i.e. $e^{-rt}$. So we need to find a stabilising solution where $\lim_{t_f\rightarrow \infty} x(t_f)=x_s$.
Euler: $1+x+r\dot x -\ddot x=0$
From the initial condition and Euler equation, the solution candidate is
$$x^*=2e^{0.5(r+\sqrt{4+r^2})t}+C_1e^{0.5(r-\sqrt{4+r^2})t}-C_1e^{0.5(r+\sqrt{4+r^2})t}-1$$
Stabilising condition: $\dot x=\ddot x=0$ when $t=t_f\rightarrow\infty$ so according to the Euler the stabilising solution is $x_s=-1$; so integrating constant $C_1$:
$$x^*(t_f)=x_s\Rightarrow C_1=\frac{2e^{0.5(r+\sqrt{4+r^2})t_f}}{-e^{0.5(r-\sqrt{4+r^2})t_f}+e^{0.5(r+\sqrt{4+r^2})t_f}}$$
The limit of the integrating factor $C_1$ when $t_f\rightarrow\infty$ is $C_1=2$.
Cannot understand
- where does the Euler equation $1+x+r\dot x -\ddot x=0$ come from?
$$ \int \mathcal{L}(x,\dot{x},t)dt $$ we want to maximize this equation, the Euler-Lagrange equation is of the form $$ \frac{d}{dt}\frac{\partial\mathcal{L}}{\partial \dot{x}} = \frac{\partial\mathcal{L}}{\partial x} $$ where $\mathcal{L} = \mathrm{e}^{-rt}\left(x^{2} + 2x +\dot{x}^{2}\right)$ This results in $$ \frac{d}{dt}\mathrm{e}^{-rt}2\dot{x} = -r\mathrm{e}^{-rt}2\dot{x} + 2\ddot{x}\mathrm{e}^{-rt} = \mathrm{e}^{-rt}\left(2x + 2\right). $$ Reducing the equation leads to $$ 2\mathrm{e}^{-rt}\left[\ddot{x} - r\dot{x} - x - 1\right] = 0 $$ or we could put it into the form above.