Let $p:[0,1)^2\to\mathbb R$ be a Lebesgue integrable function. Define $\sigma(x):=p(x)^{-\frac12}$, if $p(x)>0$, and $\sigma(x):=\infty$, if $p(x)=0$, for $x\in[0,1)^2$. Moreover, let $\varphi(y):=e^{-(rx)^2}$ for $x\in\mathbb R$ and some $r>0$ and $\varphi_x(y):=\frac1{\sigma^2(x)}\varphi\left(\frac{\|x-y\|}{\sigma(x)}\right)$ for $x,y\in[0,1)^2$.
I want to place $x\in[0,1)^2$ such that $f(x):=\int_{[0,\:1)^2}|\varphi_x(y)-p(y)|\:{\rm d}y$ is minimized.
I'm using gradient descent for this. Now, my problem occurs when we start at a $x\in[0,1)^2$ with $p(x)=0$. In this case, $\varphi_x=0$ and $\nabla f(x)=0$. However, we might clearly minimize $f(x)$ by moving $x$. Consider, for example, the simple case $p=1_{[0,\:1/2)^2}$.
So, what can we do? Should we define $\varphi_x$ differently when $p(x)=0$? Or do we need something else than gradient descent?