Proving $f$ is infinitely differentiable 
Suppose$$
f(x)=\begin{cases}
\exp\left(-\dfrac{1}{x-a}-\dfrac{1}{x-b}\right); & x \in (a,b)\\
0; & \text{otherwise}
\end{cases}
$$
Show that $f \in C_{c}^{\infty}(\mathbb R)$.

I think I have to just find the general form of the $n$th derivative and argue on that, or , go by induction, any idea?
 A: First, I think your function is supposed to be, for $x \in (a,b)$,
$$
f(x) = e^{-\frac{1}{x-a} - \frac{1}{b-x}}.
$$
The way you had it before with $-1/(x - b)$ can't be right because $-1/(x-b)$ would approach $+\infty$ as $x \to b$ with $x < b$. Define, for $x \in (a,\infty)$,
$$
f_1(x) = e^{-\frac{1}{x-a}}
$$
and $f_1(x) = 0$ otherwise, and define, for $x \in (-\infty,b)$,
$$
f_2(x) = e^{- \frac{1}{b-x}},
$$
and $f_2(x) = 0$ otherwise. Then,
$$
f(x) = f_1(x)\cdot f_2(x).
$$
It follows that all we have to do is prove that both $f_1$ and $f_2$ are in $C^\infty(R)$. Consider $f_1$, as $f_2$ is proven similarly. By an induction argument, one can show that (just take a few derivatives and you'll see the pattern): For all $n = 1,2,3,\ldots$,
$$
f_1^{(n)}(x) = \begin{cases} \displaystyle \frac{p_{n-1}(x)}{(x-a)^{2n}} \, e^{-\frac{1}{x-a}} & \text{if}\ x \in (a,\infty),\\
0 & \text{if}\ x \leq a, \end{cases}
$$
where $p_{n-1}(x)$ is a polynomial in $x$ of degree $(n-1)$ and moreover that for all $n=1,2,3,\ldots$ that $f_1^{(n)}$ is continuous. This proves that $f_1 \in C^\infty$. Similarly, $f_2 \in C^\infty$. Thus, $f \in C^\infty$. Since it has compact support, $f \in C^\infty_c$.
