The functions you are talking about are called bump functions and are incredibly important in the theory of distributions.
Bump functions can have any close interval as their support; as an example, the function
$$f(x)=\begin{cases} e^{\frac{-1}{(x-a)^2(x-b)^2}}\ \ x\in [a,b]\\
0\end{cases}$$
is a smooth function with compact support $[a,b]$.
Actually, more is true: given any compact set $K$ and an open set $U$ containing $K$ there is a bump function that has value $1$ inside $K$ and $0$ outside $U$ (for the construction see the linked Wikipedia page).
- Derivatives and integrals
The derivative of a bump function is still a bump function vanishing outside the same set $K$
Proof:
Let $A=\mathbb{R}-K$. Then $A$ is an open set on which $f=0$. For every point $x$ in $A$ we have, for $h$ sufficiently small such that $x+h$ is still in $A$
$$f'(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}=\lim_{h\to 0}\frac{0}{h}=0$$
Integration is possible, but since it depends on a constant the integral is not assured to be $0$ outside $K$.
Yes. Every non zero bump function is smooth but is not analytic: this easily follows from a theorem known as the identity theorem, which states that two analytic functions defined on an open and connected set that
are equal on a set of points $S$ such that $S'≠0$ are equal on all the domain.
Thus, if a non zero bump function was to be analytic, it would have to be zero everywhere, which is not the case.
No, $f$ need not be smooth. Take $h(t) = \frac{t(t+1)}{2}$. Then $f$ sends $(x, 0)$ to $(\frac{x^2\operatorname{sign}(x) + x}2, 0)$, so $f$ is at most once differentiable.
Best Answer
$g$ will always be well defined at $0$ because:
$$g(0) = \lim_{x\to 0} \frac{f(x)}{x} = \lim_{x\to 0} \frac{f(x)-0}{x-0} \equiv f'(0)$$
by the definition of the derivative. One can even prove via repeated use of quotient rule and induction that by this definition,
$$g^{(n)}(0) = \frac{f^{(n+1)}(0)}{(n+1)}$$
which is well defined because $f$ is smooth.