differentiate with respect to a function
You can think about it in terms of "cancellation":
$$\frac{df(x)}{d (x^2)} = \frac{df(x)/dx}{d(x^2)/dx} = \frac{1}{2 x} \frac{df(x)}{dx}$$
More formally, let $y=x^2$, then consider $x=\sqrt{y}$ and differentiate $\,df(\sqrt{y})/dy$.
As mostly a follow-up to rlgordonma's answer, here's a way to explain the method that perhaps fits a bit closer to things you're probably used to seeing.
Let $u = x^2$ and use the chain rule as follows for the function $f(x)$:
$$\frac{df}{dx} \; = \; \frac{df}{du} \frac{du}{dx} \; = \; \frac{df}{du} \cdot 2x$$
$$\implies \;\; \frac{df}{du} \; = \; \frac{1}{2x} \cdot \frac{df}{dx}$$
For what it's worth, I've seen problems stated in exactly the way Badshah stated his question in old calculus texts, such as:
George Abbott Osborne, Differential and Integral Calculus (1908). [See page 60 for several neat examples.]
So it's true that the correct answer is that if we want to differentiate f(x) with respect to another g(x) that we take $$\frac{f'(x)}{g'(x)}$$, but I think just calling this chain rule cancellation is not exactly correct (though it is both intuitive and also gives the right answer... lol).
To formalize things, let's say we have (1) $$f(t) = h(t,g(t))$$, which for simplicity in applying the multivariate chain rule we can write as $$f(t) = h(x(t), y(t))$$
So then (2) $$\frac{df}{dy} = \frac{dh}{dx}\frac{dx}{dy} + \frac{dh}{dy}\frac{dy}{dy}$$. We know that $$\frac{dx}{dy} = \frac{dt}{dg} = \frac{1}{\frac{dg}{dt}} = \frac{1}{g'(t)}$$, by the inverse derivative theorem, and we know $$\frac{dy}{dy} = 1$$.
So in (1) if we multiply $$\frac{dh}{dy}$$ by $$1 = \frac{g'(t)}{g'(t)}$$, we get (3) $$\frac{df}{dy} = \frac{\frac{dh}{dx}*1 + \frac{dh}{dy}\frac{dy}{dt}}{g'(t)}$$, since y=g, and then since x=t, we can write $$1 = \frac{dx}{dt}$$, which gives us
$$\frac{df}{dy} = \frac{\frac{dh}{dx}*\frac{dx}{dt} + \frac{dh}{dy}\frac{dy}{dt}}{g'(t)}$$, which is just $$\frac{f'(t)}{g'(t)}$$.