Hi. I want to find the derivative of a functional with respect to a function, in particular, the $\displaystyle L_2$ norm of a function. I haven't done this type of calculations for a while.

So, let's say my functional is a mismatch between two functions:

$\displaystyle R=||g(\mathbf{r})-f(\mathbf{r})||^2=\int d\mathbf{r}[g(\mathbf{r})-f(\mathbf{r})]^2$,

and I want to find $\displaystyle \frac{\partial R}{\partial g(\mathbf{r})}$.

So, I thought of using the chain rule, such that: [tex]\frac{\partial R}{\partial g(\mathbf{r})}= $\displaystyle \frac{\partial R}{\partial \mathbf{r}}\times \frac{\partial \mathbf{r}}{\partial g(\mathbf{r})}=\frac{\partial R}{\partial \mathbf{r}}\times \left ( \frac{\partial g(\mathbf{r})}{\partial \mathbf{r}}\right)^{-1}$.

That would give: $\displaystyle \frac{\partial R}{\partial g(\mathbf{r})}=2[g(\mathbf{r})-f(\mathbf{r})]\hat{r}\cdot \left[ \nabla g(\mathbf{r})\right]^{-1}=\sum_i 2[g(\mathbf{r})-f(\mathbf{r})] \left[ \frac{\partial g(\mathbf{r})}{x_i}\right]^{-1}$.

with $\displaystyle x_i=x,y,z$ for i=1,2,3.

Is this correct?

Thanks in advance.