# How to link two curves?

If $f \in {C^\infty }(( - \infty ,1))$ and $g \in {C^\infty }(( 0 ,+\infty))$, then for arbitary real numbers $a<0$ and $b>1$, can we find a $C^\infty(R)$ function $h$ which satisfies that $h$ is equal to $f$ when restricted to $( - \infty ,a]$, and $g$ when restricted to $[ b, \infty)$?

Complement: Someone has given a beautiful construction. I have an addtional question, that is can the new function $f$ satisfy the addtional conditions that ${f^{(n)}}(a) = {h^{(n)}}(a)$ and ${g^{(n)}}(b) = {h^{(n)}}(b)$ for all $n=0,1,2...$ It is obvious that such $h$ cannot exist for arbitrary $f$ and $g$(e.g.$f$ is analytical), then what conditions do we have to put on $f$ and $g$? Or for arbitrary $f$ and $g$, if we can find a $h$ such that ${f^{(n)}}(a) = {h^{(n)}}(a)$ and ${g^{(n)}}(b) = {h^{(n)}}(b)$ for all $n=0,1,2...k$, with a definite $k$?

-
Since you're allowing $a < 0$ there is no problem. Just perform the same trick as Davide's but taking a smooth function $f_1$ that is constant $1$ on the interval $(-\infty, 2a/3]$ and constant zero on $[a/3,\infty)$ and similarly for $g_1$. Analyticity of $f$ and $g$ is not an obstruction (since the resulting function $h$ won't be analytic at some points at least). – t.b. Oct 14 '11 at 14:44
So, did you even think about the solution Davide gave you? You ask a question. He answers it. You ask a follow-up question with an immediate solution. Then you accept his answer. Then you unaccept the answer, you ask another question that is equally easy? Rather bad style I would say. – t.b. Oct 14 '11 at 21:33
Note that a very similar question has been posted here without either question mentioning the other. @Adterram: This, too, is rather bad style. – joriki Oct 15 '11 at 3:12

Consider a function $\rho_1$ which is smooth with support contained in $\left[a,0\right]$, and $\int_{\mathbb R}\rho_1(x)dx=1$ and put $f_1(x):=\int_x^{+\infty}\rho_1(x)dx$. Then $f_1$ is a smooth function such that $f_1(x)=1$ if $x\leq a$ and $f_1(x)=0$ if $x\geq 0$. We put $F(x):=\begin{cases}f(x)f_1(x)&\mbox{ if }x\leq 0\\ 0&\mbox{ otherwise}\end{cases}$. Then $F$ is a smooth function which is equal to $f$ on $\left(-\infty,a\right]$ and $0$ on $(0,+\infty)$. By the same way, we can find a smooth function $G$ which is equal to $g$ on $\left[b,+\infty\right)$ and $0$ on $\left(-\infty,1\right)$. Now put $h:=F+G$.