Let's say I am given a function $f: \mathbb{R}\setminus (0,1) \to \mathbb{R}$ defined piecewise as
$$f(x)= \begin{cases} g(x) \quad x \geq 1 \\ h(x) \quad x \leq 0 \end{cases},$$
where $g$ and $h$ are smooth, that is, $C^\infty$ functions. How can I extend $f$ to a $C^\infty$ function on all of $\mathbb{R}$? Is there a way to use mollification to do this? Any solutions/references/help would be deeply appreciated!
Depending on the characteristics of your functions, like if both are flat functions at the edges of their domains, you could use a smooth transition function, as example, $$q(x)=\begin{cases} 0,\quad x\leq 0,\\ 1,\quad x\geq 1,\\ \dfrac{1}{1+\exp\left(\dfrac{2x-1}{x^2-x}\right)},\ \text{otherwise} \end{cases}$$
You could see it in Desmos: