Between any two continuous functions $f>g$, can we find a real-analytic function?
@NateEldredge mentioned a result of Carleman. It is indeed a beautiful theorem: Suppose $G:\mathbb R \to \mathbb R$ is continuous, and $\epsilon: \mathbb R \to (0,\infty)$ is any positive continuous function. Then there exists an entire function $F$ such that $|F(x)-G(x)| < \epsilon(x)$ for all $x\in \mathbb R.$
In your problem we can let $G = (f+g)/2$ and $\epsilon = (f-g)/2.$ Then
$$\frac{g-f}{2} < F - \frac{f+g}{2} < \frac{f-g}{2}\,\,\, \text { on }\,\, \mathbb R$$
and your result falls right out.