Tutorials › Calculus I › Antiderivatives Of Tangent And Cotangent

Antiderivatives and Basic Integrals · Tutorial 1071 of 1495

Antiderivatives Of Tangent And Cotangent

Learn why tangent and cotangent integrate to logarithms, when absolute values are needed, and how to verify the formulas.

Beginner 8 min read

What You'll Learn

  • Derive antiderivatives for tangent and cotangent from logarithmic derivatives.
  • State the intervals on which each formula is valid.
  • Use absolute values to keep logarithms real across positive and negative function values.
  • Integrate tangent and cotangent with scaled arguments.
  • Check each antiderivative by differentiating it.

Why Tangent and Cotangent Lead to Logarithms

Tangent and cotangent are quotients of sine and cosine. Their antiderivatives are logarithmic because the derivative of the natural logarithm of a nonzero function \(u(x)\) is \(u'(x)/u(x)\). In these trigonometric quotients, the numerator that appears after differentiating the logarithm matches the other trigonometric function in the quotient.

The signs require care. The cosine derivative is negative sine, while the sine derivative is cosine. As a result, the tangent antiderivative has a minus sign and the cotangent antiderivative does not.

All angles in the formulas below are measured in radians. Each formula applies on an interval where the trigonometric function being integrated is defined.

Key formulas: Where \(\cos x\ne 0\), an antiderivative of \(\tan x\) is \(-\ln|\cos x|+C\). Where \(\sin x\ne 0\), an antiderivative of \(\cot x\) is \(\ln|\sin x|+C\).

Deriving the Tangent Formula

Recall that \(\tan x=\sin x/\cos x\), so tangent is defined wherever \(\cos x\ne 0\). On any interval with this property, \(\cos x\) never equals zero. The logarithm of its absolute value is therefore defined throughout the interval.

For any differentiable function \(u\) that is nonzero, the chain rule gives \(\frac{d}{dx}\ln|u(x)|=u'(x)/u(x)\). Apply this fact to \(u(x)=\cos x\). Since \(\frac{d}{dx}\cos x=-\sin x\), we obtain:

$$ \frac{d}{dx}\ln|\cos x| = \frac{-\sin x}{\cos x} = -\tan x. $$

Thus the negative of this logarithm differentiates to tangent:

$$ \frac{d}{dx}\bigl(-\ln|\cos x|\bigr) = \tan x. $$

Therefore, on any interval where \(\cos x\ne 0\), the family of antiderivatives is:

$$ \int \tan x\,dx = -\ln|\cos x|+C. $$

Because \(\sec x=1/\cos x\) wherever cosine is nonzero, the same answer can also be written as \(\ln|\sec x|+C\). The two logarithmic forms differ only in how the reciprocal is expressed.

Deriving the Cotangent Formula

Cotangent is \(\cot x=\cos x/\sin x\), so it is defined wherever \(\sin x\ne 0\). On an interval where sine is nonzero, apply the logarithmic derivative rule to \(u(x)=\sin x\). Since \(\frac{d}{dx}\sin x=\cos x\), we have:

$$ \frac{d}{dx}\ln|\sin x| = \frac{\cos x}{\sin x} = \cot x. $$

It follows that on any interval where \(\sin x\ne 0\):

$$ \int \cot x\,dx = \ln|\sin x|+C. $$

The two derivations have the same structure: take the logarithm of the denominator of the quotient, differentiate it, and compare the resulting quotient with the trigonometric function. The derivative of cosine introduces a minus sign, whereas the derivative of sine does not.

Domain condition: The tangent formula is valid only where \(\cos x\ne 0\), and the cotangent formula only where \(\sin x\ne 0\). A constant \(C\) describes the antiderivatives on the interval under consideration.

Worked Examples

Worked Example: Find an Antiderivative of Tangent

Find \(\int \tan x\,dx\), and check the result.

First use the quotient identity \(\tan x=\sin x/\cos x\). The formula applies on any interval on which \(\cos x\ne 0\). The logarithmic derivative of the absolute value of cosine is:

$$ \frac{d}{dx}\ln|\cos x| = \frac{-\sin x}{\cos x} = -\tan x. $$

Negating this logarithm reverses the sign, so an antiderivative is:

$$ \int \tan x\,dx = -\ln|\cos x|+C. $$

Check by differentiating the proposed antiderivative:

$$ \frac{d}{dx}\bigl(-\ln|\cos x|+C\bigr) = -\left(\frac{-\sin x}{\cos x}\right) = \frac{\sin x}{\cos x} = \tan x. $$

The derivative matches the integrand wherever \(\cos x\ne 0\), so the result is correct on each such interval.

Worked Example: Find an Antiderivative of Cotangent

Find \(\int \cot x\,dx\), and verify it.

Where \(\sin x\ne 0\), write \(\cot x=\cos x/\sin x\). Differentiate the logarithm of the absolute value of sine:

$$ \frac{d}{dx}\ln|\sin x| = \frac{\cos x}{\sin x} = \cot x. $$

Therefore:

$$ \int \cot x\,dx = \ln|\sin x|+C. $$

To check, differentiate the complete expression:

$$ \frac{d}{dx}\bigl(\ln|\sin x|+C\bigr) = \frac{\cos x}{\sin x} = \cot x. $$

The check is valid wherever the original integrand is defined, namely where \(\sin x\ne 0\).

Worked Example: Integrate Cotangent with a Scaled Argument

Find \(\int \cot(2x)\,dx\). The inside function \(2x\) changes the derivative by a factor of \(2\), so the logarithmic expression must include a compensating factor of \(1/2\).

Differentiate \(\frac12\ln|\sin(2x)|\). By the chain rule, the derivative of \(\sin(2x)\) is \(2\cos(2x)\):

$$ \begin{aligned} \frac{d}{dx}\left(\frac12\ln|\sin(2x)|\right) &= \frac12\cdot\frac{2\cos(2x)}{\sin(2x)}\\ &= \frac{\cos(2x)}{\sin(2x)}\\ &= \cot(2x). \end{aligned} $$

Thus:

$$ \int \cot(2x)\,dx = \frac12\ln|\sin(2x)|+C, $$

on any interval where \(\sin(2x)\ne 0\). The differentiation above verifies both the factor \(1/2\) and the answer.

Worked Example: Integrate Tangent with a Scaled Argument

Find \(\int \tan(3x)\,dx\), and check the result.

The derivative of \(\cos(3x)\) is \(-3\sin(3x)\). Differentiating \(-\frac13\ln|\cos(3x)|\) therefore gives:

$$ \begin{aligned} \frac{d}{dx}\left(-\frac13\ln|\cos(3x)|\right) &= -\frac13\cdot\frac{-3\sin(3x)}{\cos(3x)}\\ &= \frac{\sin(3x)}{\cos(3x)}\\ &= \tan(3x). \end{aligned} $$

Consequently, on any interval where \(\cos(3x)\ne 0\):

$$ \int \tan(3x)\,dx = -\frac13\ln|\cos(3x)|+C. $$

The derivative calculation returns exactly \(\tan(3x)\), confirming that the factor \(1/3\) is necessary.

Why the Absolute Values Matter

The expressions \(\ln(\cos x)\) and \(\ln(\sin x)\) are real-valued only when their arguments are positive. But tangent and cotangent are defined on intervals where their denominators can be negative as well as positive. The expressions \(\ln|\cos x|\) and \(\ln|\sin x|\) remain real whenever the corresponding denominator is nonzero.

The absolute value does not change the derivative formula on intervals where \(u\ne 0\): \(\frac{d}{dx}\ln|u(x)|=u'(x)/u(x)\). Thus it preserves the desired quotient while allowing the formula to apply on both positive and negative portions of the domain.

For example, replacing \(\ln|\cos x|\) with \(\ln(\cos x)\) unnecessarily restricts the expression to points where \(\cos x>0\). It cannot serve as a real-valued formula on intervals where cosine is negative, even though tangent is defined there.

A Common Sign Mistake

A frequent error is to write \(\int \tan x\,dx=\ln|\cos x|+C\), omitting the negative sign. Differentiate that proposed answer to test it:

$$ \frac{d}{dx}\ln|\cos x| = \frac{-\sin x}{\cos x} = -\tan x. $$

This gives the negative of the required integrand, so the proposed antiderivative is incorrect. The correction is to negate the logarithm:

$$ \frac{d}{dx}\bigl(-\ln|\cos x|\bigr) = -(-\tan x) = \tan x. $$

Checking by differentiation is especially useful here because the sine and cosine derivatives have different signs. A second common mistake is to leave out the absolute value. Doing so can make the logarithm undefined on part of the interval where the original trigonometric function is defined.

Summary

The logarithmic antiderivatives follow directly from the logarithmic derivative rule and the quotient definitions of tangent and cotangent. The sign in the tangent formula comes from \(\frac{d}{dx}\cos x=-\sin x\); the cotangent formula uses \(\frac{d}{dx}\sin x=\cos x\) and has no extra minus sign.

Takeaway: Where \(\cos x\ne 0\), \(\int\tan x\,dx=-\ln|\cos x|+C\). Where \(\sin x\ne 0\), \(\int\cot x\,dx=\ln|\sin x|+C\). For scaled arguments, the coefficient from the chain rule must be accounted for, and differentiation verifies the result.

Check Your Understanding

Use the domain conditions and differentiate your proposed answers to check them.

  1. Find an antiderivative of \(\tan x\) on an interval where it is defined.
  2. Why does the formula for the tangent antiderivative include a negative sign?
  3. Find an antiderivative of \(\cot(4x)\).
  4. Why are absolute values used in the logarithmic formulas?
  5. Differentiate \(-\frac12\ln|\cos(2x)|\) and identify the trigonometric function obtained.

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon