Let $X$ be a compact Hausdorff space and $F$ be a closed subspace. Let $f\colon X \to \mathbb R$ be a continuous function.
I want to construct a continuous function $g \colon X \to \mathbb R$ such that $g=0$ on $F$ and $$\sup_{x \in X}|g(x)-f(x)|=\sup_{x \in F}|f(x)|$$
Roughly, I want $g$ to "follow" $f$ outside $F$.
I know this is possible if $F$ is a $G_\delta$ set and there exists an open set $U$ such that $F \subseteq U \neq X$ and $ X\backslash U $ is also $G_\delta$ by the strong form of Urysohn lemma. However, I cannot proceed on.
Any help is appreciated.
After some thoughts, If the $f$ is restriced so that $ f \in [\inf_{x \in F} f, \sup_{x \in F} f]$, then I can just put $g =0$ and this is exactly what I needed. I guess there should be a counter example for the originally formulate problem above.
This is more an indirect proof that such a function $g$ exists. Maybe it can be upgraded to a constructive proof.
Consider the two continuous functions $f_{\pm}(x):=f(x) \pm \sup_{x \in F} |f(x)|$. Then any continuous function $g$ that satisfies $f_-(x) \le g(x) \le f_+(x)$ satisfies your 'following f' criteria. Now $f_+ \ge 0$ on $F$ and $f_- \le 0$ on $F$. Hence there are continuous functions $g$ sandwiched between $f_-$ and $f_+$ that are constant zero on $F$.
Edit: Hopefully I'm not missing something trivial here but setting:
$$f(x)=\begin{cases}f_+(x) & f_+(x) \le 0 \\ 0 & f_+(x) > 0 > f_-(x) \\ f_-(x) & f_-(x) \ge 0\end{cases}$$
seems to satisfy your criteria. But this doesn't make use of compactness (which seems unnecessary to me) nor the Hausdorff property (which makes me suspicious).