# Integral of sec² x: Formula, Derivation and Examples

> The integral of sec² x is tan x + C. See why it follows from the derivative of tan x, the sec²(ax) form, related integrals like tan² x and csc² x, and examples.

Source: https://practicecalculus.com/integrals/sec-squared-x
Updated: 2026-11-06

$$ \int \sec^2 x\,dx = \tan x + C $$

## At a glance

- **Antiderivative:** $\tan x + C$
- **Also written:** $\int\dfrac{1}{\cos^2 x}\,dx = \tan x + C$
- **Linear form:** $\int\sec^2(ax + b)\,dx = \dfrac{1}{a}\tan(ax + b) + C$
- **Cosecant partner:** $\int\csc^2 x\,dx = -\cot x + C$
- **From 0 to π/4:** $1$

## Key takeaways

- The integral of $\sec^2 x$ is $\tan x + C$, because the derivative of $\tan x$ is $\sec^2 x$.
- The power rule does not apply: $\int\sec^2 x\,dx$ is not $\frac{\sec^3 x}{3}$.
- For $\sec^2(ax)$, divide by $a$.
- The identity $\tan^2 x = \sec^2 x - 1$ turns $\int\tan^2 x\,dx$ into this integral.

The **integral of $\sec^2 x$ is $\tan x + C$**. It is a direct reversal of the derivative of $\tan x$, so there is nothing to compute, only a fact to recognise.

$$\int \sec^2 x\,dx = \tan x + C$$

## Graph of sec² x and its antiderivative

```graph
title: 'Area under y = sec² x from 0 to π/4, with the antiderivative y = tan x'
caption: 'The shaded area is $\tan\frac{\pi}{4} - \tan 0 = 1$. The dashed curve $y = \tan x$ is steepest where $\sec^2 x$ is largest, near the asymptotes.'
x: [-1.6, 1.6]
y: [-3, 5]
functions:
  - expr: sec(x)^2
    label: y = sec² x
    domain: [-1.1, 1.1]
  - expr: tan(x)
    label: y = tan x (antiderivative)
    dashed: true
    domain: [-1.37, 1.37]
shade: {expr: sec(x)^2, from: 0, to: 0.7854}
points:
  - [0.7854, 1, '(π/4, 1)']
  - [0, 1, 'slope 1']
```

The smallest value of $\sec^2 x$ is $1$, at $x = 0$. That matches the slope of $\tan x$ at the origin.

## Derivation

1. Recall the [derivative of tan x](/derivatives/tan-x): $\frac{d}{dx}\tan x = \sec^2 x$.
2. So $\tan x$ is an antiderivative of $\sec^2 x$.
3. Add $C$: $\int\sec^2 x\,dx = \tan x + C$.

If you have forgotten why $\frac{d}{dx}\tan x = \sec^2 x$, apply the [quotient rule](/rules/quotient-rule) to $\frac{\sin x}{\cos x}$:

$$\frac{\cos x\cdot\cos x - \sin x\cdot(-\sin x)}{\cos^2 x} = \frac{1}{\cos^2 x} = \sec^2 x$$

## Check by differentiating

$$\frac{d}{dx}(\tan x + C) = \sec^2 x \checkmark$$

## Definite integrals

$$\int_0^{\pi/4}\sec^2 x\,dx = 1, \qquad \int_0^{\pi/3}\sec^2 x\,dx = \sqrt{3}, \qquad \int_{-\pi/4}^{\pi/4}\sec^2 x\,dx = 2$$

Any interval that reaches $\pm\frac{\pi}{2}$ gives a divergent improper integral, because $\tan x \to \infty$.

## Substitution variants

$$\int\sec^2(ax + b)\,dx = \frac{1}{a}\tan(ax + b) + C$$

**Example 1.** $\int\sec^2(5x)\,dx = \frac{1}{5}\tan(5x) + C$.

**Example 2.** $\int x\sec^2(x^2)\,dx = \frac{1}{2}\tan(x^2) + C$, with $u = x^2$.

**Example 3.** $\int\sec^2 x\,e^{\tan x}\,dx = e^{\tan x} + C$, with $u = \tan x$.

**Example 4.** $\int\frac{\sec^2 x}{\tan x}\,dx = \ln\lvert\tan x\rvert + C$, since the top is the derivative of the bottom.

## Related integrals

The six "square" and "product" trig integrals come straight from the six trig derivatives:

| Integral | Answer | Comes from |
| --- | --- | --- |
| $\int\sec^2 x\,dx$ | $\tan x + C$ | $(\tan x)' = \sec^2 x$ |
| $\int\csc^2 x\,dx$ | $-\cot x + C$ | $(\cot x)' = -\csc^2 x$ |
| $\int\sec x\tan x\,dx$ | $\sec x + C$ | $(\sec x)' = \sec x\tan x$ |
| $\int\csc x\cot x\,dx$ | $-\csc x + C$ | $(\csc x)' = -\csc x\cot x$ |
| $\int\tan^2 x\,dx$ | $\tan x - x + C$ | $\tan^2 x = \sec^2 x - 1$ |

The last row is worked out on the [integral of tan² x](/integrals/tan-squared-x) page, and the third row on the [integral of sec x tan x](/integrals/sec-x-tan-x) page.

## Worked example: two correct answers

Find $\int\sec^2 x\tan x\,dx$.

- With $u = \tan x$, $du = \sec^2 x\,dx$: the answer is $\frac{\tan^2 x}{2} + C$.
- With $u = \sec x$, $du = \sec x\tan x\,dx$: the integrand is $\sec x\cdot(\sec x\tan x)$, so the answer is $\frac{\sec^2 x}{2} + C$.

Both are right. Since $\sec^2 x = \tan^2 x + 1$, the two answers differ only by the constant $\frac{1}{2}$, which $C$ absorbs.

## Common mistakes

1. **Using the power rule: $\frac{\sec^3 x}{3}$.** The power rule needs the derivative of the inside, $\sec x\tan x$, to be present. It is not.
2. **Answering $2\sec x\cdot\sec x\tan x$.** That is the derivative of $\sec^2 x$.
3. **Confusing it with $\int\sec x\,dx$.** That one is $\ln\lvert\sec x + \tan x\rvert + C$. See the [integral of sec x](/integrals/sec-x).
4. **Forgetting to divide by $a$** in $\int\sec^2(ax)\,dx$.

Practise on [trig integral problems](/practice-problems/trig-integrals).

## Frequently asked questions

### What is the integral of sec² x?

The integral of $\sec^2 x$ is $\tan x + C$.

### What is the integral of 1/cos² x?

Since $\frac{1}{\cos^2 x} = \sec^2 x$, it is $\tan x + C$.

### What is the integral of sec²(3x)?

It is $\frac{1}{3}\tan(3x) + C$.

### What is the integral of sec² x tan x?

With $u = \tan x$ it is $\frac{\tan^2 x}{2} + C$. With $u = \sec x$ you get $\frac{\sec^2 x}{2} + C$. Both are correct, since they differ by the constant $\frac{1}{2}$.
