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? 
 A: 
Where am I going wrong?

Recall
$$\frac{d}{dx}f(g(x))=f'(g(x))g'(x)$$
with
$$f(\cdot) = \ln(\cdot) \rightarrow f'(\cdot) = \frac{1}{\cdot}$$
and
$$g(x) = \frac{a^2}{x^2} \rightarrow g'(x) = \frac{-2a^2}{x^3}$$
Thus
$$\frac{d}{dx}\ln\frac{a^2}{x^2} = \frac{1}{\frac{a^2}{x^2}}\frac{-2a^2}{x^3} = -\frac{2}{x}$$

An alternative approach is to recognize
$$\ln x^{-2} = -2\ln x$$
thus
$$ \ln\frac{a^2}{x^2} = \ln a^2 + \ln x^{-2} = \ln a^2 -2 \ln x$$
for which we can immediately write the derivative.
A: You are doing nothing wrong except failing to take the second derivative correctly. Remember, derivative is "the speed of change" of a function. Now, you take a dimensionless number and want to find how fast it changes in respect to x. Of course the resulting dimension will be ~ [1/m], where m is the thing you  measure your distances in (I usually use metres ;)). 
Imagine you did the same with change over time: the initial function may very well be dimensionless — yet after taking the derivative, the dimension would obviously be $s^{-1}$
A: 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.
