condition $\vx_0 = \begin{bmatrix} 2, 3  \end{bmatrix}^\top$. The optimization goal is to calculate the optimal switching times $t_1$ (from subsystem 1 to 2), $t_2$ (from subsystem 2 to 3), and the continuous control input $u_1$ such that the following cost function is minimized $$\label{eq:exp1_cost}
J = 0.5 \| \vx(3)-\vx_g \|^2 + 0.5 \int_0^3{ \left( \| \vx(t)-\vx_g \|^2 + \|\vu(t)\|^2 \right) dt } ,$$ where $\vx_g = \begin{bmatrix} 1,& -1\end{bmatrix} ^\top$. We apply both OCS2 and BVP to this system with uniformly distributed initial switching times. The optimized switching times, the optimized cost, the number of the iterations, and number of function calls (bottom-level optimization calls) for both algorithms are presented in Table \[tab:performance\]. As it illustrates, OCS2 and BVP converge to the same solution within a comparable number of iterations and function calls. However, the consumed CPU times are significantly different. The BVP method utilizes about 235 seconds on an Intel’s core i7 2.7-GHz processor while the OCS2 algorithm uses only 31 seconds which is roughly 7.5 times faster (Figure \[fig:cpu\_time\]).

#### Example 2: {#example-2 .unnumbered}

In order to examine the scalability of both algorithms to higher dimensions, we augment each subsystem in Example 1 with two more states and 