# Smooth Bump Function Between Two Functions

I know that if you have a bump function $$B$$

$$B(x) = \begin{cases} e^\frac{-1}{x}, & x>0 \\[2ex] 0, & x\le0 \end{cases}$$

and some other arbitrary smooth function $$f$$ (i.e. $$f(x)=x^2$$) and create a secondary function to bind both $$B$$ and $$f$$ to make $$f=B$$ for some interval and $$f\neq B$$ anywhere outside of that interval (as done in the comments here).

However, if you have two functions, $$f$$ and $$g$$ (say $$g(x)=x$$), is there a way to use a bump function to smoothly "connect" these two functions (you probably need to make sure there is some sort of intersection between $$f$$ and $$g$$ anyways, $$g(x)=x$$ may be a poor example).

The behavior I am looking for is that, when $$B\le0$$, $$B=f$$ and when $$B\ge1$$, $$B=g$$, and across the interval $$(0,1)$$ $$B$$ is a $$C^\infty$$ function where $$B\neq f$$ and $$B\neq g$$. I'm sure there is some sort of restriction between what $$f$$ and $$g$$ can be, which may not be properly represented in this example.

The function that's more useful for your purpose is the so-called bump function:

$$f : \mathbb{R} \to \mathbb{R}, x \mapsto \begin{cases} \exp\left( -\frac{1}{1 - x^2} \right) & \text{ if } |x| < 1, \\ 0 & \text{ else}. \end{cases}$$

The reason this one is nicer is because it is also a smooth function, but this one is compactly supported, so outside of the small region $$(-1,1)$$, this is zero, so it's a useful tool for making tiny fixes to your function around small areas. It basically behaves the same way that your function $$e^{-\tfrac{1}{x}}$$ behaves at zero, but at two different points.

What's more, consider what happens if you integrate this function (and for reasons you'll see in a moment, we also normalize the integral

$$F : \mathbb{R} \to \mathbb{R}, x \mapsto \frac{\int_{-\infty}^x f(y) dy }{\int_{-\infty}^\infty f(y) dy}.$$

This is clearly again a smooth function, and it has the property that if $$x < -1$$, then $$F(x) = 0$$, and if $$x > 1$$, then $$F(x) = 1$$. Hence, if you have any other function $$h : \mathbb{R} \to \mathbb{R}$$, the function $$F \cdot h$$ will have

$$(F \cdot h )|_{(-\infty,-1)} = 0, \quad (F \cdot h )|_{(1,\infty)} = h|_{(1,\infty)}.$$

Hence, if you want to glue two functions $$g$$ and $$h$$ together, multiply one of them with $$F$$, multiply the other one with a horizontally flipped $$F$$, and add them together! (of course, this $$F$$ does the connecting across the interval $$(-1,1)$$ and not $$(0,1)$$ as you asked, but that's just a matter of translating and rescaling the function).

If you would instead like to stay with your $$e^{-1/x}$$-function, you can also look into the answers to this question, there are some constructions which are even more elementary :)

Note in particular: you do not need any specific requirements for your functions, you can glue all two functions together that you like!