## 4 Algorithm for Minimization of Second-derivative-based 5-point-window Spline Functional  
We propose here an algorithm for generation of second-derivative-based 5-point-window \(L_{1}\) splines based on the analytical results of Section 2 of [17]. Recall that, in the interpolation situation of interest in this paper, the task of calculating an \(L_{1}\) spline is the task of calculating the first derivatives \(b_{i}\) by minimization of a spline functional with given nodes \(x_{i}\) and given function values \(z_{i}\) at the nodes. In the \(i\)th 5-point window, \(2\leq i\leq I-2\), an objective function \(E(b_{i-2},b_{i-1},b_{i},b_{i+1},b_{i+2})\) is minimized:  
\[\min_{\mathbf{b}\in\mathbb{R}^{5}}E(b_{i-2},b_{i-1},b_{i},b_{i+1},b_{ i+2})\] \[= \min_{\mathbf{b}}\left\{\sum_{j=i-2}^{i+1}\int_{-\frac{1}{2}}^{\frac{ 1}{2}}|(b_{j+1}-b_{j})+6t(b_{j}+b_{j+1}-2\triangle z_{j})|\;\text{d}t\right\}.\]  
In [17], minimization of \(E(b_{i-2},b_{i-1},b_{i},b_{i+1},b_{i+2})\) is treated as a bilevel minimization problem by representing \(b_{i-2}\), \(b_{i-1}\), \(b_{i+1}\) and \(b_{i+2}\) as functions of \(b_{i}\). The optimal \(b_{i}\), called \(b_{i}^{*}\), is determined by solving  
\[\min_{\mathbf{b}}E(b_{i-2},b_{i-1},b_{i},b_{i+1},b_{i+2})=\min_{b_{i}}\{G_{1}(b_{i })+G_{2}(b_{i})\}, \tag{10}\]  
where  
\[G_{1}(b_{i})=\frac{2(\sqrt{10}-1)}{3}|b_{i-1}(b_{i})-\triangle z_{i-2}|+\int_ {-\frac{1}{2}}^{\frac{1}{2}}|(b_{i}-b_{i-1}(b_{i}))+6t(b_{i-1}(b_{i})+b_{i}-2 \triangle z_{i-1})|\;\text{d}t \tag{11}\]  
and  
\[G_{2}(b_{i})=\frac{2(\sqrt{10}-1)}{3}|b_{i+1}(b_{i})-\triangle z_{i+1}|+\int_ {-\frac{1}{2}}^{\frac{1}{2}}|(b_{i+1}(b_{i})-b_{i})+6t(b_{i}+b_{i+1}(b_{i})-2 \triangle z_{i})|\;\text{d}t\,. \tag{12}\]  
\(G_{1}(b_{i})\) and \(G_{2}(b_{i})\) have similar structure, which leads to the representation  
\[G_{1}(b_{i})+G_{2}(b_{i})=G(b_{i}-\triangle z_{i-1};\triangle z_{i-2}- \triangle z_{i-1})+G(b_{i}-\triangle z_{i};\triangle z_{i+1}-\triangle z_{i}), \tag{13}\]  
where \(G(q;c)\) is a function that is defined and analyzed in [17]. The analysis of [17] is based on the signs of \(\triangle z_{i-2}-\triangle z_{i-1}\), \(\triangle z_{i-1}-\triangle z_{i}\) and \(\triangle z_{i}-\triangle z_{i+1}\). There are 27 cases, as shown in Table 1. For the simple cases, the optimal \(b_{i}^{*}\) are listed in the last column of the table. For cases 14, 15, 17, 18, 23, 24, 26 and 27, the \(b_{i}^{*}\) will be discussed in Algorithm 1. **Table 1**. 27 cases used in the 5-point window algorithm (see [17])  
Whenever the optimal \(b_{i}\) is non-unique at a node \(x_{i}\), \(2\leq i\leq I-2\), we choose the solution \(b_{i}^{*}\) to be the real number in the optimal set closest to \(\delta_{i}\), that is, median\(\{b_{i}^{u},b_{i}^{l},\delta_{i}\}\). In all 27 cases, the solution is either uniquely determined by a simple expression or lies inside the interval \((\triangle z_{i-1},\triangle z_{i})\) and can be found by a line search. The expression \(G_{1}(b_{i})+G_{2}(b_{i})\) is always continuously differentiable on \((\triangle z_{i-1},\triangle z_{i})\). When line search is required, the solution of (10) is obtained by solving \(\dfrac{\mathrm{d}G_{1}(b_{i})}{\mathrm{d}b_{i}}+\dfrac{\mathrm{d}G_{2}(b_{i})} {\mathrm{d}b_{i}}=0\). (The explicit form of this expression is provided in [17].) For the results generated in this paper, we used the \begin{table}
\begin{tabular}{|c|c c c|c|c|} \hline \multirow{2}{*}{Case} & \multicolumn{4}{c|}{Sign of} & Same as & \\  & \(\triangle z_{i-1}-\triangle z_{i-2}\) & \(\triangle z_{i}-\triangle z_{i-1}\) & \(\triangle z_{i+1}-\triangle z_{i}\) & Case & \(b_{i}^{*}\) \\ \hline  
(-\) & 0 & 5 & \(\triangle z_{i}\) \\
26 & \(-\) & \(-\) & + & 15 & [see text] \\
27 & \(-\) & \(-\) & \(-\) & 14 & [see text] \\ \hline \end{tabular}
\end{table} 
Table 1: 27 cases used in the 5-point window algorithm (see [17])secant method (previously used in an analogous way in [3]). Calculation of \(b_{i}^{*}\) for \(i=0\), 1, \(I-1\) and \(I\) is carried out differently, as described in Step 3 of Algorithm 2.