∫Yoboa Math
Home / Integral of tan(x)
Integral Reference

Integral of tan(x)

Step-by-step derivation, definite integral examples, and common variants.

Unlike sine and cosine, the antiderivative of tangent is not another trig function — it requires u-substitution and produces a logarithm.

Result

\[ \int \tan(x)\,dx = -\ln|\cos(x)| + C \]

Derivation

Write \(\tan(x) = \dfrac{\sin(x)}{\cos(x)}\) and substitute \(u = \cos(x)\), \(du = -\sin(x)\,dx\):

\[ \int \tan(x)\,dx = \int \frac{\sin(x)}{\cos(x)}\,dx = -\int \frac{du}{u} = -\ln|u| + C = -\ln|\cos(x)| + C \]

This can also be written as \(\ln|\sec(x)| + C\) since \(-\ln|\cos x| = \ln|1/\cos x| = \ln|\sec x|\). Both forms are correct.

Verification: \(\dfrac{d}{dx}[-\ln|\cos(x)|] = \dfrac{\sin(x)}{\cos(x)} = \tan(x)\) ✓

Definite integral examples

\(\int_0^{\pi/4} \tan(x)\,dx\)

\[ \Big[-\ln|\cos(x)|\Big]_0^{\pi/4} = -\ln\!\Bigl(\frac{\sqrt{2}}{2}\Bigr) + \ln(1) = \tfrac{1}{2}\ln 2 \approx 0.347 \]

\(\int_0^{\pi/6} \tan(x)\,dx\)

\[ \Big[-\ln|\cos(x)|\Big]_0^{\pi/6} = -\ln\!\Bigl(\frac{\sqrt{3}}{2}\Bigr) = \tfrac{1}{2}\ln\!\Bigl(\tfrac{4}{3}\Bigr) \approx 0.144 \]

Common variants

IntegralAntiderivativeNotes
\(\int \tan(ax)\,dx\)\(-\dfrac{\ln|\cos(ax)|}{a} + C\)Chain rule.
\(\int \tan^2(x)\,dx\)\(\tan(x) - x + C\)Use the identity \(\tan^2 x = \sec^2 x - 1\).

Try it in the calculator

Paste any variant below into the step-by-step integral calculator for a full worked solution and graph.

Open in calculator →

Related guides