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?