How do we know that there is a smooth function that is constant on two disjoint non-empty compact sets in $\mathbb{R}^n$?

66 Views Asked by At

Let $A$ and $B$ be non-empty compact sets in $\mathbb{R}^n$ such that $A\cap B\neq\emptyset.$ Prove that there is a smooth function $f$ on $\mathbb{R}^n$ with values ranging (inclusively) between 0 and 1 and satisfying $f|_A=0,$ $f|_B=1$.

One way to approach this problem is by finding a satisfactory $f$ that is continuous, then smoothing it via convolution. For example, we could define $f(x)=\frac{\text{min}(\text{dist}(x,A),\text{dist}(x,B))}{\text{dist}(A,B)}$ for a point $x\in\mathbb{R}^n$. This function is continuous because taking the minimum of continuous functions is continuous, as is taking the quotient of continuous functions. However, at this point, I'm lost on how to make it smooth.

I'm told there is also a way to show this using partitions of unity. I would very much like to understand this method as well, but I'm unsure even about where to start. I believe that this method also requires a step where we take a smooth approximation of our "first attempt" function.

I think I am missing some of the analytic background to answer this question. References to/explanations of relevant concepts from analysis would be helpful (especially why they are necessary, and what they guarantee).