Integrals

Integral of sec(x): ln|sec x + tan x| + C, Step by Step

Integral of sec(x): ln|sec x + tan x| + C, Step by Step

The integral of sec x is ln|sec x + tan x| + C. Equivalently, it is -ln|sec x – tan x| + C. You solve it by multiplying the numerator and denominator by (sec x + tan x). This creates a derivative-over-function fraction. Therefore, it integrates directly using u-substitution.

Basic trigonometric integrals, like sines and cosines, use straightforward antiderivative rules. However, the secant integral requires a specific algebraic setup. This guide walks you through three distinct derivations. It explains why the absolute value sign is mandatory. Furthermore, it works through seven representative examples. You will also learn common mistakes to avoid on exams.

Why does multiplying by sec x + tan x work?

The standard integral rule for logarithmic derivatives is useful here. It states that if an integrand’s numerator is the exact derivative of its denominator, the result is a natural logarithm.

$$\int \frac{g'(x)}{g(x)} \, dx = \ln|g(x)| + C$$

You can see why sec x fits this rule. First, test the function \(g(x) = \sec x + \tan x\). Next, take its derivative. This gives:

$$g'(x) = \sec x \tan x + \sec^2 x = \sec x (\sec x + \tan x) = \sec x \cdot g(x)$$

Dividing both sides by \(g(x)\) yields:

$$\frac{g'(x)}{g(x)} = \sec x$$

This identity proves that sec x is naturally the log-derivative of \((\sec x + \tan x)\). So, the famous trick of multiplying and dividing by \((\sec x + \tan x)\) simply writes this identity. It uses an explicit fraction form. This allows standard substitution to apply.

Historically, mathematicians knew the antiderivative of secant produced logarithmic values. They learned this from nautical map projections. This was long before the short algebraic trick was published. In 1668, James Gregory published the first formal proof for the integral of sec x. He used partial fractions. However, the (sec x + tan x) trick became preferred in calculus instruction. It collapses a multi-step algebraic derivation. As a result, it becomes a single substitution line.

Graphically, on \([0, \frac{\pi}{2})\), \(\sec x\) starts at \(1\) when \(x = 0\). It approaches infinity as \(x\) nears \(\frac{\pi}{2}\). The continuous area under the curve increases rapidly toward the vertical asymptote. Similarly, the integral of sec x, \(\ln(\sec x + \tan x)\), mirrors this behavior. It equals \(0\) at \(x = 0\). Also, it grows infinitely as the argument inside the logarithm approaches infinity.

Derivation 1: The standard u-substitution method

This is the fastest proof. Also, it is the most common proof required in calculus courses.

  1. Multiply top and bottom: Multiply \(\sec x\) by \(\frac{\sec x + \tan x}{\sec x + \tan x}\):

    $$\int \sec x \, dx = \int \frac{\sec x (\sec x + \tan x)}{\sec x + \tan x} \, dx$$

  2. Distribute the numerator: Expand the top expression. This reveals the derivative terms.

    $$\int \frac{\sec^2 x + \sec x \tan x}{\sec x + \tan x} \, dx$$

  3. Set up u-substitution: Let \(u = \sec x + \tan x\). Differentiate \(u\) with respect to \(x\) using u-substitution rules:

    $$du = (\sec x \tan x + \sec^2 x) \, dx$$

  4. Substitute into the integral: The entire numerator and \(dx\) combine to form \(du\):

    $$\int \frac{du}{u} = \ln|u| + C$$

  5. Substitute back for x: Replace \(u\) with \((\sec x + \tan x)\):

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

This method takes only a few lines. However, its main drawback is that you must remember the exact factor \((\sec x + \tan x)\) ahead of time. If you forget this factor during an exam, derivations using partial fractions or half-angles provide reliable mathematical alternatives.

Derivation 2: Using cosine and partial fractions

Perhaps you prefer not to memorize the \((\sec x + \tan x)\) trick. However, you can derive the result algebraically. Rewrite secant in terms of cosine.

Integral of sec x: Bored young woman sitting at desk in front of math formulas
  1. Convert to cosine: First, write \(\sec x = \frac{1}{\cos x}\). Next, multiply the top and bottom by \(\cos x\). This gives you:

    $$\int \sec x \, dx = \int \frac{\cos x}{\cos^2 x} \, dx = \int \frac{\cos x}{1 - \sin^2 x} \, dx$$

  2. Substitute u = sin x: Note that \(du = \cos x \, dx\):

    $$\int \frac{du}{1 - u^2}$$

  3. Apply partial fraction decomposition for the integral of sec x: You can split the integrand into linear factors. Use partial fractions to do this:

    $$\frac{1}{1 - u^2} = \frac{1}{(1 - u)(1 + u)} = \frac{1/2}{1 - u} + \frac{1/2}{1 + u}$$

    To solve for these constants directly, write \(\frac{1}{(1-u)(1+u)} = \frac{A}{1-u} + \frac{B}{1+u}\). Next, multiply through by \((1-u)(1+u)\). This yields \(1 = A(1+u) + B(1-u)\). Then, set \(u = 1\). This gives \(1 = 2A\), so \(A = 1/2\). Also, set \(u = -1\). This gives \(1 = 2B\), so \(B = 1/2\).

  4. Integrate each term:

    $$\int \left( \frac{1/2}{1 + u} + \frac{1/2}{1 - u} \right) du = \frac{1}{2} \ln|1 + u| - \frac{1}{2} \ln|1 - u| + C = \frac{1}{2} \ln\left|\frac{1 + u}{1 - u}\right| + C$$

  5. Substitute u = sin x:

    $$\frac{1}{2} \ln\left|\frac{1 + \sin x}{1 - \sin x}\right| + C$$

To show that this matches \(\ln|\sec x + \tan x|\), multiply the interior fraction by \(\frac{1 + \sin x}{1 + \sin x}\):

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

Bringing the exponent 2 outside the logarithm cancels the factor of \(\frac{1}{2}\), confirming that both antiderivatives are identical.

Derivation 3: The half-angle tangent substitution

Historical navigation tables derived this formula using the half-angle substitution \(t = \tan(\frac{x}{2})\), known as the Weierstrass substitution.

A hand writing geometry and math formulas in a spiral notebook

Using standard half-angle identities:

$$dx = \frac{2}{1 + t^2} \, dt, \quad \sec x = \frac{1 + t^2}{1 - t^2}$$

Substituting these into the integral gives:

$$\int \sec x \, dx = \int \left(\frac{1 + t^2}{1 - t^2}\right) \left(\frac{2}{1 + t^2}\right) dt = \int \frac{2}{1 - t^2} \, dt = \ln\left|\frac{1 + t}{1 - t}\right| + C$$

Replacing \(t\) with \(\tan(\frac{x}{2})\) gives the historical form:

$$\int \sec x \, dx = \ln\left|\frac{1 + \tan(x/2)}{1 - \tan(x/2)}\right| + C = \ln\left|\tan\left(\frac{x}{2} + \frac{\pi}{4}\right)\right| + C$$

This half-angle identity is very useful. For example, you can use it in geographic computing. Also, it helps with spherical trigonometry. It calculates distances along lines of constant compass bearing.

Why are absolute value bars required?

The natural logarithm function \(\ln(y)\) is defined only when its argument \(y\) is strictly positive ($y > 0$). However, the trigonometric expression \((\sec x + \tan x)\) can take negative values depending on the quadrant of \(x\). For example, in the third quadrant when \(x = \frac{7\pi}{6}\):

$$\sec\left(\frac{7\pi}{6}\right) = -\frac{2}{\sqrt{3}}, \quad \tan\left(\frac{7\pi}{6}\right) = \frac{1}{\sqrt{3}}$$

$$\sec\left(\frac{7\pi}{6}\right) + \tan\left(\frac{7\pi}{6}\right) = -\frac{1}{\sqrt{3}} < 0$$

You cannot evaluate \(\ln(-\frac{1}{\sqrt{3}})\) in real numbers. It would be undefined without absolute value bars. However, absolute value signs maintain a real-valued output. They work across all valid domains where secant is defined.

Specifically, the domain behavior across different quadrants breaks down as follows:

  • Quadrant I (\(0 < x < \frac{\pi}{2}\)): Both \(\sec x > 0\) and \(\tan x > 0\), so \(\sec x + \tan x > 0\). Absolute value bars are optional here.
  • Quadrant II (\(\frac{\pi}{2} < x < \pi\)): Both \(\sec x < 0\) and \(\tan x < 0\). As a result, \(\sec x + \tan x < 0\). Therefore, you must strictly use absolute value bars.
  • Quadrant III (\(\pi < x < \frac{3\pi}{2}\)): Here \(\sec x 0\). Because \(|\sec x| > |\tan x|\) in this region, the sum remains negative, making absolute values mandatory.
  • Quadrant IV (\(\frac{3\pi}{2} < x < 2\pi\)): Here \(\sec x > 0\). Also, \(\tan x |\tan x|\). The sum is positive. Therefore, absolute values are optional.

Equivalent forms of the integral

Depending on the textbook or software tool used, you may encounter three equivalent expressions for the antiderivative of \(\sec x\):

A person holding a pen writing math equations on paper
  • Standard form: \(\ln|\sec x + \tan x| + C\)
  • Negative conjugate form: \(-\ln|\sec x - \tan x| + C\)
  • Half-angle form: \(\ln\left|\tan\left(\frac{x}{2} + \frac{\pi}{4}\right)\right| + C\)

You can see why the standard form equals \(-\ln|\sec x - \tan x|\). To do this, multiply \((\sec x + \tan x)\) by its conjugate fraction:

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

Applying the logarithm exponent rule \(\ln(w^{-1}) = -\ln(w)\) yields \(-\ln|\sec x - \tan x| + C\).

Each form serves specific practical purposes:

  • Standard form: Best suited for definite integral evaluations and standard calculus exam solutions.
  • Negative conjugate form: Ideal when simplifying expressions in differential equations where subtraction inside logarithms simplifies term cancellation.
  • Half-angle form: Preferred in computer algebra systems, spherical geometry, and Mercator mapping calculations.

How to check the solution by differentiation

You can verify any antiderivative by taking its derivative to recover the original integrand. Apply the chain rule to \(y = \ln|\sec x + \tan x|\):

Colorful wooden math cubes with numbers and multiplication facts

$$\frac{dy}{dx} = \frac{1}{\sec x + \tan x} \cdot \frac{d}{dx}(\sec x + \tan x)$$

Substitute the derivatives of sec x and tan x:

$$\frac{dy}{dx} = \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$$

The derivative simplifies directly to \(\sec x\), proving the result is correct.

Step-by-step worked examples

Example 1 (Basic definite integral). Evaluate \(\int_0^{\pi/4} \sec x \, dx\).

Evaluate the antiderivative at the upper bound \(\frac{\pi}{4}\) and lower bound \(0\):

$$\sec\left(\frac{\pi}{4}\right) = \sqrt{2}, \quad \tan\left(\frac{\pi}{4}\right) = 1$$

$$\sec(0) = 1, \quad \tan(0) = 0$$

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

Example 2 (Linear coefficient inside). Evaluate \(\int \sec(4x) \, dx\).

Let \(u = 4x\), so \(du = 4 \, dx\) and \(dx = \frac{du}{4}\):

$$\int \sec(4x) \, dx = \frac{1}{4} \int \sec u \, du = \frac{1}{4} \ln|\sec 4x + \tan 4x| + C$$

Example 3 (Symmetric interval). Evaluate \(\int_{-\pi/4}^{\pi/4} \sec x \, dx\).

Because \(\sec(-x) = \sec x\), secant is an even function. For even functions integrated over symmetric limits $[-a, a]$, the integral equals twice the integral over $[0, a]$:

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

Example 4 (Exact value evaluation). Evaluate \(\int_0^{\pi/6} \sec x \, dx\).

At \(x = \frac{\pi}{6}\), \(\sec x = \frac{2}{\sqrt{3}}\) and \(\tan x = \frac{1}{\sqrt{3}}\). Summing these gives \(\frac{3}{\sqrt{3}} = \sqrt{3}\):

$$\int_0^{\pi/6} \sec x \, dx = \ln\left|\sqrt{3}\right| - \ln|1| = \ln\left(\sqrt{3}\right) = \frac{1}{2} \ln 3 \approx 0.5493$$

Example 5 (Substitution before secant). Evaluate \(\int x \sec(x^2) \, dx\).

Integrating secant with u-substitution

Let \(u = x^2\), so \(du = 2x \, dx\) and \(x \, dx = \frac{du}{2}\):

$$\int x \sec(x^2) \, dx = \frac{1}{2} \int \sec u \, du = \frac{1}{2} \ln\left|\sec(x^2) + \tan(x^2)\right| + C$$

Example 6 (Splitting a trigonometric fraction). Evaluate \(\int \frac{1 + \sin x}{\cos x} \, dx\).

Separate the fraction into two distinct terms:

$$\int \left( \frac{1}{\cos x} + \frac{\sin x}{\cos x} \right) dx = \int \sec x \, dx + \int \tan x \, dx$$

Integrate each term individually:

$$\int \frac{1 + \sin x}{\cos x} \, dx = \ln|\sec x + \tan x| + \ln|\sec x| + C$$

Example 7 (Exam classic: sec³ x). Evaluate \(\int \sec^3 x \, dx\).

Apply integration by parts using integration by parts with \(u = \sec x\) and \(dv = \sec^2 x \, dx\). Thus \(du = \sec x \tan x \, dx\) and \(v = \tan x\). Let \(I = \int \sec^3 x \, dx\):

$$I = \sec x \tan x - \int \sec x \tan^2 x \, dx$$

Replace \(\tan^2 x\) with \((\sec^2 x - 1)\):

$$I = \sec x \tan x - \int \sec x (\sec^2 x - 1) \, dx = \sec x \tan x - I + \int \sec x \, dx$$

Add \(I\) to both sides and divide by 2:

$$2I = \sec x \tan x + \ln|\sec x + \tan x|$$

$$\int \sec^3 x \, dx = \frac{1}{2} \left( \sec x \tan x + \ln|\sec x + \tan x| \right) + C$$

You can check your answers using an online integral calculator.

The cosecant formula and companion results

You can derive the integral of cosecant. Also, use the same technique. Multiply it by \((\csc x + \cot x)\).

An open book and notebook with a pen on a table

$$\int \csc x \, dx = -\ln|\csc x + \cot x| + C = \ln|\csc x - \cot x| + C$$

The table below summarizes essential secant and cosecant integrals for quick comparison:

Integral Result
\(\int \sec x \, dx\) \(\ln|\sec x + \tan x| + C\)
\(\int \csc x \, dx\) \(-\ln|\csc x + \cot x| + C\)
\(\int \sec x \tan x \, dx\) \(\sec x + C\)
\(\int \sec^2 x \, dx\) \(\tan x + C\)
\(\int \sec(ax) \, dx\) \(\frac{1}{a} \ln|\sec ax + \tan ax| + C\)

A general strategy for powers of secant and tangent

The integral of sec x provides a foundation. It supports broader trigonometric integrals. For example, it helps with products of powers \(\int \sec^m x \tan^n x \, dx\).

  • Even power of secant (\(m\) is even): First, save a factor of \(\sec^2 x\) for \(du\). Next, rewrite remaining secants. Use \(\sec^2 x = 1 + \tan^2 x\). Then, substitute \(u = \tan x\).
  • Odd power of tangent (\(n\) is odd): First, save a factor of \(\sec x \tan x\) for \(du\). Then, rewrite remaining tangents. Use \(\tan^2 x = \sec^2 x - 1\). Finally, substitute \(u = \sec x\).
  • Odd power of secant alone (\(m\) is odd, \(n = 0\)): Use integration by parts repeatedly. Every reduction step eventually reduces down to \(\int \sec x \, dx\).

Understanding this structure helps you. You can quickly identify integral needs. For example, this includes simple \(u\)-substitution, identity rewriting, or integration by parts.

Common mistakes to avoid

  1. Confusing the integral with the derivative: Writing \(\int \sec x \, dx = \sec x \tan x + C\). However, the expression \(\sec x \tan x\) is the derivative of secant, not its integral.
  2. Omitting tangent inside the logarithm: Writing \(\ln|\sec x| + C\). That expression is the integral of integral of tan x.
  3. Treating 1/cos x like 1/x: Assuming \(\int \frac{1}{\cos x} \, dx = \ln|\cos x| + C\). The log rule requires \(g'(x)\) in the numerator, but \(\frac{d}{dx}(\cos x) = -\sin x \neq 1\).
  4. Forgetting the 1/a chain-rule factor: You might omit \(\frac{1}{a}\) when you evaluate \(\sec(ax)\). For instance, do not forget the \(\frac{1}{3}\) factor in \(\int \sec(3x) \, dx\).
  5. Integrating across vertical asymptotes: You cannot evaluate definite integrals across \(x = \frac{\pi}{2}\). This also applies to odd multiples of \(\frac{\pi}{2}\). Secant is undefined at these values. As a result, integrals like \(\int_0^{\pi} \sec x \, dx\) are divergent.

Real-world applications

Mercator map projection: You can compute the vertical displacement \(y\) of a point. This point is at latitude \(\varphi\) from the equator. On standard nautical maps, you compute it using the integral of secant:

A hand measuring architectural blueprints on a backlit surface

$$y = R \int_0^{\varphi} \sec x \, dx = R \ln\left|\sec \varphi + \tan \varphi\right|$$

Because the secant integral inflates distances near the poles, maps using this projection stretch high-latitude regions like Greenland and Antarctica.

Arc length calculations: You can calculate the length of the logarithmic cosine curve \(y = \ln(\cos x)\). This calculation runs from \(x = 0\) to \(x = \frac{\pi}{4}\). It uses the standard arc length formula \(L = \int \sqrt{1 + (y')^2} \, dx\). Because \(y' = -\tan x\), the integrand becomes \(\sqrt{1 + \tan^2 x} = \sec x\). So, this yields \(L = \ln(1 + \sqrt{2})\).

Trigonometric substitution: Integrals containing square roots often use trig substitution. These forms include \(\sqrt{a^2 + x^2}\) or \(\sqrt{x^2 - a^2}\). For example, you can use trig substitution with \(x = a \tan \theta\). Transforming these expressions frequently produces \(\int \sec \theta \, d\theta\).

Try it yourself

Step-by-step solverExact 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.

Try:
Input syntax
  • Powers x^2, roots sqrt(x), cbrt(x), absolute value |x|
  • Implicit multiplication works: 3x sin(2x)
  • sin cos tan sec csc cot, asin acos atan, sinh cosh tanh
  • e^x or exp(x); ln(x) is the natural log. In this solver log(x) also means the natural log (the usual calculus convention); type log10(x) for base 10
  • Constants pi and e; bounds accept inf and -inf
Enter a function and press Solve to see a full worked solution.

Practice problems

  1. \(\int \sec(3x) \, dx\)
  2. \(\int_0^{\pi/3} \sec x \, dx\)
  3. \(\int \sec x (\sec x + \tan x) \, dx\)
  4. \(\int \sec\left(\frac{x}{3}\right) \, dx\)
  5. \(\int_0^{\pi/6} \sec(2x) \, dx\)
  6. \(\int \frac{dx}{\sqrt{1 + x^2}}\)

Solutions and step-by-step answers:

A woman holding a notebook and pencil looking thoughtful

1. \(\frac{1}{3} \ln|\sec 3x + \tan 3x| + C\) (Use substitution \(u = 3x\)).

2. \(\ln\left(2 + \sqrt{3}\right) \approx 1.3170\) (At \(\frac{\pi}{3}\), \(\sec x = 2\) and \(\tan x = \sqrt{3}\)).

3. \(\tan x + \sec x + C\) First, expand this to \(\int \sec^2 x \, dx + \int \sec x \tan x \, dx\). Then, see integral of sec²x.

4. \(3 \ln\left|\sec\left(\frac{x}{3}\right) + \tan\left(\frac{x}{3}\right)\right| + C\) (Use substitution \(u = \frac{x}{3}\), so \(dx = 3 \, du\)).

5. \(\frac{1}{2} \ln\left(2 + \sqrt{3}\right) \approx 0.6585\) (Substitute \(u = 2x\); upper limit becomes \(\frac{\pi}{3}\)).

6. \(\ln\left|x + \sqrt{1 + x^2}\right| + C\) Let \(x = \tan \theta\). Then \(dx = \sec^2 \theta \, d\theta\). This simplifies the integrand to \(\int \sec \theta \, d\theta\).

Frequently asked questions

Is the integral of sec x equal to sec x tan x?

No. The expression \(\sec x \tan x\) is the derivative of \(\sec x\), not its antiderivative. The antiderivative of \(\sec x\) is \(\ln|\sec x + \tan x| + C\). See derivative of sec x.

How do you know to multiply by sec x + tan x?

You are not expected to invent this choice on your own. It works because the derivative of \((\sec x + \tan x)\) is \(\sec x(\sec x + \tan x)\). This creates a \(g'(x)/g(x)\) structure. As a result, it directly integrates to a natural logarithm.

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

The definite integral diverges to infinity. As \(x\) approaches \(\frac{\pi}{2}\) from the left, both \(\sec x\) and \(\tan x\) tend to infinity. As a result, the natural logarithm blows up.

What is the integral of sec³ x?

You can evaluate the antiderivative as \(\frac{1}{2} \left( \sec x \tan x + \ln|\sec x + \tan x| \right) + C\). You use integration by parts. Also, \(u = \sec x\) and \(dv = \sec^2 x \, dx\).

What is the integral of csc x?

The result is \(-\ln|\csc x + \cot x| + C\). Alternatively, you can write it as \(\ln|\csc x - \cot x| + C\). You derive this by multiplying the top and bottom by \((\csc x + \cot x)\).

Further reading

Calculators for this topic

Get new calculus guides by email

Free worked examples and new calculators, at most once a day. Unsubscribe with one click.

Leave a comment

Your email address will not be published. Required fields are marked *