practicecalculus
Trigonometric functions

Tangent Function tan(x): Graph, Asymptotes, Derivative and Integral

The tangent function tan(x) = sin(x)/cos(x): its graph, vertical asymptotes, period π, derivative sec²(x), integral ln|sec x| + C and examples.

Trigonometric functions Updated 3 min read

At a glance

f(x) = \tan x = \frac{\sin x}{\cos x}
Domain
x \ne \frac{\pi}{2} + k\pi
Range
(-\infty, \infty)
Derivative
\sec^2 x
Integral
\ln\lvert\sec x\rvert + C
Period
\pi
Asymptotes
x = \frac{\pi}{2} + k\pi, k an integer
On this page
  1. Definition of tan x
  2. Graph of y = tan x
  3. Key values of tangent
  4. Properties of the tangent function
  5. Derivative of tan x
  6. Integral of tan x
  7. Worked examples
  8. Common mistakes
  9. How tangent connects to other topics

The tangent function is the ratio \tan x = \frac{\sin x}{\cos x}. Geometrically, it is the slope of the line from the origin to the point at angle x on the unit circle. Unlike sine and cosine, it is unbounded and has a vertical asymptote every time cosine hits zero.

Definition of tan x

\tan x = \frac{\sin x}{\cos x}, \qquad \cos x \ne 0

In a right triangle this is \frac{\text{opposite}}{\text{adjacent}}. Because the line through the origin at angle x has slope \tan x, tangent is how you convert an angle into a slope, and arctangent converts a slope back into an angle.

Graph of y = tan x

Graph of y = tan x with vertical asymptotes at x = ±π/2
Each branch rises from -\infty to \infty between consecutive asymptotes. The pattern repeats every \pi.

Key values of tangent

x -\frac{\pi}{3} -\frac{\pi}{4} 0 \frac{\pi}{6} \frac{\pi}{4} \frac{\pi}{3} \frac{\pi}{2}
\tan x -\sqrt{3} -1 0 \frac{\sqrt{3}}{3} 1 \sqrt{3} undefined

Properties of the tangent function

  • Domain. All real numbers except x = \frac{\pi}{2} + k\pi.
  • Range. All real numbers.
  • Period. \tan(x + \pi) = \tan x, so the period is \pi, not 2\pi.
  • Zeros. \tan x = 0 at x = k\pi, the same zeros as sine.
  • Odd symmetry. \tan(-x) = -\tan x.
  • Always increasing. On each branch the slope \sec^2 x is at least 1, so the graph never levels off.
  • One-sided limits. \lim_{x \to \pi/2^-}\tan x = \infty and \lim_{x \to \pi/2^+}\tan x = -\infty. See limits at infinity for more on asymptotes.
  • Identity. 1 + \tan^2 x = \sec^2 x, found by dividing \sin^2 x + \cos^2 x = 1 by \cos^2 x.

Derivative of tan x

Apply the quotient rule to \frac{\sin x}{\cos x}:

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

At x = 0 the slope is \sec^2 0 = 1, which matches the graph crossing the origin at a 45 degree angle.

Integral of tan x

Write \tan x = \frac{\sin x}{\cos x} and let u = \cos x, so du = -\sin x\,dx:

\int \tan x\,dx = -\int \frac{du}{u} = -\ln|\cos x| + C = \ln|\sec x| + C

The two forms are equal because -\ln|\cos x| = \ln\frac{1}{|\cos x|}.

Worked examples

Example 1: chain rule. \frac{d}{dx}\tan(3x) = 3\sec^2(3x).

Example 2: a power of tangent. \frac{d}{dx}\tan^2 x = 2\tan x\sec^2 x.

Example 3: an integral using the identity. Since \tan^2 x = \sec^2 x - 1,

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

Example 4: a definite integral. \int_0^{\pi/4}\sec^2 x\,dx = \tan\frac{\pi}{4} - \tan 0 = 1.

Common mistakes

  1. Thinking the period is 2\pi. Tangent repeats every \pi, because \sin and \cos both change sign after a half turn and the signs cancel.
  2. Writing \int\tan x\,dx = \sec^2 x. That is backward: \sec^2 x is the derivative. The integral needs a logarithm.
  3. Dropping the absolute value. \ln|\cos x| needs the bars because \cos x is negative on parts of the domain.
  4. Ignoring the asymptotes. You cannot integrate \tan x across x = \frac{\pi}{2} with the Fundamental Theorem; that would be an improper integral, and it diverges.

How tangent connects to other topics

Tangent pairs with secant in derivatives and integrals, so its siblings on reciprocal trig functions are worth learning together. Its inverse, arctangent, is the antiderivative of \frac{1}{1+x^2}, and the substitution x = \tan\theta is a workhorse of trig substitution. For all six trig derivatives in one place, read derivatives of trig functions.

Practice it now

Sine, cosine and tangent

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

Frequently asked questions

What is the derivative of tan x?

The derivative of \tan x is \sec^2 x = \frac{1}{\cos^2 x}. It comes from the quotient rule applied to \frac{\sin x}{\cos x}.

What is the integral of tan x?

The integral is \int \tan x\,dx = -\ln|\cos x| + C, which is the same as \ln|\sec x| + C. Write \tan x = \frac{\sin x}{\cos x} and substitute u = \cos x.

What is the period of tan x?

The period of \tan x is \pi, half the period of sine and cosine. The function \tan(bx) has period \frac{\pi}{|b|}.

Where does tan x have vertical asymptotes?

At every x where \cos x = 0, that is x = \frac{\pi}{2} + k\pi for any integer k.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.