As a consequence of the formula for the first variation of the energy of a curve, we have the following known characterization of geodesics.
A piecewise differentiable curve $c:[0,1]\to M$ is a geodesic if and only if, for every proper variation $f$ of $c$, we have $\frac{dE}{ds}(0)=0.$
But I'm trying to prove a slight modification of this result, which is given by:
Let $N$ be a closed submanifold of $M$ and a piecewise differentiable curve $c:[0,1]\to M$ such that $c(0),c(1)\in N$. If $\frac{dE}{ds}(0)=0$ then $c$ is a geodesic which intercepts the submanifold $N$ orthogonally (is free boundary).
I managed to get to,
$$\frac{1}{2}E'(0)=-\int^a_{0}\left\langle V(t),\frac{D}{dt}\cdot\frac{dc}{dt} \right\rangle dt-\sum^{k}_{i=1}\left\langle V(t_i),\frac{dc}{dt}(t^{+}_{i})-\frac{dc}{dt}(t^{-}_{i})\right\rangle- \left\langle V(0),\frac{dc}{dt}(0)\right\rangle+\left\langle V(1),\frac{dc}{dt}(1)\right\rangle$$
where $V$ is the variational field defined by $V(t)=g(t)\frac{D}{dt}\frac{dc}{dt}$, where $g:[0,1] \to \mathbb{R}$ is a piecewise differentiable function with $g(t)>0$ if $g(t_i)\neq 0$, remembering that $t_i$ are the partition terms for which $c$ is differentiable.
We know that the variational field is non-zero, and $E'(0)=0$, to finish the proof I need to conclude that
$$\frac{D}{dt}\frac{dc}{dt}=0\quad\text{and}\quad \frac{dc}{dt}(0)=\frac{dc}{dt}(1)=0$$
But I'm not able to do that. I don't know if I took the correct path, I used the main ideas of the proof of the previous proposition. I can go into more detail if needed, but does anyone have any suggestions?
Let $M$ be a Riemannian manifold and $N$ be a closed submanifold. We say that $c:I\rightarrow M$ is a free-boundary geodesic if $c(a),c(b)\in N \text{ and } c'(a),c'(b ) \perp N$.
The first result mentioned can be found in Manfredo P. do Carmo book Riemannian Geometry Proposition 2.5.
Edit: A small change in the statement is necessary to make the question make sense. It was not assumed that $c(0),c(1)\in N$.
Additional Information: This question was probably inspired by exercise 1 in chapter 9. You can see the exercise in this image.