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:
- x^3 = 8 and x^2 = 4.
- Nudge x from 2 to 2.01. Then x^3 goes from 8 to 8.120601 (change of 0.120601) and x^2 goes from 4 to 4.0401 (change of 0.0401).
- The ratio of changes is 0.120601 / 0.0401 \approx 3.008.
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
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:
Rearrange:
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:
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:
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.
The first worked example
Example 1: Differentiate $\sin^2 x$ with respect to $\cos x$
Step 1. Identify the two functions.
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.
Why: for f', use the chain rule on (\sin x)^2. For g', differentiate \cos x directly.
Step 3. Divide.
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 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
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.
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
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:
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.
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:
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:
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.
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:
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.
The method step by step
Here is a clear procedure for any "differentiate f(x) w.r.t. g(x)" problem:
-
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.
-
Differentiate both f(x) and g(x) with respect to x. Use whatever rules you need — chain rule, product rule, quotient rule.
-
Divide: f'(x) / g'(x). Simplify the resulting expression.
-
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
-
"Differentiate f(x) with respect to g(x)" means differentiate the composite f(g(x))." No. If the problem says "differentiate x^3 with respect to x^2," it does not mean "differentiate (x^2)^3 = x^6 with respect to x." It means: compute d(x^3)/d(x^2), which is 3x^2/(2x) = 3x/2. This is the most common misunderstanding — confusing "with respect to" with "composed with."
-
"The answer should be in terms of g(x), not x." It can be in either form. Often the answer is simplest in terms of x. Sometimes you can rewrite it in terms of g — as in Example 1, where -2\cos x is the same as -2u with u = \cos x — but this is not required. Unless the problem explicitly says "express in terms of g," leave the answer in whichever form is cleanest.
-
"If g'(x) = 0 at some point, the derivative of f with respect to g is zero there." It is undefined, not zero. Division by zero is not zero. Geometrically, g'(x) = 0 means g has a turning point, and you cannot measure the rate of change of f per unit change in g when g is not changing. The situation is analogous to a vertical tangent in parametric curves — the ratio blows up.
-
"This is a new rule of differentiation." It is not. It is the chain rule, rearranged. No new mathematics is involved — just a different way of asking the question. If you understand the chain rule, you already understand this formula.
-
"The answer for \tan^{-1} x w.r.t. \cot^{-1} x depends on x." It does not. Since \tan^{-1} x + \cot^{-1} x = \pi/2 for all x, the derivative of \tan^{-1} x is always -1 times the derivative of \cot^{-1} x. Their ratio is the constant -1. When two functions differ by a constant, or one is a constant multiple of the other, the "with respect to" derivative is a constant.
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 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
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
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:
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:
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:
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.
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:
- Chain Rule — the foundational rule that makes this formula work. If you haven't read it yet, this is essential background.
- Parametric Differentiation — the special case where you differentiate y(t) with respect to x(t), both given as functions of a parameter.
- Higher Order Derivatives — what happens when you differentiate more than once.
- Implicit Differentiation — another technique for finding dy/dx when the relationship between x and y is not given explicitly.
- Inverse Functions — the derivative of an inverse function is a close relative of the ideas in this article.