Why the Inner Derivative Matters
A tangent or cotangent expression may have an input more complicated than \(x\). For example, the angle might be \(3x^2-1\) or \(\sqrt{x+3}\). Differentiating such an expression requires two pieces of information: how the trigonometric function changes with its angle, and how quickly that angle changes with \(x\).
The chain rule combines these two rates. The derivative of the outer function supplies one factor, evaluated at the inner function, and the derivative of the inner function supplies another. Keeping both factors is essential: the derivative of \(\tan(u(x))\) is not just \(\sec^2(u(x))\), and the derivative of \(\cot(u(x))\) is not just \(-\csc^2(u(x))\).
Definitions and Domain Conditions
Let \(u\) be differentiable at \(x\). The expression \(\tan(u(x))\) is defined when \(\cos(u(x))\ne 0\), because \(\tan t=\sin t/\cos t\). The expression \(\cot(u(x))\) is defined when \(\sin(u(x))\ne 0\), because \(\cot t=\cos t/\sin t\). These restrictions matter: a derivative formula can only be applied at a point where the original composite function is defined.
Since sine and cosine are continuous, if the relevant denominator is nonzero at a point, it remains nonzero in some interval around that point. Thus the composition is defined locally there, as needed for its derivative.
Here \(\sec t=1/\cos t\) and \(\csc t=1/\sin t\). The formulas may also be written using reciprocals of cosine and sine squared:
The two forms are equivalent wherever the corresponding function is defined. The minus sign in the cotangent formula belongs to the outer derivative; it does not replace or cancel the inner derivative.
Why These Formulas Follow from the Chain Rule
The chain rule says that if an outer function \(F\) is differentiable at \(u(x)\) and \(u\) is differentiable at \(x\), then \((F\circ u)'(x)=F'(u(x))u'(x)\). Apply it first with \(F(t)=\tan t\), whose derivative is \(\sec^2 t\), and then with \(F(t)=\cot t\), whose derivative is \(-\csc^2 t\). Substitution gives the stated formulas.
The multiplication by \(u'(x)\) has a rate-of-change interpretation. A small change in \(x\) produces, to first order, a change of about \(u'(x)\) times as much in the angle \(u(x)\). The tangent or cotangent responds to that angle change at its own rate. Multiplying the two rates gives the rate of change with respect to \(x\).
This can also be seen directly from local linearization. Write \(h\) for a small change in \(x\). Differentiability of \(u\) gives \(u(x+h)=u(x)+u'(x)h+o(h)\), where \(o(h)/h\) tends to zero as \(h\) tends to zero. Set \(k=u(x+h)-u(x)\), so \(k=u'(x)h+o(h)\). If \(F\) is differentiable at \(u(x)\), then \(F(u(x)+k)=F(u(x))+F'(u(x))k+o(k)\). Since \(k=O(h)\), the remainder \(o(k)\) is also \(o(h)\) (and when \(k=0\), the corresponding change in \(F\) is zero). Substituting the expression for \(k\) yields \(F(u(x+h))-F(u(x))=F'(u(x))u'(x)h+o(h)\). Dividing by \(h\) and taking the limit gives the chain rule. For tangent and cotangent, this argument applies at inputs where their denominators are nonzero.
A Reliable Differentiation Process
For a composite tangent or cotangent expression, identify the inner function before doing any differentiation. Then differentiate that inner function and use the appropriate outer derivative. This order helps prevent a missing factor or a sign error.
Rewrite the expression mentally as \(\tan(u(x))\) or \(\cot(u(x))\), and record \(u(x)\).
Find \(u'(x)\) separately before combining the factors.
For tangent use \(\sec^2(u(x))\); for cotangent use \(-\csc^2(u(x))\).
Include \(u'(x)\) as a factor, and exclude points where the original tangent or cotangent is undefined.
Worked Examples
Worked Example: Tangent of a Quadratic Input
Differentiate \(y=\tan(3x^2-1)\).
The inner function is \(u(x)=3x^2-1\), so \(u'(x)=3(2x)-0=6x\). The outer tangent derivative is \(\sec^2(u(x))\). Therefore, by the chain rule,
The original expression is defined when \(\cos(3x^2-1)\ne0\); the derivative formula applies at those points. To verify the result, write \(y=\sin(u)/\cos(u)\). Using the quotient rule and the composite sine and cosine derivatives gives
This agrees with the chain-rule answer.
Worked Example: Cotangent with a Decreasing Input
Differentiate \(y=\cot(1-2x)\).
Set \(u(x)=1-2x\). Its derivative is \(u'(x)=0-2=-2\). Cotangent contributes a negative sign, so both the outer derivative and the inner derivative must be included:
The two negative factors produce a positive result. The expression is defined when \(\sin(1-2x)\ne0\). To check the calculation directly, put \(u=1-2x\) and write \(y=\cos(u)/\sin(u)\). Then
The quotient-rule check confirms both the positive sign and the factor \(2\).
Worked Example: Tangent of a Square-Root Input
Differentiate \(y=\tan(\sqrt{x+3})\), and state where the derivative formula applies.
The inner function is \(u(x)=\sqrt{x+3}=(x+3)^{1/2}\). It is differentiable when \(x>-3\), and
Applying the tangent chain rule gives
Thus the formula applies for \(x>-3\) and \(\cos(\sqrt{x+3})\ne0\). The first restriction ensures that the inner function has a finite derivative; the second ensures the tangent is defined. For a direct check, let \(u=\sqrt{x+3}\). The quotient-rule calculation for \(\sin(u)/\cos(u)\) reduces to \(u'/\cos^2(u)\), which is \(\frac{1}{2\sqrt{x+3}}\sec^2(\sqrt{x+3})\), exactly the result above.
Keeping Simplification Under Control
The chain-rule formula is often clearest before any algebraic simplification. For instance, \(u'(x)\sec^2(u(x))\) makes the two sources of the derivative visible. Reordering the factors or writing \(\sec^2(u)=1/\cos^2(u)\) can be useful, but neither operation removes the domain restriction \(\cos(u)\ne0\). Likewise, writing the cotangent derivative with \(\csc^2(u)\) does not make it defined where \(\sin(u)=0\).
Some inner derivatives simplify together with the outer factor. That simplification is valid only after both factors have been found. In particular, do not cancel a factor across a sum, and do not use cancellation to claim that the original composition is defined at a point where its tangent or cotangent denominator is zero.
Common Mistake: Leaving Out the Inner Derivative
A frequent error is to differentiate only the outer tangent or cotangent. For example, the incorrect calculation \(\frac{d}{dx}\tan(3x^2-1)=\sec^2(3x^2-1)\) treats the angle as if it changed at rate \(1\). But the angle \(3x^2-1\) changes at rate \(6x\), so the correct result is
Another common error is to lose a negative sign for cotangent or to confuse it with the sign of the inner derivative. The cotangent rule always begins with \(-\csc^2(u)u'\). If \(u'\) is negative, the product may be positive, as in \(\frac{d}{dx}\cot(1-2x)=2\csc^2(1-2x)\). A useful check is to write both factors explicitly before multiplying.
Why This Rule Is Useful
Tangent and cotangent often describe slopes, ratios, or angular relationships whose angle itself depends on a changing quantity. The chain rule lets us compute the rate of change with respect to that quantity without pretending that the angle is simply \(x\). Its practical value is also structural: once the inner function is identified, the same procedure works whether that input is a polynomial, a root, or another differentiable expression.
For every application, keep three questions in view: What is the inner function? What is its derivative? At which points is the original tangent or cotangent defined? Answering all three produces a derivative that is not only algebraically correct but also valid on the appropriate domain.
Check Your Understanding
For each question, identify the inner function and keep the domain conditions in mind.
- Differentiate \(y=\tan(5x-2)\). What factor comes from differentiating the inner function?
- Differentiate \(y=\cot(x^2+4)\). Where is the original expression defined?
- A student writes \(\frac{d}{dx}\cot(1-3x)=-\csc^2(1-3x)\). What factor is missing, and what is the correct derivative?
- State the condition on \(u(x)\) needed to differentiate \(\tan(u(x))\) at \(x\).
- Explain why the derivative of \(\tan(u(x))\) contains both \(\sec^2(u(x))\) and \(u'(x)\).