Differentiating function times indicator function I have
$$C=\int\limits_{\lambda=0}^{\lambda=2\pi}\int\limits_{\mu=0}^{\mu=1}hq\chi_{q\geq Q}\mathrm{d}\lambda \mathrm{d}\mu$$
where $Q$ is some constant, and $h$ and $q$ are functions of $\lambda$ and $\mu$.
I would like to evaluate $\partial_q C$. Am I correct in saying that it is
$$\int\limits_{\lambda=0}^{\lambda=2\pi}\int\limits_{\mu=0}^{\mu=1}h\chi_{q\geq Q}\mathrm{d}\lambda \mathrm{d}\mu - \int\limits_{\lambda=0}^{\lambda=2\pi}\int\limits_{\mu=0}^{\mu=1}hq\delta_{q- Q}\mathrm{d}\lambda \mathrm{d}\mu,$$
where $\delta$ is Dirac's delta?
 A: The expression you obtained is inaccurate. One way to perform this calculation is to write $C[q]$ in a form matching the Euler-Lagrange equations. Thus we write
$$
C[q]=\int L(x,q(x),q'(x))\ dx,
$$
where $dx=d\mu\ d\lambda$ and the integration is over the rectangle $[0,2\pi]\times [0,1]$, and where
$$
L(x,q(x),q'(x))=h\ q\ \chi_{q\geq Q}.
$$
The Euler-Lagrange equations tell us that the functional derivative is
$$
\frac{\delta C}{\delta q}=\frac{\partial L}{\partial q}-\frac{d}{dx}\frac{\partial L}{\partial q'}.
$$
In this case $L$ does not depend on $q'$ so the second term goes away. That leaves the first term, which we calculate using distributional derivatives. Therefore, by the product rule,
$$
\boxed{\frac{\delta C}{\delta q}=\frac{\partial L}{\partial q}=h\ \chi_{q\geq Q}+h\ q\ \delta(q-Q)}.
$$
Here we have used the fact that the distributional derivative of $\chi_{q\geq Q}$ is $\delta(q-Q)$, as can be seen by a direct integration by parts.
Comparison with your expression. The main difference is that you have integrated this. The functional derivative is defined such that if $\eta(x)$ is any test function on $[0,2\pi]\times [0,1]$, then
$$
\left.\frac{\partial}{\partial t}C[q+t\eta]\right|_{t=0}=\int \frac{\delta C}{\delta q}\ \eta\ dx.
$$
As you can see, the integral is "outside" the functional derivative.
One more comment. The expression $q'(x)$ in the above is actually a gradient, as is $\frac{d}{dx}$, but I didn't want to clutter the notation further since these derivative terms play no role in the calculation anyway. For a complete discussion of the Euler-Lagrange equations with gradients, see this page.
