Smooth approximation of three-phased linear models

322 Views Asked by At

I am looking for a smooth (continuous differentiable) approximation of the following two three-phased functions with breakpoints at $B_1$ and $B_2$:$$ y_1(x, B_1, B_2, a, b) = \begin{cases} a; & x < B_1\\ a + b(x - B_1); & B_1 \leqslant x \leqslant B_2\\ a + b(B_2 - B_1); & x > B_2 \end{cases}, $$

and$$ y_2(x, B_1, B_2, a, b_1, b_2, b_3) = \begin{cases} a + b_1(x - B_1); & x < B_1\\ a + b_2(x - B_1); & B_1 \leqslant x \leqslant B_2\\ a + b_2(B_2 - B_1) + b3(x - B_2); & x > B_2 \end{cases}. $$

The derivative equals $b$ or $b2$ at $\dfrac{1}{2}(B_1+B_2)$ for functions $y_1$ and $y_2$, and equals $b1$ at $x\ll B_1$ and $b3$ at $x\gg B_2$ for function $y_2$.

I would like one additional parameter $s$ that would describe how closely the smooth function would approximate the piecewise linear versions. The function should extrapolate more or less linearly on both sides.

Any thoughts about what could be good functions for this? I want the functions to be smooth and continuously differentiable as that would help me to fit these parameters as I could then provide the analytical first-order derivative.

2

There are 2 best solutions below

4
On BEST ANSWER

$\def\peq{\mathrel{\phantom{=}}{}}$Redefine $y_2(x)$ as$$ y_2(x) = \begin{cases} a_1 x + b_1; & x \leqslant x_1\\ a_2 x + b_2; & x_1 < x \leqslant x_2\\ a_3 x + b_3; & x > x_2 \end{cases}. $$ Assume that $a_2 > a_1$ and $a_2 > a_3$. Extending from your brother's construction, here is an approximation of two parameters $s$ and $n$:\begin{align*} y_2(x; s, n) &= \frac{1}{2} (a_1 + a_3)x + \frac{1}{2} (b_1 + b_3)\\ &\peq + \frac{1}{2} (a_2 - a_1) \left((x - x_1)^{2n} + (a_2 - a_3)^{2n} s^{2n}\right)^{\frac{1}{2n}}\\ &\peq + \frac{1}{2} (a_3 - a_2) \left((x - x_2)^{2n} + (a_2 - a_1)^{2n} s^{2n}\right)^{\frac{1}{2n}}, \end{align*} where $s > 0$, $n \in \mathbb{N}_+$. The smaller the $c$ or the larger the $n$, the better the approximation.

0
On

Ha with the help of my brother found the answer myself in the end. If we define \begin{align*} f(x, b, s) &= \frac{1}{2}\sqrt{\smash[b]{b(4s+bx^2)}}\\ &\mathrel{\phantom{=}}{} \end{align*}

then my piecewise linear function $y_1(x, a, b, B1, B2, s)$ can be approximated as \begin{align*} y_1(x, a,b,B1,B2,s) &= a + f(x-B1,b,s)-f(x-B2,b,s) \end{align*} if the intercept is $a$ and slope of the middle part $b$.

Likewise, my piecewise linear function $y_2(x, a, b1, b2, b3, B1, B2, s)$ with slopes $b1$, $b2$ and $b3$ in the 3 linear parts can be approximated as \begin{align*} y_2(x, a,b1,b2,b3,B1,B2,s) &= a + b1.x + f(x-B1,b2-b1,s)-f(x-B2,b2-b3,s) \end{align*} These will approach the original piecewise model more as $s\to0$. The same system can be used for functions with any number of breakpoints. They are much easier to fit than the original piecewise model though, due to them being continuously differentiable.