<s>[INST] Apparent dimensional mismatch after taking derivative Suppose I have a variable $x$ and a constant $a$, each having the dimension of length. That is $[x]=[a]=[L]$ where square brackets denote the dimension of the physical quantity contained within them. 
Now, we wish to take the derivative of $u = log (\frac{x^2}{a^2})-log (\frac{a^2}{x^2})$. Here, we have taken the natural logarithm. It is clear that $u$ is a dimensionless function. 
$$\frac{du}{dx} = \frac{a^2}{x^2}.\frac{2x}{a^2} - \frac{x^2}{a^2}.(-2a^2).\frac{2x}{x^3} \\
= \frac{1}{x} - 4. $$
Here, the dimensions of the two terms on the right do not match. The dimension of the first term is what I expected. Where am I going wrong? 
 [/INST] I think the second half of your derivative is wrong:
$ \frac{d}{dx} \log\left( \frac{a^2}{x^2}\right) = \frac{x^2}{a^2} \cdot \frac{d}{dx} \left(a^2 x^{-2}\right) = \frac {x^2} {a^2} \left(-3a^2\right) x^{-3} = \frac{-3 a^4}{x} $
which has the correct dimension.
</s>