2

I have two functions $f(x)$ and $g(x)$, and I am looking for a continuous function $h(x)$, or rather $\hat{h}(x)$, which smoothly transitions from $f$ to $g$ over a fixed interval $[x_0,x_1]$, i.e.

$$h(x)=\begin{cases}f(x), &x \le x_0\\ \hat{h}(x), &x_0 < x < x_1\\ g(x) ,& x_1 \le x\end{cases}$$

On here https://kitchingroup.cheme.cmu.edu/blog/2013/02/27/Smooth-transitions-between-two-constants I found the example of $$h(x) \ =\ f(x) \ +\ \Big(g(x)-f(x)\Big) \cdot \left(1 - \frac{1}{1 + \exp\{-(x_c-x)/a\}}\right)$$

which gives e.g.

      sample plot

This is a very nice transition function, but the problem with this approach is that there is only one center point $x_c$. That is, the transition is not perfectly bound between two points $x_0$ and $x_1$, but rather converges to $0$ as we move away from $x_c$.

Can this idea be tweaked to support a fixed transition interval $[x_0,x_1]$?

zhw.
  • 105,693
Phil-ZXX
  • 3,194

2 Answers2

2

You can use the “smooth step function” $\phi$ defined as $$ \psi(t) = \begin{cases} e^{-1/t} & t >0\\ 0 & t \leq 0 \end{cases} \\ \phi(t) = \frac{\psi(t)}{\psi(t)+\psi(1-t)} $$ from Example of a smooth 'step'-function that is constant below 0 and constant above 1. $\phi$ is smooth, equal to $0$ on $(-\infty, 0]$, equal to $1$ on $[1, \infty)$, and strictly increasing on $(0, 1)$.

Together with an affine transformation from the interval $[x_0, x_1]$ to $[0, 1]$ we get that $$ h(x) = f(x) + (g(x) - f(x)) \phi \left( \frac{x-x_0}{x_1 - x_0}\right) $$ has the desired properties.

Martin R
  • 113,040
1

First, define $\varphi_1 : \mathbb{R} \rightarrow \mathbb{R}$ by $$ \varphi_1 : x \mapsto \begin{cases} \exp \left( - \frac{1}{x}\right) &\quad\text{if } x > 0\\ 0 &\quad\text{if } x \leq 0 \\ \end{cases}$$

You can prove that $\varphi_1$ is $\mathcal{C}^{\infty}$ over $\mathbb{R}$. Then $\varphi_2 : x \mapsto \varphi_1(x)\varphi_1(1-x)$ is also $\mathcal{C}^{\infty}$, and has support included in $[0,1]$. Finally, consider $$\varphi_3 : x \mapsto \frac{\int_0^x \varphi_2(t)dt}{\int_0^1 \varphi_2(t)dt}$$

Then you can see that $\varphi_3$ is $\mathcal{C}^{\infty}$, and satisfies $\varphi_3(x) = 0$ if $x \leq 0$, and $\varphi_3(x)=1$ is $x \geq 1$.

Finally, consider $$h : x \mapsto f(x) \left(1- \varphi_3 \left( \frac{x-x_0}{x_1-x_0}\right) \right) + g(x) \varphi_3 \left( \frac{x-x_0}{x_1-x_0}\right)$$

You have that $h(x) = f(x)$ if $x \leq x_0$ and $h(x)=g(x)$ if $x \geq x_1$, and the transition is smooth since $\varphi_3$ is $\mathcal{C}^{\infty}$.

TheSilverDoe
  • 29,720