Identify a Non-Analytic Function that Overlaps with a given Function

I understand that, because of the Identity Theorem in Complex Analysis, two functions $$f(x)$$ and $$g(x)$$ are equal if there exists an interval $$(a,b)$$, where $$a, such that $$f(x)=g(x)$$ for every value in $$(a,b)$$, provided both $$f$$ and $$g$$ are analytic.

However, is there a way to go about finding non-analytic functions that actually prescribe to this behavior? It seems that bump functions are somewhere in the right direction, but I fail to see how those could do what I am looking for.

For example, if you have a function $$f(x) = x^2$$, is there a method to find a smooth non-analytic function $$h(x)$$ so that some interval, say $$(1, 2)$$, $$h(x)=x^2$$, but does not equal $$f(x)$$ for every value outside of that interval? It is simple to construct a non-smooth piecewise function, but that is not what I'm looking for.

• Take a bump function $b(x)$ which is $1$ for $1 \leq x \leq 2$ and $0 \leq b(x) < 1$ for $x<1$ or $x>2$, and use $h(x) = f(x) b(x)$. Then $h(x)=f(x)$ for $1 \leq x \leq 2$ yet $h(x) \neq f(x)$ elsewhere (well, ignoring places where $f(x)=0$). Is this what you're after? Commented Aug 21, 2020 at 1:33
• Yeah this is exactly it. I started with $h(x)=\frac{1}{e^\frac{1}{x}}$ where $x>0$ and $h(x)=0$ where $x\le0$, and then build the bump function $b\left(x\right)=\frac{\left(h\left(1-\left(x-\frac{3}{2}\right)\right)\cdot h\left(1+\left(x-\frac{3}{2}\right)\right)\right)}{h\left(1-\left(x-\frac{3}{2}\right)\right)\cdot h\left(1+\left(x-\frac{3}{2}\right)\right)+h\left(\left(x-\frac{3}{2}\right)-\frac{1}{2}\right)+h\left(-\left(x-\frac{3}{2}\right)-\frac{1}{2}\right)}$. When do something like $g(x) = b(x)*x^2$ this works perfectly. Is there a simple way to prove that $g(x)$ is now smooth? Commented Aug 21, 2020 at 13:08
• Smoothness of your bump function should follow immediately from smoothness of h(x), which is clear except at 0, when you have to verify all derivatives of $e^{-1/x}$ are 0. You're pretty much forced to use some sort of messy induction argument there I think, unfortunately. Commented Aug 21, 2020 at 20:20

Take e.g. $$e^z$$ and $$e^{\Re z}$$. They agree on all $$\mathbb{R}$$, but the second one is clearly not analytical.