In short

To differentiate f(x) with respect to g(x), compute \dfrac{d\,f(x)}{d\,g(x)} = \dfrac{f'(x)}{g'(x)}. Both functions are differentiated with respect to x, and then you divide. This is the chain rule in disguise.

Here is a problem that looks strange the first time you see it.

Differentiate x^3 with respect to x^2.

With respect to x^2? Every derivative you have computed so far has been with respect to x — the plain variable. What does it even mean to differentiate with respect to x^2?

The answer is surprisingly simple, and once you see it, you will realise it is the same chain rule you already know, just viewed from a different angle.

What "with respect to" means

When you compute \dfrac{d}{dx}(x^3) = 3x^2, you are asking: if x increases by a tiny amount, how much does x^3 change, per unit of that increase in x?

Now ask a different question: if x^2 increases by a tiny amount, how much does x^3 change, per unit of that increase in x^2?

This is a perfectly reasonable question. As x grows, both x^2 and x^3 grow. You are asking about the rate of change of one with respect to the other — not with respect to x, but with respect to x^2.

Think of a concrete number. Take x = 2. At this point:

That ratio is heading toward 3 as the nudge shrinks. And 3 is exactly what you get from the formula: (3x^2) / (2x) = 3x/2, evaluated at x = 2, gives 6/2 = 3.

The recipe is: differentiate both functions with respect to x, then divide.

Try another value to build confidence. At x = 3: x^3 = 27, x^2 = 9, and the formula gives 3(3)/2 = 4.5. Nudge to x = 3.01: x^3 = 27.270901, x^2 = 9.0601. The ratio (27.270901 - 27)/(9.0601 - 9) = 0.270901/0.0601 \approx 4.508. Heading toward 4.5, just as the formula predicted.

The recipe works because both functions are riding the same underlying variable x. Any tiny change in x simultaneously nudges x^3 and x^2, and the ratio of those nudges — the one you actually care about — is the ratio of their individual rates of change.

The formula

Derivative of $f(x)$ with respect to $g(x)$

If f and g are differentiable functions of x, and g'(x) \neq 0, then

\frac{d\,f(x)}{d\,g(x)} = \frac{f'(x)}{g'(x)} = \frac{df/dx}{dg/dx}

Why this works — the chain rule. Let u = g(x). Then f(x) can be thought of as a function of u (through x). By the chain rule:

\frac{df}{dx} = \frac{df}{du} \cdot \frac{du}{dx}

Rearrange:

\frac{df}{du} = \frac{df/dx}{du/dx} = \frac{f'(x)}{g'(x)}

That is the entire derivation. The formula is the chain rule, solved for df/du instead of df/dx.

In Leibniz notation, it looks like you are cancelling the dx's in the fraction \dfrac{df/dx}{dg/dx}. And indeed, in this case, the cancellation gives the right answer. The chain rule is the justification for why this cancellation is valid.

The opening problem solved

Back to "differentiate x^3 with respect to x^2." Apply the formula:

\frac{d(x^3)}{d(x^2)} = \frac{\frac{d}{dx}(x^3)}{\frac{d}{dx}(x^2)} = \frac{3x^2}{2x} = \frac{3x}{2}

You can verify this a different way. Let u = x^2, so x = u^{1/2} (for x > 0), and x^3 = u^{3/2}. Differentiating directly:

\frac{d(u^{3/2})}{du} = \frac{3}{2}u^{1/2} = \frac{3}{2}\sqrt{x^2} = \frac{3x}{2}

Same answer. The formula and the direct substitution agree. The formula is faster — you skip the step of rewriting f in terms of g — but the substitution gives a useful sanity check.

$f(x) = x^3$ (solid) and $g(x) = x^2$ (dashed). Both grow as $x$ increases, but $x^3$ grows faster. The "with respect to" derivative $3x/2$ measures exactly how much faster — at $x = 2$, for every unit increase in $x^2$, $x^3$ increases by $3$ units.

The first worked example

Example 1: Differentiate $\sin^2 x$ with respect to $\cos x$

Step 1. Identify the two functions.

f(x) = \sin^2 x, \qquad g(x) = \cos x

Why: f is the function being differentiated, g is the function you are differentiating with respect to.

Step 2. Differentiate both with respect to x.

f'(x) = 2\sin x \cos x, \qquad g'(x) = -\sin x

