# 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.

Source: https://practicecalculus.com/functions/tangent-function
Updated: 2026-11-03

$$ f(x) = \tan x = \frac{\sin x}{\cos x} $$

## At a glance

- **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

## Key takeaways

- $\tan x = \frac{\sin x}{\cos x}$, the slope of the line from the origin to the point at angle $x$ on the unit circle.
- It has period $\pi$ and vertical asymptotes wherever $\cos x = 0$.
- The derivative is $\sec^2 x$ and the integral is $\ln|\sec x| + C = -\ln|\cos x| + C$.

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](/functions/sine-function) and [cosine](/functions/cosine-function), 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](/functions/arctangent) converts a slope back into an angle.

## Graph of y = tan x

```graph
title: 'Graph of y = tan x with vertical asymptotes at x = ±π/2'
caption: 'Each branch rises from $-\infty$ to $\infty$ between consecutive asymptotes. The pattern repeats every $\pi$.'
x: [-4.6, 4.6]
y: [-5, 5]
functions:
  - expr: tan(x)
    label: y = tan x
points:
  - [0, 0, '(0, 0)']
  - [0.7854, 1, '(π/4, 1)']
  - [-0.7854, -1, '(−π/4, −1)']
vertical:
  - {x: 1.5708, label: 'x = π/2'}
  - {x: -1.5708, label: 'x = −π/2'}
```

## 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](/blog/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](/rules/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](/blog/improper-integrals), and it diverges.

## How tangent connects to other topics

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

## 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$.
