Let $X$ be a compact subset of $\mathbb{R}^d$, let $f\in L^2(X)$ be an unknown function with $\lVert f\rVert_2=1$ for which we may assume suitable regularity (e.g. Lipschitz, $C^1$), and let $\mu$ be a Borel probability measure on $X$. Suppose $\int fd\mu=0$. Is there an efficient (in an algorithmic sense, time complexity not exponential in $d$) way to find a perturbation $\mu'$ close to $\mu$ such that $\int fd\mu'\neq 0$?
For example, we could divide the domain into $N^d$ hypercubes $A_1,A_2,\cdots$ and try the density proportional to $\mu+\epsilon 1_{A_i}$ until we hit a region of nonzero $f$. Then the integral value is guaranteed to change due to Lipschitzity for large enough $N$. However, this incurs the curse of dimensionality in $d$. For a similar reason, random perturbations also seem to require exponential time to detect nonzero $f$. I am unsure if this is inevitable.
For context, I am studying the stability of gradient dynamics of a functional on the space of probability measures, and trying to come up with a scheme that will always find an unstable direction to escape to, if one exists. This can be quantified by the magnitude of the perturbation in the direction of an unstable eigenfunction $f$.
Idea 1. Suppose $\phi$ is an odd function such that $\phi(x)>0$ whenever $x>0$. If we set $\mu'$ by
$$ \mathrm{d}\mu' = C (1+ \varepsilon \phi(f)) \, \mathrm{d}\mu $$
for constants $C, \varepsilon > 0$, then
$$\int_X f \, \mathrm{d}\mu' = C\epsilon \int_X f\phi(f) \, \mathrm{d}\mu >0$$
because $f$ is not identically zero (in $\mu$-a.e. sense) and $f\phi(f)>0$ whenever $f\neq 0$.
One issue is that $\mu'$ is in general neither a probability measure nor a positive Borel measure. However, if we assume $f$ is bounded, then:
Choosing $\varepsilon$ sufficiently small makes $\mu'$ positive. This requires knowing the value of $\|\phi(f)\|_{\infty}$.
Choosing an appropriate $C$ normalizes $\mu'$ so that $\mu'(X) = 1$. This requires knowing the value of $\int_X \phi(f) \, \mathrm{d}\mu$.
Estimating $\|\phi(f)\|_{\infty}$ and $\int_X \phi(f) \, \mathrm{d}\mu$ in the general scenario seems suffering from the curse of dimensionality. However, there is one occasion where this becomes cheap:
Idea 2. Assume $f$ is sampled from a distribution $\mathbb{P}$ on $L^2(\mu)$ such that $\mathbb{P}(V) = 0$ for every proper closed subspace $V$ of $L^2(\mu)$. (This essentially tells that $\mathbb{P}(V) = 0$ for every subspace of the form $V = \langle g \rangle^{\perp}$ for some non-zero $g \in L^2(\mu)$.)
Then by fixing an arbitrary non-zero $g \in L^2(\mu)$ in the start, we have $\int_X fg \, \mathrm{d}\mu \neq 0$ with probability one. If in addition $g$ is assumed to be bounded, then we may set $\mu'$ by
$$ \mathrm{d}\mu' = C (1+ \varepsilon g) \, \mathrm{d}\mu, \qquad C = \frac{1}{\int_X (1+ \varepsilon g) \, \mathrm{d}\mu} $$
for any $\epsilon \leq 1 / \|g\|_{L^{\infty}(\mu)}$. Since any non-zero $g$ will work, we may choose $g$ to be nice enough so that $\int_X g \, \mathrm{d}\mu$ is easy to estimate, if necessary.