## 4 Algorithm for Minimization of Second-derivative-based 5-point-window Spline Functional
Here,_ \(c_{1}=\triangle z_{i-2}-\triangle z_{i-1}\) _and_ \(c_{2}=\triangle z_{i+1}-\triangle z_{i}\)_._
* _In Cases 1, 2, 3, 5, 6, 8, 9, 11, 12, 20 and 21, return_ \(b_{i}^{*}=\triangle z_{i-1}\)_._
* _In Cases 10, 13, 16, 19, 22 and 25, return_ \(b_{i}^{*}=\triangle z_{i}\)_._
* _In Cases 4 and 7, return_ \(b_{i}^{*}=\delta_{i}\)_._
* _Case 14:_
* _Subcase 14-1: If_ \(\triangle z_{i}-\triangle z_{i-1}\leq\frac{\sqrt{10}-2}{\sqrt{10}}(|c_{1}|+|c_{ 2}|)\)_, then_ \[b_{i}^{*}=\mathrm{median}\{\max\{\triangle z_{i-1},\triangle z_{i}+\frac{2-\sqrt {10}}{\sqrt{10}}c_{2}\},\min\{\triangle z_{i-1}+\frac{2-\sqrt{10}}{\sqrt{10}}c_ {1},\triangle z_{i}\},\delta_{i}\}.\]
* _Subcase 14-2: If_ \(\frac{\sqrt{10}-2}{\sqrt{10}}(|c_{1}|+|c_{2}|)<\triangle z_{i}-\triangle z_{i-1 }<\frac{1}{2}(|c_{1}|+|c_{2}|)\)_, then_ \(b_{i}^{*}\) _lies in the interval_ \[\big{[}\max\{\triangle z_{i-1}+\frac{2-\sqrt{10}}{\sqrt{10}}c_{1},\triangle z_ {i}-\frac{1}{2}c_{2}\},\min\{\triangle z_{i-1}-\frac{1}{2}c_{1},\triangle z_{i }+\frac{2-\sqrt{10}}{\sqrt{10}}c_{2}\}\big{]}.\]
* _Use a line search to find_ \(b_{i}^{*}\) _such that_ \(\frac{\mathrm{d}G_{1}(b_{i}^{*})}{\mathrm{d}b_{i}}+\frac{\mathrm{d}G_{2}(b_{i}^ {*})}{\mathrm{d}b_{i}}=0\) _in this interval._
* _Subcase 14-3: If_ \(\frac{1}{2}(|c_{1}|+|c_{2}|)\leq\triangle z_{i}-\triangle z_{i-1}\leq 2(|c_{1}|+|c_{ 2}|)\)_, then_ \[b_{i}^{*}=\mathrm{median}\{\max\{\triangle z_{i-1}-\frac{1}{2}c_{1},\triangle z _{i}-2c_{2}\},\min\{\triangle z_{i-1}-2c_{1},\triangle z_{i}-\frac{1}{2}c_{2}\},\delta_{i}\}.\]
* _Subcase 14-4: If_ \(2(|c_{1}|+|c_{2}|)<\triangle z_{i}-\triangle z_{i-1}\)_, then_ \(b_{i}^{*}\) _lies in the interval_ \[[\triangle z_{i-1}-2c_{1},\triangle z_{i}-2c_{2}].\]
* _Use a line search to find_ \(b_{i}^{*}\) _such that_ \(\frac{\mathrm{d}G_{1}(b_{i}^{*})}{\mathrm{d}b_{i}}+\frac{\mathrm{d}G_{2}(b_{i}^ {*})}{\mathrm{d}b_{i}}=0\) _in this interval._ _Return_ \(b_{i}^{*}\)_._
* _Case 15:_
* _Subcase 15-1: If_ \(\triangle z_{i}-\triangle z_{i-1}\leq\frac{2-\sqrt{10}}{\sqrt{10}}c_{1}\)_, then_ \(b_{i}^{*}=\triangle z_{i}\)_._
* _Subcase 15-2: If_ \(\frac{2-\sqrt{10}}{\sqrt{10}}c_{1}<\triangle z_{i}-\triangle z_{i-1}\leq-\frac{ 7+\sqrt{10}}{3}c_{1}\)_, then_ \(b_{i}^{*}=\triangle z_{i}\)
_._ _Subcase 15-3: If_ \(-\frac{7+\sqrt{10}}{3}c_{1}<\triangle z_{i}-\triangle z_{i-1}\)_, then_ \(b_{i}^{*}\) _lies in the interval_ \[[\triangle z_{i-1}-\frac{7+\sqrt{10}}{3}c_{1},\triangle z_{i}].\] _Use a line search to find_ \(b_{i}^{*}\) _such that_ \(\frac{\mathrm{d}G_{1}(b_{i}^{*})}{\mathrm{d}b_{i}}+\frac{\mathrm{d}G_{2}(b_{i}^ {*})}{\mathrm{d}b_{i}}=0\) _in this interval._ _Return_ \(b_{i}^{*}\)_._ * _Case 17:_ * _Subcase 17-1: If_ \(\triangle z_{i-1}-\triangle z_{i}>\frac{\sqrt{10}+1}{3}(|c_{1}|+|c_{2}|)\)_, then_ \(b_{i}^{*}\) _lies in the interval_ \[[\triangle z_{i}+\frac{\sqrt{10}+1}{3}c_{2},\triangle z_{i-1}+\frac{\sqrt{10}+ 1}{3}c_{1}].\] _Use a line search to find_ \(b_{i}^{*}\) _such that_ \(\frac{\mathrm{d}G_{1}(b_{i}^{*})}{\mathrm{d}b_{i}}+\frac{\mathrm{d}G_{2}(b_{i }^{*})}{\mathrm{d}b_{i}}=0\) _in this interval._ * _Subcase 17-2: If_ \(\triangle z_{i-1}-\triangle z_{i}\leq\frac{\sqrt{10}+1}{3}  
* _In Case 27, let_ \[(\triangle z_{i-2}^{\prime},\triangle z_{i-1}^{\prime},\triangle z_{i}^{\prime}, \triangle z_{i+1}^{\prime},\delta_{i}^{\prime})=-(\triangle z_{i-2},\triangle z _{i-1},\triangle z_{i},\triangle z_{i+1},\delta_{i}).\] _This transforms Case 27 into Case 14. Obtain the optimal solution_ \(b_{i}^{\prime}\) _of the transformed problem. Return_ \(b_{i}^{*}=-b_{i}^{\prime}\)_._
* _Stop._  
The \"outer loop\" (Algorithm 2) consists of repeated or parallel application of Algorithm 1. **Algorithm 2** (Analysis-based Algorithm).