I am making a mistake somehow when differentiating and changing the variable of differentiation. I think it has something to do with the way I introduce a new variable that relates two independent variables, but I'm confusing myself and can't undertand exactly what I'm doing wrong.
So I have a product of three matrices whose entries are parameterised by $r$ and $r'$. The product is
$$ \mathbf{F}(r,r')=\mathbf{G}(r-r')\mathbf{Q}(r')\mathbf{n}(r-r'). $$
I am interested in the derivative with respect to $r$, namely $\partial_r \mathbf{F}(r,r')$.
I notice that two of the matrices only depend on the difference between $r$ and $r'$ so I introduce the variable $R=r-r'$. I wish to change the variable of differentiation to $R$ as follows
$$ \begin{align} \partial_r \mathbf{F}(r,r') &= \partial_r \left[ \mathbf{G}(r-r')\mathbf{Q}(r')\mathbf{n}(r-r') \right]\\ &= \left[ \partial_r \mathbf{G}(r-r') \right] \mathbf{Q}(r') \mathbf{n}(r-r') + \mathbf{G}(r-r') \mathbf{Q}(r') \left[ \partial_r \mathbf{n}(r-r')\right] \\ &= \left[ \partial_R \mathbf{G}(R) \right] \mathbf{Q}(r') \mathbf{n}(R) + \mathbf{G}(R) \mathbf{Q}(r') \left[ \partial_r \mathbf{n}(R)\right] \\ &= \partial_R \mathbf{F}(r,r') \end{align} $$
Then, I notice that I can write $\mathbf{Q}(r')$ as $\mathbf{Q}(r-R)$, and therefore
$$ \begin{align} \partial_R \mathbf{F}(r,r') &= \partial_R \left[ \mathbf{G}(R)\mathbf{Q}(r-R)\mathbf{n}(R) \right] \\ &= \partial_R \left[ \mathbf{G}(R)\right]\mathbf{Q}(r-R)\mathbf{n}(R) + \mathbf{G}(R)\partial_R \left[\mathbf{Q}(r-R)\right]\mathbf{n}(R) + \mathbf{G}(R)\mathbf{Q}(r-R)\partial_R \left[\mathbf{n}(R)\right] \end{align} $$
This result is not the same as calculated above (there is an additional term $\mathbf{G}[\partial_R \mathbf{Q}] \mathbf{n}$). Please could you tell me what I'm doing wrong?
The notation for partial derivatives is unfortunately ambiguous. One has to specify the variable of differentiation but also what variable is remaining constant. I.e., $\tfrac{\partial}{\partial x} f(x,y)$ means the derivative of $f(x,y)$ in $x$ leaving $y$ constant. This is not, for example, the same as the derivative of $f(x,y)$ in $x$ leaving $x+y$ constant!
You should always specify a change of two variables into two variables to make sense of partial derivatives. Hence in this case, set $R=r-r'$ and also $S=r'$. Then, by the general transformation rule for partial derivatives, $$ \frac\partial{\partial r}=\frac{\partial R}{\partial r}\frac\partial{\partial R}+\frac{\partial S}{\partial r}\frac\partial{\partial S}=\frac{\partial}{\partial R}. $$ Here, as is always left implicit, $\tfrac\partial{\partial r}$ is the derivative in $r$ at $r'$ fixed and $\tfrac\partial{\partial R}$ is the derivative in $R$ at $S$ fixed. Hence, in the last computation you have $$ \frac\partial{\partial R}(G(R)Q(S)n(R)) $$ and you should not differentiate $Q$.
Note the following alternative: if $R=r-r'$ but $S=r$ instead, which is more in the spirit of your final computation, we have $$ \frac\partial{\partial r}=\frac{\partial R}{\partial r}\frac\partial{\partial R}+\frac{\partial S}{\partial r}\frac\partial{\partial S}=\frac{\partial}{\partial R}+\frac\partial{\partial S} $$ and so $$ \frac\partial{\partial r}(G(r-r')Q(r')n(r-r'))= \frac\partial{\partial R}(G(R)Q(S-R)n(R))+\frac\partial{\partial S}(G(R)Q(S-R)n(R)) $$ and note that the additional term coming from differentiating $Q(S-R)$ in $R$ (that you have) is compensated by the last term obtained from differentiating $Q(S-R)$ in $S$ (that you missed).