Why: for f', use the chain rule on (\sin x)^2. For g', differentiate \cos x directly.

Step 3. Divide.

\frac{d(\sin^2 x)}{d(\cos x)} = \frac{2\sin x \cos x}{-\sin x} = -2\cos x

Why: the \sin x cancels (valid whenever \sin x \neq 0), leaving -2\cos x.

Step 4. Verify the answer makes sense. Since \sin^2 x = 1 - \cos^2 x, if you let u = \cos x, then \sin^2 x = 1 - u^2. Differentiating directly: \dfrac{d(1 - u^2)}{du} = -2u = -2\cos x. The same answer, confirming the formula.

Why: this substitution check is the most reliable way to verify a "with respect to" derivative — rewrite f as a function of g and differentiate directly.

Result: \dfrac{d(\sin^2 x)}{d(\cos x)} = -2\cos x.

The functions $\sin^2 x$ (solid black) and $\cos x$ (dashed red). When $\cos x$ decreases, $\sin^2 x$ increases — and the rate of exchange between them is $-2\cos x$. The negative sign reflects that they move in opposite directions through most of the cycle.

The answer -2\cos x tells you that when \cos x decreases by a tiny amount, \sin^2 x increases by approximately 2\cos x times that amount. The negative sign captures the fact that \sin^2 x and \cos x generally move in opposite directions — when one grows, the other shrinks (think of the identity \sin^2 x + \cos^2 x = 1).

A chain rule reinterpretation

The formula \dfrac{df}{dg} = \dfrac{f'(x)}{g'(x)} is the chain rule read in a new way.

The standard chain rule says: to differentiate a composite function, multiply rates along the chain. If y depends on u and u depends on x, then dy/dx = (dy/du)(du/dx).

The "with respect to" formula says: to find the rate of change of f per unit change in g, divide their individual rates of change with respect to a common variable. If both f and g depend on x, then

\frac{df}{dg} = \frac{df/dx}{dg/dx}

These are the same statement. In the chain rule, you multiply rates along a chain. In the "with respect to" formula, you divide rates that share the same base variable. Multiplication and division are inverse operations, so df/dg = (df/dx) \div (dg/dx) is just the chain rule df/dx = (df/dg) \cdot (dg/dx) rearranged.

This reinterpretation shows why the formula requires g'(x) \neq 0. If g'(x) = 0, then g is momentarily not changing — it is at a maximum, a minimum, or a flat spot. At such a point, asking "how much does f change per unit change in g" is meaningless, because g isn't changing at all. It is like asking "how many kilometres per litre" when the car has stopped — the denominator is zero, and the question has no answer at that instant.

The second worked example

Example 2: Differentiate $\tan^{-1} x$ with respect to $\sin^{-1}\!\left(\dfrac{2x}{1+x^2}\right)$

This is a classic JEE-style problem where the answer simplifies dramatically.

Step 1. Identify the functions and look for a simplification.

f(x) = \tan^{-1} x, \qquad g(x) = \sin^{-1}\!\left(\frac{2x}{1+x^2}\right)

Why: before differentiating, check whether g(x) simplifies. The expression \dfrac{2x}{1+x^2} is the double-angle identity \sin 2\theta when x = \tan\theta.

Step 2. Simplify g(x). Let x = \tan\theta, so \theta = \tan^{-1} x. Then

\frac{2x}{1+x^2} = \frac{2\tan\theta}{1+\tan^2\theta} = \sin 2\theta

So g(x) = \sin^{-1}(\sin 2\theta) = 2\theta = 2\tan^{-1} x, provided |2\theta| \leq \pi/2, i.e., |x| \leq 1.

Why: the identity \dfrac{2\tan\theta}{1+\tan^2\theta} = \sin 2\theta is a standard double-angle formula. The restriction |x| \leq 1 ensures 2\theta stays in the principal range of \sin^{-1}.

Step 3. Now the problem is easy. For |x| \leq 1:

\frac{d(\tan^{-1} x)}{d(2\tan^{-1} x)} = \frac{\frac{d}{dx}(\tan^{-1} x)}{\frac{d}{dx}(2\tan^{-1} x)} = \frac{1/(1+x^2)}{2/(1+x^2)} = \frac{1}{2}

Why: both derivatives produce factors of 1/(1+x^2), and those factors cancel completely, leaving a constant.

