# Integral of sec x: Formula, Derivation and Examples

> The integral of sec x is ln|sec x + tan x| + C. See the multiply-by-one trick step by step, the equivalent forms, a check by differentiating and examples.

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

$$ \int \sec x\,dx = \ln\lvert\sec x + \tan x\rvert + C $$

## At a glance

- **Antiderivative:** $\ln\lvert\sec x + \tan x\rvert + C$
- **Method:** Multiply by $\dfrac{\sec x + \tan x}{\sec x + \tan x}$
- **Equivalent form:** $\dfrac{1}{2}\ln\left\lvert\dfrac{1 + \sin x}{1 - \sin x}\right\rvert + C$
- **Another form:** $\ln\left\lvert\tan\left(\dfrac{x}{2} + \dfrac{\pi}{4}\right)\right\rvert + C$
- **From 0 to π/4:** $\ln\left(1 + \sqrt{2}\right) \approx 0.881$

## Key takeaways

- The integral of $\sec x$ is $\ln\lvert\sec x + \tan x\rvert + C$.
- The trick is to multiply by $\frac{\sec x + \tan x}{\sec x + \tan x}$, which makes the top the derivative of the bottom.
- Other textbooks write it as $\frac{1}{2}\ln\left\lvert\frac{1 + \sin x}{1 - \sin x}\right\rvert$ or $\ln\left\lvert\tan\left(\frac{x}{2} + \frac{\pi}{4}\right)\right\rvert$. All are equal.
- It is not $\sec x\tan x$. That is the derivative of $\sec x$.

The **integral of $\sec x$ is $\ln\lvert\sec x + \tan x\rvert + C$**. It is famous because the standard derivation relies on a trick that nobody would guess at first, and it shows up again inside harder integrals like $\int\sec^3 x\,dx$.

$$\int \sec x\,dx = \ln\lvert\sec x + \tan x\rvert + C$$

## Graph of sec x and the area under it

```graph
title: 'Area under y = sec x from 0 to π/4, with the antiderivative y = ln|sec x + tan x|'
caption: 'The shaded area is $\ln(1 + \sqrt{2}) \approx 0.881$. The dashed antiderivative passes through the origin and always increases, because $\sec x > 0$ on $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$.'
x: [-1.6, 1.6]
y: [-3, 4]
functions:
  - expr: sec(x)
    label: y = sec x
    domain: [-1.3, 1.3]
  - expr: ln(abs(sec(x) + tan(x)))
    label: y = ln|sec x + tan x| (antiderivative)
    dashed: true
    domain: [-1.5, 1.5]
shade: {expr: sec(x), from: 0, to: 0.7854}
points:
  - [0, 1, '(0, 1)']
```

## Derivation, step by step

1. Multiply by a clever form of $1$:
$$\int\sec x\,dx = \int\sec x\cdot\frac{\sec x + \tan x}{\sec x + \tan x}\,dx = \int\frac{\sec^2 x + \sec x\tan x}{\sec x + \tan x}\,dx$$
2. Look at the denominator $u = \sec x + \tan x$. Its derivative is $\sec x\tan x + \sec^2 x$, which is exactly the numerator.
3. So $du = (\sec^2 x + \sec x\tan x)\,dx$ and the integral becomes $\int\frac{du}{u}$.
4. Integrate: $\ln\lvert u\rvert + C = \ln\lvert\sec x + \tan x\rvert + C$.

Step 2 uses the [derivative of sec x](/derivatives/sec-x) and the [derivative of tan x](/derivatives/tan-x). Step 4 uses the [integral of 1/x](/integrals/1-over-x).

## Check by differentiating

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

## Equivalent forms

You may see other answers in tables or from software. They are all the same function.

Since $\sec x + \tan x = \frac{1 + \sin x}{\cos x}$, squaring gives

$$(\sec x + \tan x)^2 = \frac{(1 + \sin x)^2}{1 - \sin^2 x} = \frac{1 + \sin x}{1 - \sin x}$$

So $\ln\lvert\sec x + \tan x\rvert = \frac{1}{2}\ln\left\lvert\frac{1 + \sin x}{1 - \sin x}\right\rvert$. A half-angle identity also gives $\ln\left\lvert\tan\left(\frac{x}{2} + \frac{\pi}{4}\right)\right\rvert$. This last form is the one Mercator's map projection uses to space lines of latitude, which is how the integral was first discovered.

## Definite integrals

$$\int_0^{\pi/4}\sec x\,dx = \ln\left(\sqrt{2} + 1\right) \approx 0.881$$

$$\int_0^{\pi/3}\sec x\,dx = \ln\left(2 + \sqrt{3}\right) \approx 1.317$$

Because $\sec x$ is even, $\int_{-a}^{a}\sec x\,dx = 2\ln(\sec a + \tan a)$ for $0 < a < \frac{\pi}{2}$.

## Substitution variants

$$\int\sec(ax + b)\,dx = \frac{1}{a}\ln\lvert\sec(ax + b) + \tan(ax + b)\rvert + C$$

For example, $\int\sec(2x)\,dx = \frac{1}{2}\ln\lvert\sec 2x + \tan 2x\rvert + C$.

## Worked examples

**Example 1: rewrite first.** $\int\frac{1}{\cos x}\,dx$ is just $\int\sec x\,dx = \ln\lvert\sec x + \tan x\rvert + C$.

**Example 2: a sum.** $\int(\sec x + \sec^2 x)\,dx = \ln\lvert\sec x + \tan x\rvert + \tan x + C$.

**Example 3: inside a bigger integral.** Integration by parts turns $\int\sec^3 x\,dx$ into $\frac{1}{2}\sec x\tan x + \frac{1}{2}\int\sec x\,dx$. See the [integral of sec³ x](/integrals/sec-cubed-x).

**Example 4: from a trig substitution.** $\int\frac{dx}{\sqrt{x^2 + 1}}$ with $x = \tan\theta$ becomes $\int\sec\theta\,d\theta = \ln\lvert\sec\theta + \tan\theta\rvert + C = \ln\left(\sqrt{x^2 + 1} + x\right) + C$.

## Common mistakes

1. **Answering $\sec x\tan x$.** That is the derivative of $\sec x$. Its integral is in the [integral of sec x tan x](/integrals/sec-x-tan-x) page, going the other way.
2. **Answering $\ln\lvert\sec x\rvert$.** That is the [integral of tan x](/integrals/tan-x).
3. **Answering $\tan x$.** That comes from $\sec^2 x$, not $\sec x$.
4. **Dropping the absolute value** on intervals where $\sec x + \tan x < 0$.

The cosecant version works the same way: see the [integral of csc x](/integrals/csc-x).

## Frequently asked questions

### What is the integral of sec x?

The integral of $\sec x$ is $\ln\lvert\sec x + \tan x\rvert + C$.

### How do you prove the integral of sec x?

Multiply top and bottom by $\sec x + \tan x$. The numerator becomes $\sec^2 x + \sec x\tan x$, which is the derivative of the denominator $\sec x + \tan x$. Then $u = \sec x + \tan x$ gives $\ln\lvert u\rvert + C$.

### What is the integral of sec(2x)?

It is $\frac{1}{2}\ln\lvert\sec 2x + \tan 2x\rvert + C$.

### What is the integral of sec x from 0 to π/4?

It is $\ln\left(\sqrt{2} + 1\right) - \ln(1 + 0) = \ln\left(1 + \sqrt{2}\right) \approx 0.881$.
