resolvent of a linearized system. Therefore, the matrix $\partial E/\partial x_0 $ is invertible, and the equations and are equivalent. But solving only requires to compute the derivative of $\tilde{E}$. This is what we do in the following.

\[rq\_leastsquares\] Note that it might not always be possible to find a solution to the equation $d\tilde{E}(t,\overline{\mathcal{T}})\cdot \delta \mathcal{T} = \delta x(t)$. This may happen for instance if $t > t_{N-n+1}$, i.e., we do not have enough degrees of freedom left to absorb the perturbation $\delta x(t) \in {\mathbb{R}}^n$. However, we can still give a meaning to the equation $d\tilde{E} \cdot \delta \mathcal{T} = \delta x(t)$. We look for a solution of the least-square problem: $$\min_{\delta \mathcal{T} \in {\mathbb{R}}^N} \left\| d\tilde{E}(t,\overline{t}_1, \ldots, \overline{t}_N) \cdot \delta \mathcal{T} - \delta x (t)\right\|^2_2,$$ for which $\delta \mathcal{T} =  d\tilde{E}(t,\overline{t}_1, \ldots, \overline{t}_N)^{\dagger} \cdot \delta x(t)$ is still the solution of minimal norm (see [@allaire2002algebre]). We see here emerging the idea that the number of switching times (i.e., degree of freedom) left at time $t$, is going to be an important factor to track the system back towards the final point $x_f$.

#### Numerical algorithm.

At time $t$, Equation provides us with a formula to adjust the 