Step 4. Interpret the result. The derivative is a constant — 1/2 — independent of x. This makes perfect sense: since g(x) = 2f(x) (in the valid range), f is always exactly half of g. A linear relationship has a constant derivative.

Why: if f = (1/2)g, then df/dg = 1/2 everywhere. The chain rule computation confirms what the algebraic simplification already told you.

Result: \dfrac{d(\tan^{-1} x)}{d\!\left(\sin^{-1}\!\frac{2x}{1+x^2}\right)} = \dfrac{1}{2}, for |x| \leq 1.

$f(x) = \tan^{-1} x$ (solid black) and $g(x) = 2\tan^{-1} x$ (dashed red). Since $g = 2f$ in the range $|x| \leq 1$, the two curves maintain a constant vertical ratio. The derivative of $f$ with respect to $g$ is $1/2$ everywhere in this range — a constant, because the relationship is linear.

The lesson here is strategic: when you see a complicated-looking "with respect to" problem, the first move is to check whether a substitution simplifies the inner expression. Inverse trigonometric functions with double-angle arguments almost always collapse. The chain rule formula is the tool, but simplification is the technique.

A third example: the direct approach

Not every "with respect to" problem involves inverse trig. Here is a purely algebraic one.

Differentiate e^{3x} with respect to e^x.

Let f(x) = e^{3x} and g(x) = e^x. Then:

\frac{df}{dg} = \frac{f'(x)}{g'(x)} = \frac{3e^{3x}}{e^x} = 3e^{2x}

Check by substitution: let u = e^x, so e^{3x} = (e^x)^3 = u^3. Then d(u^3)/du = 3u^2 = 3e^{2x}. Same answer.

This example shows a pattern: when f(x) = [g(x)]^n — that is, f is a power of g — the "with respect to" derivative is just the power rule applied with g as the variable:

\frac{d\,[g(x)]^n}{d\,g(x)} = n[g(x)]^{n-1}

This is exactly what you would expect from ordinary differentiation. The formula f'(x)/g'(x) reduces to the power rule whenever f is a power of g.

$f(x) = e^{3x}$ (solid), $g(x) = e^x$ (dashed), and their "with respect to" derivative $3e^{2x}$ (dotted red). At $x = 1$, each unit increase in $e^x$ produces approximately $3e^2 \approx 22.2$ units of increase in $e^{3x}$.

When the approach is useful

Differentiating one function with respect to another is not just a textbook exercise. It arises in several natural contexts.

Comparing growth rates. If f(r) represents the volume of a sphere (\frac{4}{3}\pi r^3) and g(r) represents its surface area (4\pi r^2), both as functions of the radius r, then df/dg tells you how volume changes per unit change in surface area. Compute it:

\frac{df}{dg} = \frac{4\pi r^2}{8\pi r} = \frac{r}{2}

So when the radius is 10 cm, each additional square centimetre of surface area adds half a centimetre's worth of volume — specifically 5 cm^3. This is a physically meaningful quantity with units of length.

Eliminating a common variable. In parametric problems, both f and g depend on a parameter t. The ratio f'(t)/g'(t) tells you how f changes relative to g — which is exactly the parametric derivative you saw in the article on Parametric Differentiation. That article's central formula dy/dx = (dy/dt)/(dx/dt) is a special case of this one, with f = y and g = x. The two ideas are the same idea wearing different clothes.

Simplifying competitive exam problems. Many JEE problems present a derivative "with respect to" an inverse trigonometric expression precisely because the expression simplifies via a substitution. The problem is testing whether you recognise the double-angle or half-angle identity hidden inside g(x) before you start differentiating. If you do, the computation collapses to a few lines. If you don't, you face a wall of algebra.

Here is a checklist of substitutions to try when you see an inverse trig expression inside a "with respect to" problem:

Expression inside g(x) Substitution Identity used
\dfrac{2x}{1+x^2} x = \tan\theta \sin 2\theta = \dfrac{2\tan\theta}{1+\tan^2\theta}
\dfrac{1-x^2}{1+x^2} x = \tan\theta \cos 2\theta = \dfrac{1-\tan^2\theta}{1+\tan^2\theta}
\dfrac{2x}{1-x^2} x = \tan\theta \tan 2\theta = \dfrac{2\tan\theta}{1-\tan^2\theta}
\dfrac{3x-x^3}{1-3x^2} x = \tan\theta \tan 3\theta formula
2x\sqrt{1-x^2} x = \sin\theta \sin 2\theta = 2\sin\theta\cos\theta

