# Implicit A-Stable Peer Triplets for ODE Constrained Optimal Control Problems
## 2 Materials and Methods
### Error Analysis
#### 2.2.4 Adjoint Order Conditions for General Matrices \(K_{n}\)  
The number of order conditions for the boundary methods is so large that they may not be fulfilled with the restriction to diagonal coefficient matrices \(K_{0},K_{N}\) for \(s\geq 3\). Hence, it is convenient to make the step to full matrices \(K_{0},K_{N}\) in the boundary methods and the order conditions for the adjoint schemes have to be derived for this case. Unfortunately, for such matrices the adjoint schemes (27) and (26) for \(n=0\) have a rather unfamiliar form. Luckily, the adjoint differential equation \(p^{\prime}=-\
abla_{y}f(y,u)^{\mathsf{T}}p\) is linear. We abbreviate the initial value problem for this equation as  
\[p^{\prime}(t)=-J(t)p(t),\quad p(T)=p_{T}, \tag{57}\]  
with \(J(t)=\
abla_{y}f\big{(}y(t),u(t)\big{)}^{\mathsf{T}}\) and for some boundary index \(\beta\in\{0,N\}\), we consider the matrices \(A_{\beta}=(a_{ij}^{(\beta)})\), \(K_{\beta}=(\kappa_{ij}^{(\beta)})\). Starting the analysis with the simpler end step (27), we have  
\[\sum_{j=1}^{s}a_{ji}^{(N)}P_{Nj}=w_{i}p_{h}(T)+hJ(t_{Ni})\sum_{j=1}^{s}\kappa_{ ji}^{(N)}P_{Nj},\ i=1,\ldots,s, \tag{58}\]  
which is some kind of half-one-leg form since it evaluates the Jacobian \(J\) and the solution \(p\) at different time points. This step must be analyzed for the linear Equation (57) only. Expressions for the higher derivatives of the solution \(p\) follow easily:  
\[p^{\prime\prime}=(J^{2}-I^{\prime})p,\quad p^{\prime\prime\prime}=(-J^{3}+2J^{ \prime}J+JJ^{\prime}-J^{\prime\prime})p. \tag{59}\]  
**Lemma 2**. : _For a smooth coefficient matrix \(J(t)\), the scheme (58) for the linear differential Equation (57) has local order 3 under the conditions_  
\[A_{N}^{\mathsf{T}}V_{3}+K_{N}^{\mathsf{T}}V_{3}\hat{E}_{3}=w\mathds{1}^{ \mathsf{T}} \tag{60}\]_and with \(\beta=N\)_  
\[\sum_{ \begin{subarray}{c}i=1\\ i\
eq j\end{subarray} }^{s}(c_{i}-c_{j})\kappa^{(\beta)}_{ij}=0,\quad j=1,\ldots,s. \tag{61}\]  
Proof. : Considering the residual of the scheme with the exact solution \(p(t)\), [PERSON] expansion at \(t_{N}\) and the Leibniz rule yield  
\[\Delta_{i} =\sum_{j=1}^{s}a_{ji}^{(N)}p(t_{Nj})-w_{i}p(T)-h(t_{Ni})\sum_{j=1} ^{s}\kappa^{(N)}_{ji}p(t_{Nj})\] \[=\sum_{k=0}^{q-1}\frac{h^{k}}{k!}\big{(}\sum_{j=1}^{s}a_{ji}^{(N) }c_{j}^{k}-w_{i}\big{)}p^{(k)}-\underbrace{h\sum_{k=0}^{q-2}\frac{h^{k}}{k!}c_ {i}^{k}J^{(k)}\sum_{j=1}^{s}\kappa^{(N)}_{ji}\sum_{\ell=0}^{q-2}\frac{h^{\ell}} {\ell!}c_{j}^{\ell}p^{(\ell)}}_{:=:\delta}+O(h^{q})\]  
where all derivatives are evaluated at \(t_{N}\). The second term can be further reformulated as  
\[\delta =\sum_{k=1}^{q-1}h^{k}\sum_{\ell=0}^{k-1}\sum_{j=1}^{s}\kappa^{(N )}_{ji}\frac{c_{i}^{\ell}c_{j}^{k-\ell-1}}{\ell!(k-\ell-1)!}I^{(\ell)}p^{(k- \ell-1)}\] \[=\sum_{k=1}^{q-1}h^{k}\sum_{\ell=1}^{k}\sum_{j=1}^{s}\kappa^{(N)} _{ji}\frac{c_{i}^{\ell-1}c_{j}^{k-\ell}}{(\ell-1)!(k-\ell)!}I^{(\ell-1)}p^{(k- \ell)}.\]  
Looking at the factors of \(h^{0},h^{1},h^{2}\) separately leads to the order conditions  
\[h^{0}:\ 0 =A_{N}^{\mathsf{T}}\mathds{1}-w,\] \[h^{1}:\ 0 =(\sum_{j=1}^{s}a_{ji}^{(N)}c_{j}-w_{i})p^{\prime}-\sum_{j=1}^{s }\kappa^{(N)}_{ji}Jp=(-\sum_{j=1}^{s}a_{ji}^{(N)}c_{j}+w_{i}-\sum_{j=1}^{s} \kappa^{(N)}_{ji})Jp,\ \text{i.e.}\] \[0 =A_{N}^{\mathsf{T}}\mathbf{c}+K_{N}^{\mathsf{T}}\mathds{1}-w,\] \[h^{2}:\ 0 =\frac{1}{2}(\sum_{j}a_{ji}^{(N)}c_{j}^{2}-w_{i})p^{\prime\prime }-\sum_{j=1}^{s}\kappa^{(N)}_{ji}\big{(}c_{j}Jp^{\prime}+c_{i}J^{\prime}p\big{)}\] \[=\frac{1}{2}(\sum_{j=1}^{s}c_{j}^{2}a_{ji}^{(N)}-w_{i}+2\sum_{j=1} ^{s}c_{j}\kappa^{(N)}_{ji})J^{2}p-\frac{1}{2}(\sum_{j=1}^{s}c_{j}^{2}a_{ji}^{( N)}-w_{i}+2\sum_{j=1}^{s}\kappa^{(N)}_{ji}c_{i})J^{\prime}p.\]  
Cancellation of the factor of \(J^{2}\) requires the condition \(0=A_{N}^{\mathsf{T}}\mathbf{c}^{2}+2K_{N}^{\mathsf{T}}\mathbf{c}-w\), which combines with the \(h^{0},h^{1}\)-conditions to (60). The factor of \(I^{\prime}\), however, requires \(0=A_{N}^{\mathsf{T}}\mathbf{c}^{2}+2D_{c}K_{N}^{\mathsf{T}}\mathds{1}-w\) with \(D_{c}=\text{diag}(c_{i})\).