which are respectively the nominal trajectory equation, the linear approximation of system dynamics, and trajectory sensitivity. Based on this approximation, the linear part is not a function of $t_j$, so we get $\partial_{t_j}\!\vA_i(z) = \mathbf{0}$ and $\partial_{t_j}\!\vB_i(z) = \mathbf{0}$ (note that the effect of the switching time variations on the approximated system dynamics would have been appeared if we had used a second order or a higher order approximation).

OCS2 algorithm
==============

In Section \[sec:ocs2\], we have discussed the technical details behind the OCS2 algorithm. Here, we highlight the main steps of the algorithm for synthesizing the optimal continuous control law and the optimal switching times (refer to Algorithm \[alg:ocs2\]). Each iteration of the OCS2 algorithm has three main steps namely (1) using SLQ algorithm to find the continuous inputs’ optimal control, (2) calculating the cost function gradient based on the LQ approximation of the problem which has been already calculated by the SLQ algorithm, (3) using a gradient descent method to update the switching times where we use the Frank-Wolfe method [@jaggi13]. An interesting aspect of our algorithm is its linear-time computational complexity with respect to the optimization time-horizon both in SLQ algorithm and calculating cost gradient. As we 