If you spot one of these patterns, the inverse trig expression collapses to a multiple of \tan^{-1} x or \sin^{-1} x, and the problem becomes trivial.

Strategy flowchart for differentiating f with respect to gA four-step flowchart: Step 1 check for simplification via trig identity, Step 2 differentiate f and g with respect to x, Step 3 divide f prime by g prime, Step 4 verify by substitution if possible. Step 1 Simplify g(x) first Step 2 Compute f'(x), g'(x) Step 3 Divide f'(x) / g'(x) Step 4 Verify via substitution
The four-step procedure for any "differentiate $f$ with respect to $g$" problem. Step 1 (simplification) is the most important — it can reduce the entire problem to two lines.

The method step by step

Here is a clear procedure for any "differentiate f(x) w.r.t. g(x)" problem:

  1. Check for simplification first. If f or g involves inverse trigonometric functions with composite arguments, look for a substitution (x = \tan\theta, x = \sin\theta, etc.) that collapses the expression. This step saves enormous effort.

  2. Differentiate both f(x) and g(x) with respect to x. Use whatever rules you need — chain rule, product rule, quotient rule.

  3. Divide: f'(x) / g'(x). Simplify the resulting expression.

  4. Verify. If possible, rewrite f as a function of g and differentiate directly to check.

The order matters. Step 1 can turn a twenty-line computation into a two-line one. Skipping it is the single biggest tactical mistake students make on "with respect to" problems.

Common confusions

Going deeper

If you came here to learn the formula and see it applied, you have that — you can stop here. The rest of this section connects the idea to more advanced concepts and examines the edge cases.

A geometric reading

There is a nice geometric way to see the "with respect to" derivative. Imagine plotting f(x) on the vertical axis and g(x) on the horizontal axis as x varies. Each value of x gives a point (g(x), f(x)) in this new coordinate system. The result is a curve in the (g, f)-plane.

The slope of this curve at any point is df/dg — the "with respect to" derivative.

For Example 1 (f = \sin^2 x, g = \cos x), the curve in the (g, f)-plane is f = 1 - g^2 — a downward-opening parabola. Its slope is -2g = -2\cos x, confirming the result. You have been computing the slope of this hidden parabola all along.

For the opening problem (f = x^3, g = x^2), the curve is f = g^{3/2} (for x > 0), a power curve. Its slope is (3/2)g^{1/2} = (3/2)\sqrt{x^2} = 3x/2.

This geometric interpretation shows that df/dg is not an abstract algebraic trick. It is the slope of a genuine curve — the curve you get by plotting one function against another, with x as a hidden parameter that drives both.

The curve $f = g^{3/2}$ obtained by plotting $f(x) = x^3$ against $g(x) = x^2$ (for $x > 0$). Each point on this curve corresponds to a value of $x$: when $x = 1$, $(g, f) = (1, 1)$; when $x = 2$, $(g, f) = (4, 8)$. The slope of this curve is $df/dg = 3x/2$.

The general Leibniz perspective

Leibniz's original vision of calculus was built on ratios of infinitesimals. In this framework, df/dg is literally the ratio of two infinitely small changes: the change in f divided by the change in g, both caused by the same infinitely small change in x.

Modern calculus has replaced infinitesimals with limits (the \epsilon-\delta framework), but Leibniz's notation survives because it is so suggestive. The formula

\frac{df}{dg} = \frac{df/dx}{dg/dx}

looks like you are cancelling dx's in a fraction. The chain rule is the rigorous theorem that says this cancellation gives the correct answer. Every time you manipulate Leibniz notation and get a valid result, the chain rule is working behind the scenes.

The inverse function case

A special case: differentiate f(x) with respect to f^{-1}(x), where f^{-1} is the inverse function. Let g = f^{-1}. Then

\frac{df}{dg} = \frac{f'(x)}{(f^{-1})'(x)} = \frac{f'(x)}{1/f'(f^{-1}(x))} = f'(x) \cdot f'(f^{-1}(x))

This uses the inverse function derivative formula (f^{-1})'(x) = 1/f'(f^{-1}(x)). The result is not as clean as the general formula, but it shows how the "with respect to" framework connects to inverse functions.

