Finding a function that minimizes a quantity given some constraints Suppose you have a particle moving in 1 dimension.
There's an acceleration $a(t)$, a velocity $v(t)$ and a total distance traveled, $s$.
The particle starts and ends at rest.
The goal is to travel $s$ distance in time $T$, while minimising $$\int_0^{T}{a(t)^2 dt}$$
How do you find that function?
 A: This kind of questions may be solved by standard techniques of calculus of variations, and in particular the Euler-Lagrange equations. Here I derive the solution in an informal manner, which can actually be made rigurous.
Suppose $f(t)$ determines the position of your particle at time $t$. Then you are asking to find $f$ satisfying 
$$f(0) = 0, \quad f(T) = s, \quad f'(0) = 0, \quad f'(T) = 0$$
and minimizing $\int (f''(t))^2 \, dt$. The trick is that if the minimizer $f$ really exists and is unique, then if we perturb it a little we will make the functional $\int (\cdot)^2\, dt$ actually bigger. So if we substitute $f$ by $f + \epsilon g$ where $g$ is any function for which $f + \epsilon g$ still satisfies the constrains then
$$ \frac{\partial}{\partial \epsilon} \int (f''(t) + \epsilon g''(t))^2 \, dt \Bigg|_{\epsilon = 0} = 0.$$
That is so because the integral must have a minimum as $\epsilon$ varies when $\epsilon = 0$.
Note we can take by $g$ any function satisfying
$$g(0) = 0, \quad g(T) = 0, \quad g'(0) = 0, \quad g'(T) = 0.$$
Assuming we can differentiate under the integral sign, we obtain
$$0 = \int f''(t) g''(t) \, dt = -\int f'''(t) g'(t) \, dt.$$
In the last step we have used integration by parts. 
At this point let us reformulate what we have: calling $h = g'$ we have deduced that for any $h$ satisfying
$$\int h(t) \,dt = 0, \qquad h(0) = h(T) = 0$$
we must have
$$\int f'''(t) h(t)\, dt = 0.$$
Fix any two points now $0 < a < b < T$. We some small $\delta > 0$ can construct a function $h$ which vanishes on $[0, a- \delta] \cup [a + \delta, b - \delta] \cup [b + \delta, T]$, is positive and has unit mass on $[a - \delta, a + \delta]$ and is negative and has unit mass on $[b-\delta, b + \delta]$. This function satisfies all of the above, and furthermore, as we make $\delta$ increasingly small it is not difficult to check that
$$0 = \int f'''(t) h(t) \, dt \approx f'''(a) - f'''(b).$$
In the limit $\delta \rightarrow 0$ this becomes an identity and since $a$ and $b$ were generic points we deduce that $f'''$ must be constant, or equivalently $f$ is a third degree polynomial.
Therefore $f(t) = a t^3 + bt^2 + ct + d$. Now the restrictions on $f$ shown at the beginning determine all four coefficients, and the candidate is
$$f(t) = -2 s T^{-3} t^3 + 3s T^{-2} t^2.$$
It is important to note an important caveat in the previous proof sketch: we have not proved a minizer exist and is smooth, but if it does it must be the $f$ we have found. 
A: If you know the particle doesn't change the direction it's moving in (so that distance is displacment), then you can use the Euler–Lagrange equation. In this case, the Lagrangian is
$$\mathcal{L}(x,\dot{x},\ddot{x})=\ddot{x}^2$$
So the corresponding Euler–Lagrange equation is
$$\frac{\partial\mathcal{L}}{\partial x}-\frac{\mathrm{d}}{\mathrm{d}t}\frac{\partial\mathcal{L}}{\partial \dot{x}}+\frac{\mathrm{d}^2}{\mathrm{d}t^2}\frac{\partial\mathcal{L}}{\partial \ddot{x}}=0\text{,}$$
i.e.,
$$2\frac{\mathrm{d}^4x}{\mathrm{d}t^4}=0\text{.}$$
Consequently, $x(t)$ is a polynomial in $t$ in degree $3$; its coefficients are fixed by the four boundary conditions (say)
$$\begin{align}x(0)&=0 &x(T)&=s\\
\dot{x}(0)&=0 &\dot{x}(T)&=0\text{.}
\end{align}$$
Finding the polynomial of degree $n(m+1)-1$ whose first derivatives through order $m$ are fixed at $n$ points is the Hermite interpolation problem. Using the Hermite interpolation algorithm for $n=2$, $m=2$, we find ($\bar{v}=(x(T)-x(0))/T$)
$$\begin{split}x(t)&=x(0)+\dot{x}(0)t+\frac{\bar{v}-\dot{x}(0)}{T}t^2+\frac{\dot{x}(T)-2\bar{v}+\dot{x}(0)}{T^2}t^2(t-T)\\
&=\tfrac{s}{T^2}t^2-\tfrac{2s}{T^3}t^2(t-T)\text{.}\end{split}$$
