# New Step Size Control Algorithm for Semi-Implicit Composition ODE Solvers
## 2 Materials and Methods
### New Technique to Estimate Local Truncation Error  
The main idea of the proposed embedded composition scheme implies the separation of the solution into two parts at every stage, as shown in Figure 3.  
In Figure 3, \(\mathbf{x}_{n}=\begin{pmatrix}x_{n}\\ y_{n}\end{pmatrix}\), \(\mathbf{x}_{n,i}=\begin{pmatrix}x_{n,i}\\ y_{n,i}\end{pmatrix}\); \(\Phi_{1}\) is a semi-explicit D method; \(\Phi_{2}\) is a semi-implicit D method, which in composition with \(\Phi_{1}\) forms a semi-implicit CD method. To obtain a semi-explicit middle point method, one requires the composition of \(\Phi_{1}\) and \(\Phi_{3}\). We will denote this scheme as ECDM (_Embedded Composition for Different Methods_).  
Figure 3: General scheme of proposed error estimation algorithm in 2-stage composition scheme.  
Using formalization to describe the proposed technique, one can obtain the following:  
\[\begin{array}{l}\widetilde{\mathbf{x}}_{n}=\Phi_{1}(\mathbf{x}_{n},\gamma_{1}h),\\ \mathbf{x}_{n,1}=\Phi_{2}(\widetilde{\mathbf{x}}_{n},\gamma_{1}h),\\ \widetilde{\mathbf{x}}_{n,1}=\Phi_{3}(\mathbf{x}_{n},\widetilde{\mathbf{x}}_{ n},\gamma_{1}h),\\ \widetilde{\mathbf{x}}_{n,1}=\Phi_{1}(\mathbf{x}_{n,1},\gamma_{2}h),\\ \mathbf{x}_{n+1}=\Phi_{2}(\overline{\mathbf{x}}_{n,1},\gamma_{2}h),\\ \widetilde{\mathbf{x}}_{n+1}=\Phi_{3}(\widetilde{\mathbf{x}}_{n,1},\overline{ \mathbf{x}}_{n,1},\gamma_{2}h).\end{array}\]  
One can see that the proposed approach is based mainly on the idea of using two different basic methods--the semi-implicit CD method and semi-explicit midpoint method, which have the same semi-implicit Euler as a starting substep. For every integration step, we take the solution at point \(\mathbf{x}_{n}\) and use it as a starting value for two different compositions, which we address as \(\mathbf{x}_{n}\) (main solution, semi-implicit CD) and \(\widetilde{\mathbf{x}}_{n}\) (additional solution, semi-explicit midpoint). Further analyzing the presented scheme, one can see that intermediate result \(\mathbf{x}_{n,1}\) from the first part of the semi-implicit solution is being used as a part of explicit \(\widetilde{\mathbf{x}}_{n,2}\), and so on.  
To further clarify the proposed solution, one can consider its pseudocode as Algorithm 1.  
```
Begin Algorithm
1 Set variable values \(\mathbf{x}_{n}\), \(h\);
2 Set vector of composition coefficients \(\gamma\);
3 Set s as number of composition stages;
4 Begin DO-WHILE cycle until \(tol\geq\left|\left|\mathbf{x}_{n+1}-\widetilde{\mathbf{x}}_{n+1}\right|\right|\)
5 Begin FOR i = 1,..., s
6 Calculate a new value of \(h\) using formula \(h=h\gamma\) [i];
7 Calculate \(\mathbf{x}_{n+0.5}\) value starting from \(\mathbf{x}_{n}\) using semi-explicit \(D\) method with step size \(h/2\);
8 Calculate \(\widetilde{\mathbf{x}}_{n+1}\) value starting from \(\mathbf{x}_{n}\) using explicit Euler method with step size \(h\) using previously obtained value \(\mathbf{x}_{n+0.5}\);
9 Calculate \(\mathbf{x}_{n+1}\) value starting from \(\mathbf{x}_{n}\) using semi-implicit \(D\) method with step size \(h/2\) using previously obtained value \(\mathbf{x}_{n+0.5}\);
10 End FOR cycle;
11 Choose new step value \(h\);
12 End DO-WHILE cycle; End Algorithm
```  
**Algorithm 1**Pseudocode for the proposed step size control algorithm