Higher-order "with respect to" derivatives

Can you compute \dfrac{d^2 f}{dg^2}, the second derivative of f with respect to g? You can, but the formula is not simply f''(x)/g''(x). Following the same logic as the second parametric derivative:

\frac{d^2 f}{dg^2} = \frac{\frac{d}{dx}\!\left(\frac{f'}{g'}\right)}{g'} = \frac{f''g' - f'g''}{(g')^3}

This mirrors the parametric second derivative formula (\ddot{y}\dot{x} - \dot{y}\ddot{x})/\dot{x}^3 exactly — because the parametric derivative is a special case of the "with respect to" derivative.

Working through a harder example

Differentiate \cos^{-1}\!\left(\dfrac{1-x^2}{1+x^2}\right) with respect to \tan^{-1} x.

Let f(x) = \cos^{-1}\!\left(\dfrac{1-x^2}{1+x^2}\right) and g(x) = \tan^{-1} x.

Put x = \tan\theta. Then:

\frac{1-x^2}{1+x^2} = \frac{1-\tan^2\theta}{1+\tan^2\theta} = \cos 2\theta

So f(x) = \cos^{-1}(\cos 2\theta) = 2\theta = 2\tan^{-1} x (for 0 \leq 2\theta \leq \pi, i.e., x \geq 0).

And g(x) = \tan^{-1} x = \theta.

Therefore:

\frac{df}{dg} = \frac{f'(x)}{g'(x)} = \frac{2/(1+x^2)}{1/(1+x^2)} = 2

The answer is a constant, 2, for x \geq 0. This happens because f = 2g in this range — the two functions are linearly related, so their rate of change is constant.

For x < 0, the situation is more subtle. The principal value branch of \cos^{-1} means \cos^{-1}(\cos 2\theta) = -2\theta when 2\theta < 0, so f = -2\tan^{-1} x and the derivative becomes -2. The absolute value hides a sign change.

A table of standard results

Several "differentiate f w.r.t. g" problems appear frequently in Indian competitive exams. Here are the most common, with their answers:

f(x) g(x) \dfrac{df}{dg} Key identity used
\sin^2 x \cos x -2\cos x \sin^2 x = 1 - \cos^2 x
x^3 x^2 \dfrac{3x}{2} Direct computation
\tan^{-1} x \cot^{-1} x -1 \tan^{-1} x + \cot^{-1} x = \pi/2
\log x x^2 \dfrac{1}{2x^2} Direct computation
e^{x^2} e^x 2xe^{x^2 - x} Direct computation

The third row is particularly elegant: since \tan^{-1} x + \cot^{-1} x = \pi/2 (a constant), differentiating both sides with respect to x gives (\tan^{-1} x)' + (\cot^{-1} x)' = 0, so (\tan^{-1} x)' = -(\cot^{-1} x)'. Their ratio is -1, always.

Let us verify the last row. f(x) = e^{x^2}, g(x) = e^x.

f'(x) = 2xe^{x^2}, \qquad g'(x) = e^x
\frac{df}{dg} = \frac{2xe^{x^2}}{e^x} = 2xe^{x^2 - x}

This result cannot be simplified further. Unlike the inverse trig examples, there is no hidden relationship between e^{x^2} and e^x that would collapse the answer to a constant. The derivative genuinely depends on x.

The principal value trap

Many "with respect to" problems involving inverse trig functions have a hidden trap: the principal value branch. In Example 2, the simplification \sin^{-1}(\sin 2\theta) = 2\theta is only valid when -\pi/2 \leq 2\theta \leq \pi/2, i.e., when |x| \leq 1. Outside this range, the principal value of \sin^{-1} wraps the answer, and you get \pi - 2\theta instead of 2\theta.

This means the derivative can change sign (or value) as x crosses the boundary. The problem statement usually specifies a range, and you must check which branch of the principal value applies. If no range is specified, state the range for which your answer is valid.

For the going-deeper example (\cos^{-1} with respect to \tan^{-1}), the derivative is +2 for x > 0 and -2 for x < 0. At x = 0, both sides equal 0 and the derivative is technically +2 (the right-hand limit). These branch issues are the main source of mistakes on competitive exams.

Where this leads next

You now know how to differentiate one function with respect to another. The natural continuations: