function components will be $$\begin{aligned}
\partial_{t_j} \vr(z) =&  \vP(z)^\top \partial_{t_j}\vx(z) + \vR(z)  \partial_{t_j}\vu(z), \hspace{3mm} \partial_{t_j} \vR(z) = \mathbf{0}, \\
\partial_{t_j} \vq(z) =&  \vQ(z) \partial_{t_j}\vx(z) + \vP(z) \partial_{t_j}\vu(z), \hspace{5mm} \partial_{t_j} \vQ(z) = \mathbf{0}, \\
\partial_{t_j} q(z)   =& \vq(z)^\top \partial_{t_j}\vx(z) + \vr(z)^\top \partial_{t_j}\vu(z), \hspace{2mm} \partial_{t_j} \vP(z) = \mathbf{0},\end{aligned}$$ which can be written in matrix form as . By the same process, we can derive for the final cost.

In order to find the linearized system dynamics sensitivity with respect to the switching time $t_j$, we can use the result from Lemma 1 where we only keep the terms up to the first order. $$\begin{aligned}
& \frac{d}{dz} \left( \bar{\vx} + \partial_{t_j}\!\vx(t_j-\bar{t}_j) + \delta\!\vx \right) \simeq (\bar{t}_i-\bar{t}_{i-1}) \big( \vf(\bar{\vx},\bar{\vu}) + \vA_i \delta\!\vx + \vB_i \delta\!\vu \big) \notag \\
&  \hspace{0mm}
 + (t_j-\bar{t}_j) \big( ( \delta_{i,j} - \delta_{i-1,j} ) \vf_i(\bar{\vx},\bar{\vu}) + (\bar{t}_{i}-\bar{t}_{i-1}) \left( \vA_i \partial_{t_j}\bar{\vx} +  \vB_i \partial_{t_j}\bar{\vu} \right) \big) ,\end{aligned}$$ where for simplicity in notation, we drop the dependencies on time, $z$. By equating the coefficients, we get $$\begin{aligned}
&\frac{d \bar{\vx}}{dz} \simeq (\bar{t}_i-\bar{t}_{i-1})f(\bar{\vx},\bar{\vu}) \\
&\frac{d \delta\!\vx}{dz} \simeq 
(\bar{t}_{i}-\bar{t}_{i-1}) \big( \vA_i \delta\!\vx + \vB_i \delta\!\vu \big) \\
&\frac{d (\partial_{t_j}\vx)}{dz} \simeq ( \delta_{i,j} - \delta_{i-1,j} ) \vf_i(\bar{\vx},\bar{\vu}) + (\bar{t}_{i}-\bar{t}_{i-1}) \big(\vA_i \partial_{t_j}\!\bar{\vx} + \vB_i \partial_{t_j}\!\bar{\vu} \big) ,\end{aligned}$$ 