Quick answer:
$$\int\sec^2 x\,dx = \tan x + C$$
The integral of sec²x is one of the shortest results in calculus, but it’s also a building block for dozens of harder integrals: tan²x, even powers of secant, trig substitution, and more. This guide explains where the formula comes from, gives a picture of what it means, and then works through seven examples, from warm-ups to exam-level problems.
Why
Integration undoes differentiation, and the derivative of tan x is \( \sec^2 x \). So \( \tan x \) is an antiderivative of \( \sec^2 x \). That’s the whole proof.
Where the derivative comes from
If you want to see the derivative itself, write tangent as a quotient and apply the quotient rule:
$$\begin{aligned} \frac{d}{dx}\frac{\sin x}{\cos x} &= \frac{\cos x\cdot\cos x - \sin x\cdot(-\sin x)}{\cos^2 x} \\ &= \frac{\cos^2 x + \sin^2 x}{\cos^2 x} \\ &= \frac{1}{\cos^2 x} = \sec^2 x \end{aligned}$$
The Pythagorean identity turns the numerator into 1. Reading this equation backward is exactly the integral formula. It’s worth memorizing both directions together, since exams test them side by side.
Intuition: sec²x is the slope of tan x
Since \( \sec^2 x = \frac{1}{\cos^2 x} \) and \( \cos^2 x \) is never more than 1, \( \sec^2 x \) is always at least 1. That matches the graph of \( \tan x \): on each branch it climbs steadily, with slope exactly 1 at the origin and steeper and steeper slopes near the asymptotes.
The integral turns this around. By the Fundamental Theorem of Calculus, the area under \( \sec^2 x \) from 0 to \( b \) equals \( \tan b - \tan 0 = \tan b \). So the area under the secant-squared curve is literally the height of the tangent graph. When \( b \) approaches \( \frac{\pi}{2} \), \( \tan b \) blows up, and the area does too.
Definite example
$$\int_0^{\pi/4}\sec^2 x\,dx = \tan\frac{\pi}{4} - \tan 0 = 1$$
This is a nice sanity check on the intuition above: on \( [0, \frac{\pi}{4}] \), \( \sec^2 x \) runs from 1 up to 2, so an area of 1 over an interval of length about 0.785 is exactly the right size.
Chain rule in reverse
For a linear inside, divide by its coefficient:
$$\int\sec^2(3x)\,dx = \frac{\tan 3x}{3} + C$$
This is the chain rule backward: differentiating \( \tan 3x \) produces an extra factor of 3, so you divide by 3 to cancel it. For a non-linear inside you need the inside’s derivative present, as in u-substitution:
$$\int x\sec^2(x^2)\,dx = \frac{\tan(x^2)}{2} + C$$
Integral of tan²x
This one trips people up. Use the identity \( \tan^2 x = \sec^2 x - 1 \):
$$\int\tan^2 x\,dx = \int\sec^2 x\,dx - \int 1\,dx = \tan x - x + C$$
Spotting sec²x in disguise
Many integrals are really \( \int\sec^2 x\,dx \) wearing a costume. Before reaching for a complicated technique, check whether the integrand can be rewritten as one of these:
- \( \frac{1}{\cos^2 x} \), which is \( \sec^2 x \) by definition.
- \( 1 + \tan^2 x \), which equals \( \sec^2 x \) by the Pythagorean identity.
- \( \frac{1}{1 + \cos 2x} \) or \( \frac{1}{1 - \sin^2 x} \), which both reduce to a multiple of \( \frac{1}{\cos^2 x} \).
- A product where \( \sec^2 x \) multiplies a function of \( \tan x \). Here \( \sec^2 x\,dx \) is \( du \) for \( u = \tan x \).
The last pattern is the most useful by far. Any time \( \tan x \) appears inside another function and \( \sec^2 x \) sits outside it, the substitution \( u = \tan x \) removes all the trig at once.
Worked examples
Example 1 (a definite interval). From \( \frac{\pi}{6} \) to \( \frac{\pi}{3} \), subtract the tangent values \( \sqrt3 \) and \( \frac{1}{\sqrt3} \):
$$\int_{\pi/6}^{\pi/3}\sec^2 x\,dx = \sqrt3 - \frac{\sqrt3}{3} = \frac{2\sqrt3}{3} \approx 1.1547$$
Example 2 (hidden sec²). For \( \int\frac{dx}{1 + \cos 2x} \), use the double-angle identity \( 1 + \cos 2x = 2\cos^2 x \). The integrand becomes \( \frac12\sec^2 x \), so
$$\int\frac{dx}{1 + \cos 2x} = \frac{\tan x}{2} + C$$
The lesson: whenever you see \( \cos^2 x \) in a denominator, think \( \sec^2 x \). Recognizing the identity turns what looks like a hard rational trig integral into a one-line answer.
Example 3 (power of tangent). For \( \int\sec^2 x\tan^3 x\,dx \), the \( \sec^2 x \) is the derivative of \( \tan x \). Let \( u = \tan x \), so the integral is \( \int u^3\,du \):
$$\int\sec^2 x\tan^3 x\,dx = \frac{\tan^4 x}{4} + C$$
Example 4 (log answer). For \( \int\frac{\sec^2 x}{1 + \tan x}\,dx \), the numerator is the derivative of the denominator. Let \( u = 1 + \tan x \); the answer is \( \ln|1 + \tan x| + C \). Keep the absolute value, since \( 1 + \tan x \) is negative whenever \( \tan x < -1 \).
Example 5 (exponential). For \( \int\sec^2 x\,e^{\tan x}\,dx \), the same substitution \( u = \tan x \) gives \( \int e^u\,du \), so the answer is \( e^{\tan x} + C \). Differentiating confirms it: the chain rule brings down the derivative of \( \tan x \), which is exactly the \( \sec^2 x \) you started with.
Example 6 (integration by parts). For \( \int x\sec^2 x\,dx \), let \( u = x \) and \( dv = \sec^2 x\,dx \), so \( v = \tan x \). Choosing \( u = x \) works because differentiating \( x \) leaves 1, while \( \sec^2 x \) is easy to integrate. The leftover integral is the integral of tan x:
$$\begin{aligned} \int x\sec^2 x\,dx &= x\tan x - \int\tan x\,dx \\ &= x\tan x + \ln|\cos x| + C \end{aligned}$$
Example 7 (exam level). For \( \int(\sec x + \tan x)^2\,dx \), expand the square to get \( \sec^2 x + 2\sec x\tan x + \tan^2 x \). Replace \( \tan^2 x \) with \( \sec^2 x - 1 \), so you have two copies of \( \sec^2 x \), one \( 2\sec x\tan x \), and a \( -1 \). Each piece is now a basic integral:
$$\int(\sec x + \tan x)^2\,dx = 2\tan x + 2\sec x - x + C$$
You can verify these with the integral calculator.
Related trig integrals
| Integral | Result |
|---|---|
| \( \int\sec^2 x\,dx \) | \( \tan x + C \) |
| \( \int\csc^2 x\,dx \) | \( -\cot x + C \) |
| \( \int\sec x\tan x\,dx \) | \( \sec x + C \) |
| \( \int\csc x\cot x\,dx \) | \( -\csc x + C \) |
| \( \int\sec x\,dx \) | \( \ln\lvert\sec x + \tan x\rvert + C \) |
The last one needs a trick; see integral of sec x.
The csc²x twin
Cosecant squared follows the same logic with a sign change. The derivative of \( \cot x \) is \( -\csc^2 x \), which you can check with the quotient rule on \( \frac{\cos x}{\sin x} \). Reversing it gives
$$\int\csc^2 x\,dx = -\cot x + C$$
The minus sign is the only thing to remember. A quick way to recall it: every cofunction (cosine, cotangent, cosecant) picks up a minus sign in its derivative.
Common mistakes
- Using the power rule. \( \frac{\sec^3 x}{3} \) differentiates to \( \sec^3 x\tan x \), not \( \sec^2 x \).
- Mixing it up with the integral of sec x. Plain \( \sec x \) needs a log; \( \sec^2 x \) doesn’t.
- Forgetting to divide by the inner coefficient. The integral of \( \sec^2(4x) \) is \( \frac{\tan 4x}{4} \), not \( \tan 4x \).
- Integrating across an asymptote. From 0 to \( \pi \), plugging in gives \( \tan\pi - \tan 0 = 0 \), but that’s wrong. The integrand is positive everywhere and blows up at \( \frac{\pi}{2} \), so the integral diverges.
- Integrating tan²x as \( \frac{\tan^3 x}{3} \). Use \( \tan^2 x = \sec^2 x - 1 \) first. The power rule only works on a power of \( x \) itself, or on a power of \( u \) when \( du \) is also present. Here the derivative of \( \tan x \) is missing, so the power rule doesn’t apply.
Where it’s used
This integral powers trig substitution. With \( x = \tan\theta \), you get \( dx = \sec^2\theta\,d\theta \) and \( 1 + x^2 = \sec^2\theta \), so the integral of \( \frac{1}{1+x^2} \) collapses to \( \int d\theta = \theta \), which is \( \arctan x + C \). It’s also the key step for any integral with an even power of secant: save one \( \sec^2 x \) as \( du \), write the rest in terms of \( \tan x \), and substitute \( u = \tan x \), exactly as in Example 3.
For example, to integrate \( \sec^4 x \), split it as \( \sec^2 x\cdot\sec^2 x \) and rewrite one factor as \( 1 + \tan^2 x \). With \( u = \tan x \), the integral becomes \( \int(1 + u^2)\,du \), so
$$\int\sec^4 x\,dx = \tan x + \frac{\tan^3 x}{3} + C$$
The same approach handles \( \sec^6 x \), \( \sec^8 x \) and beyond, with longer polynomials in \( \tan x \) each time.
Try it yourself
Step-by-step solver·Exact symbolic engine
Interactive Calculus Problem Solver
Derivatives, antiderivatives, definite and improper integrals, and limits. Every answer comes with the rules used, and antiderivatives are verified by differentiating them back.
Input syntax
- Powers
x^2, rootssqrt(x),cbrt(x), absolute value|x| - Implicit multiplication works:
3x sin(2x) sin cos tan sec csc cot,asin acos atan,sinh cosh tanhe^xorexp(x);ln(x)andlog(x)are both the natural log- Constants
piande; bounds acceptinfand-inf
Practice problems
Try these before checking the answers.
- \( \int\sec^2(4x)\,dx \)
- \( \int_0^{\pi/3}\sec^2x\,dx \)
- \( \int(1 + \tan^2x)\,dx \)
- \( \int\sec^2\frac x2\,dx \)
- \( \int_0^{\pi/12}\sec^2(3x)\,dx \)
- \( \int\sec^2 x\tan x\,dx \)
Answers: (1) \( \frac{\tan 4x}{4} + C \); (2) \( \sqrt3 \); (3) \( \tan x + C \); (4) \( 2\tan\frac x2 + C \); (5) \( \frac13 \); (6) \( \frac{\tan^2 x}{2} + C \).
FAQ
Is the integral of sec²x equal to sec³x/3?
No. That would be the answer only if there were an extra factor of \( \sec x\tan x \) (the derivative of \( \sec x \)).
What is the integral of sec²x·tan x?
Let \( u = \tan x \): \( \int u\,du = \frac{\tan^2 x}{2} + C \).
What is the integral of sec²x from 0 to π/2?
It diverges. The area up to \( b \) is \( \tan b \), which grows without bound as \( b \) approaches \( \frac{\pi}{2} \).
What is the integral of csc²x?
It’s \( -\cot x + C \), because the derivative of \( \cot x \) is \( -\csc^2 x \).
Is sec²x the same as sec(x²)?
No. \( \sec^2 x \) means \( (\sec x)^2 \), which integrates to \( \tan x \). The function \( \sec(x^2) \) squares the input instead of the output, and this formula doesn’t apply to it.
Why is there no logarithm in the answer?
Logs appear when the integrand looks like \( \frac{f'}{f} \). Here \( \sec^2 x \) is already a complete derivative, the derivative of \( \tan x \), so no log is needed.
Further reading
- Derivatives of Trig Functions (Paul’s Online Math Notes) — the full derivation of the derivative of tan x that this integral reverses.
- Integrals Involving Trig Functions (Paul’s Online Math Notes) — how even powers of secant and odd powers of tangent are handled.
- Computing Indefinite Integrals (Paul’s Online Math Notes) — the table of basic antiderivatives, including sec²x.
Calculators for this topic
Keep learning
Fundamental Theorem of Calculus (Parts 1 and 2) Explained
The Fundamental Theorem of Calculus links derivatives and integrals. Both parts explained with intuition, formulas and worked examples.
Improper Integrals: How to Tell If They Converge or Diverge
Improper integrals have infinite limits or infinite integrands. Learn the limit definition, the p-integral test, comparison, and 6 worked examples.

