# Adaptive Piecewise Poly-Sinc Methods for Ordinary Differential Equations
## 3 Piecewise Collocation Method
### Hanging Bar Problem  
We discuss the piecewise collocation method for a second-order IVP in integral form. Considering the following IVP on the interval \([a,b]\)  
\[\begin{split}\forall x\in[a,b],\quad-(\tilde{K}(x)y^{\prime}(x))^ {\prime}&=f(x),\\ y(a)&=y_{a},\\ y^{\prime}(a)&=\tilde{y}_{a}.\end{split} \tag{14}\]  
where \(y(x)\) is the sought-for solution. In the context of the hanging bar problem [48], \(y(x)\) and \(\tilde{K}(x)\) are the displacement and the material property of the bar at the position \(x\), respectively. For simplicity, we set \(\tilde{K}(x)=1\). Equation (14) can be written as a system of first-order equations  
\[y^{\prime}=q,\quad q^{\prime}=-f,\quad y(a)=y_{a},\ q(a)=\tilde{y}_{a}. \tag{15}\]  
The integral form of (15) is  
\[y(x) =y_{a}+\int_{a}^{x}q(t)\,\mathrm{d}t\,, \tag{16}\] \[q(x) =\tilde{y}_{a}-\int_{a}^{x}f(t)\,\mathrm{d}t\,. \tag{17}\]Plugging (17) into (16), we obtain  
\[y(x) =y_{a}+\int_{a}^{x}\biggl{[}\tilde{y}_{a}-\int_{a}^{t}f(s)\,\mathrm{ d}s\biggr{]}\,\mathrm{d}t\] \[=y_{a}+\tilde{y}_{a}(x-a)-\int_{a}^{x}\int_{a}^{t}f(s)\,\mathrm{d} s\,\mathrm{d}t\,.\]  
Using integration by parts \(\int u\,\mathrm{d}v=uv-\int v\,\mathrm{d}u\)[49] with \(u(t)=\int_{a}^{t}f(s)\,\mathrm{d}s\),  
\[\int_{a}^{x}\int_{a}^{t}f(s)\,\mathrm{d}s\,\mathrm{d}t =t\int_{a}^{t}f(s)\,\mathrm{d}s\,\biggl{|}_{t=a}^{t=x}-\int_{a}^{ x}tf(t)\,\mathrm{d}t\] \[=x\int_{a}^{x}f(s)\,\mathrm{d}s-\int_{a}^{x}tf(t)\,\mathrm{d}t\] \[=x\int_{a}^{x}f(s)\,\mathrm{d}s-\int_{a}^{x}sf(s)\,\mathrm{d}s\] \[=\int_{a}^{x}(x-s)f(s)\,\mathrm{d}s\,,\]  
where we set \(t=s\). Thus, the integral form of the solution to (14) becomes  
\[y(x)=y_{a}+(x-a)\tilde{y}_{a}-x\int_{a}^{x}f(s)\,\mathrm{d}s+\int_{a}^{x}sf(s) \,\mathrm{d}s\,.\]  
The residual can be written as  
\[R_{\mathrm{I}}(x,a,y_{a},\tilde{y}_{a},y_{\mathrm{c}}(x))=y_{\mathrm{c}}(x)-y _{a}-(x-a)\tilde{y}_{a}+x\int_{a}^{x}f(s)\,\mathrm{d}s-\int_{a}^{x}sf(s)\, \mathrm{d}s\,. \tag{18}\]  
Approximating the indefinite integral in (18), the approximate residual becomes  
\[\tilde{R}_{\mathrm{I}}(x,a,y_{a},\tilde{y}_{a},y_{\mathrm{c}}(x))=y_{\mathrm{ c}}(x)-y_{a}-(x-a)\tilde{y}_{a}+x(\mathcal{J}_{m}^{+}f)(x)-(\mathcal{J}_{m}^{+} x\,f)(x). \tag{19}\]  
For the \(k-\)th partition, \(k=1,2,\ldots,K\), we replace \(a\) with \(x^{k-1}\), \(y_{a}\) with \(y_{c,\,k-1}(x^{k-1})\), and \(\tilde{y}_{a}\) with \(y^{\prime}_{c,\,k-1}(x^{k-1})\). The approximate residual becomes  
\[\tilde{R}_{\mathrm{I},k}(x,x^{k-1},y_{c,\,k-1}(x^{k-1}),y^{ \prime}_{c,\,k-1}(x^{k-1}),y_{c,\,k}(x))=y_{c,\,k}(x)-y_{c,\,k-1}(x^{k-1})\\ -(x-x^{k-1})y^{\prime}_{c,\,k-1}(x^{k-1})+x(\mathcal{J}_{m}^{+}f) (x)-(\mathcal{J}_{m}^{+}x\,f)(x),\;x\in I_{k}.\]  
We remove the equations corresponding to the leftmost and rightmost Sinc points in each partition, and replace them with the conditions  
\[y_{\mathrm{c}}(x^{0}) =y_{a}, \tag{20a}\] \[y^{\prime}_{\mathrm{c}}(x^{0}) =\tilde{y}_{a},\] (20b) \[y_{c,\,k}(x^{k-1}) =y_{c,\,k-1}(x^{k-1}),\quad k=2,\ldots,K,\] (20c) \[y^{\prime}_{c,\,k}(x^{k-1}) =y^{\prime}_{c,\,k-1}(x^{k-1}),\quad k=2,\ldots,K, \tag{20d}\]  
and the set of equations  
\[\tilde{R}_{\mathrm{I},k}(x_{j,k},x^{k-1},y_{c,\,k-1}(x^{k-1}),y^{\prime}_{c, \,k-1}(x^{k-1}),y_{c,\,k}(x_{j,k}))=0, \tag{21}\]  
\(j=2,\ldots,m_{k}-1,k=1,\ldots,K\). Equations (20c)-(20d) are known as the continuity equations at the interior boundaries [47]. The collocation algorithm for the IVP (14) is outlined in Algorithm 2.