The derivative of tan(x) with respect to x is sec²(x). Also, you can write it in the equivalent forms 1 + tan²(x) or 1/cos²(x). First, you can derive this standard trigonometric derivative by applying the quotient rule to sin(x)/cos(x). Alternatively, you can evaluate the limit definition of the derivative.
In addition, 1 + tan²(x) is an equivalent form that is often handy in calculus problems. This is because the Pythagorean identity gives sec²(x) = 1 + tan²(x). Below, you will find step-by-step proofs using the quotient rule and first principles. Next, you will find geometric intuition, chain rule examples, higher derivatives, and common test mistakes.
Why does the derivative of tan(x) equal sec²(x)?
First, examine the behavior of the tangent function across its domain. This will help you understand why the derivative of tan(x) is sec²(x).

Near the origin (x = 0), tan(x) stays close to x. Also, the curve crosses the y-axis at 45 degrees, which matches a slope of 1. Next, evaluating the derivative formula at x = 0 gives sec²(0) = 1/cos²(0) = 1, matching the initial slope.
As x moves from 0 toward π/2 (90 degrees), sin(x) approaches 1 while cos(x) shrinks toward 0. Because tan(x) = sin(x)/cos(x), dividing near 1 by near zero pushes tan(x) toward infinity. Next, the derivative 1/cos²(x) squarifies this shrinking denominator. As a result, it reflects how the curve gets infinitely steep near x = π/2.
Using the identity sec²(x) = 1 + tan²(x) provides another angle on slope behavior. So, the slope of the tangent graph depends entirely on its vertical height y. At y = 0, the slope is 1 + 0² = 1. Next, at height y = 1, the slope increases to 1 + 1² = 2. Then at height y = 3, the slope jumps to 1 + 3² = 10. The further tan(x) travels from the x-axis, the faster it rises.
Proof using the quotient rule
First, the most straightforward proof uses the identity tan(x) = sin(x)/cos(x) alongside the quotient rule. The quotient rule states that for f(x) = u(x)/v(x), the derivative is:

$$\frac{d}{dx}\left(\frac{u}{v}\right) = \frac{u'v - uv'}{v^2}$$
Set u(x) = sin(x) and v(x) = cos(x). Also, their respective derivatives are u'(x) = cos(x) and v'(x) = -sin(x). Substituting these into the formula gives:
$$\frac{d}{dx}\left(\frac{\sin x}{\cos x}\right) = \frac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x}$$
Multiplying out the terms in the numerator produces:
$$\frac{d}{dx}\tan x = \frac{\cos^2 x + \sin^2 x}{\cos^2 x}$$
Applying the Pythagorean identity sin²(x) + cos²(x) = 1 simplifies the numerator to 1:
$$\frac{d}{dx}\tan x = \frac{1}{\cos^2 x} = \sec^2 x$$
If you separate the fraction prior to combining terms, you obtain the second form directly:
$$\frac{\cos^2 x + \sin^2 x}{\cos^2 x} = \frac{\cos^2 x}{\cos^2 x} + \frac{\sin^2 x}{\cos^2 x} = 1 + \tan^2 x$$
Proof from the limit definition
You can also derive the derivative directly from the limit definition of the derivative (first principles):
$$\frac{d}{dx}\tan x = \lim_{h \to 0} \frac{\tan(x + h) - \tan x}{h}$$
First, use the trigonometric identity tan(A) – tan(B) = sin(A – B) / (cos A cos B). This evaluates the difference in the numerator. Next, setting A = x + h and B = x gives:
$$\tan(x + h) - \tan x = \frac{\sin(x + h - x)}{\cos(x + h)\cos x} = \frac{\sin h}{\cos(x + h)\cos x}$$
Substitute this back into the limit expression:
$$\lim_{h \to 0} \frac{1}{h} \cdot \frac{\sin h}{\cos(x + h)\cos x} = \lim_{h \to 0} \left( \frac{\sin h}{h} \cdot \frac{1}{\cos(x + h)\cos x} \right)$$
Apply limit laws to separate the expression into two independent limits:
$$\left( \lim_{h \to 0} \frac{\sin h}{h} \right) \cdot \left( \lim_{h \to 0} \frac{1}{\cos(x + h)\cos x} \right)$$
The first term is the fundamental trigonometric limit limit of sin x / x, which equals 1 as h approaches 0. For the second term, substitute h = 0 directly into the continuous cosine function to get 1 / (cos x · cos x) = 1/cos²(x). Multiplying the two results yields:
$$\frac{d}{dx}\tan x = 1 \cdot \frac{1}{\cos^2 x} = \sec^2 x$$
Domain, continuity, and slope limits
The tangent function is continuous and differentiable on all real numbers except where cos(x) = 0. These excluded points occur at odd multiples of π/2:

$$x \neq \frac{\pi}{2} + k\pi \quad \text{for any integer } k$$
At these exact values, tan(x) has vertical asymptotes. Consequently, neither tan(x) nor its derivative sec²(x) exists at x = π/2 + kπ.
On every open interval between vertical asymptotes—such as (-π/2, π/2)—sec²(x) stays positive because sec²(x) = 1/cos²(x) ≥ 1. As a result, this creates three key properties:
- The slope is never negative: tan(x) is an increasing function on every open interval in its domain.
- Minimum slope is 1: The smallest possible value for sec²(x) occurs when cos(x) = 1 or -1, where slope equals 1.
- Infinite steepness near asymptotes: As x approaches π/2 from the left, sec²(x) approaches +∞, meaning the graph turns almost vertical.
Differentiating tan(g(x)) using the chain rule
When the input to tangent is a composite function g(x) rather than x, apply the chain rule. So the general derivative formula is:

$$\frac{d}{dx}\tan\big(g(x)\big) = \sec^2\big(g(x)\big) \cdot g'(x)$$
Always leave the inner function g(x) unchanged inside secant squared. Next, multiply the result by the derivative g'(x).
Worked examples with the chain rule
Example 1: Inner linear coefficient
Find the derivative of f(x) = tan(3x). Here, g(x) = 3x and g'(x) = 3.
$$\frac{d}{dx}\tan(3x) = \sec^2(3x) \cdot 3 = 3\sec^2(3x)$$
Example 2: Inner polynomial vs. outer power
Contrast the derivative of tan(x²) with tan²(x):
- For f(x) = tan(x²), the inner function is x². Applying the chain rule yields:
$$\frac{d}{dx}\tan(x^2) = \sec^2(x^2) \cdot (2x) = 2xsec^2(x^2)$$ - For f(x) = tan²(x) = (tan x)², the outer function is the square power. In addition, the inner function is tan(x). So, applying the power rule and chain rule yields:
$$\frac{d}{dx}(\tan x)^2 = 2\tan x \cdot \left(\frac{d}{dx}\tan x\right) = 2\tan x \sec^2 x$$
Example 3: Three-layer composition
Find the derivative of f(x) = tan³(2x) = [tan(2x)]³.
Work from the outermost layer inward:
- Differentiate the cube power: 3[tan(2x)]²
- Multiply by the derivative of tangent: sec²(2x)
- Multiply by the derivative of 2x: 2
Compound result:
$$\frac{d}{dx}\tan^3(2x) = 3\tan^2(2x) \cdot \sec^2(2x) \cdot 2 = 6\tan^2(2x)\sec^2(2x)$$
Combining product and tangent rules
Example 4: Combining product rule and tangent
Find the derivative of f(x) = x · tan(x). Use the product rule (u’v + uv’) where u = x and v = tan(x):
$$\frac{d}{dx}(x\tan x) = (1)\cdot \tan x + x \cdot \sec^2 x = \tan x + xsec^2 x$$
Example 5: Logarithm of tangent
Find the derivative of f(x) = ln(tan x) on the interval (0, π/2). The derivative of ln(u) is u’/u:
$$\frac{d}{dx}\ln(\tan x) = \frac{\sec^2 x}{\tan x} = \frac{\frac{1}{\cos^2 x}}{\frac{\sin x}{\cos x}} = \frac{1}{\sin x \cos x}$$
Using the double-angle identity sin(2x) = 2 sin(x) cos(x), this simplifies to:
$$\frac{1}{\frac{1}{2}\sin 2x} = 2\csc(2x)$$
Example 6: Exponential function with tangent
Find the derivative of f(x) = e^x tan(x). Apply the product rule:
$$\frac{d}{dx}(e^x \tan x) = e^x \tan x + e^x \sec^2 x = e^x(\tan x + \sec^2 x)$$
Example 7: Radical inside tangent
Find the derivative of f(x) = tan(√x). Recalling the derivative of √x is 1/(2√x):
$$\frac{d}{dx}\tan(\sqrt{x}) = \sec^2(\sqrt{x}) \cdot \frac{1}{2\sqrt{x}} = \frac{\sec^2\sqrt{x}}{2\sqrt{x}}$$
Higher-order derivatives of tan(x)
Finding higher derivatives of tan(x) requires differentiating sec²(x) repeatedly using the chain rule and product rule.

Second derivative
To calculate f”(x) when f(x) = tan(x), differentiate f'(x) = sec²(x) = (sec x)²:
$$\frac{d^2}{dx^2}\tan x = \frac{d}{dx}(\sec x)^2 = 2(\sec x) \cdot \frac{d}{dx}(\sec x)$$
Because the derivative of sec(x) is sec(x)tan(x):
$$\frac{d^2}{dx^2}\tan x = 2\sec x \cdot (\sec x \tan x) = 2\sec^2 x \tan x$$
Third derivative
To find f”'(x), apply the product rule to 2 · sec²(x) · tan(x):
$$\frac{d^3}{dx^3}\tan x = 2 \left[ \frac{d}{dx}(\sec^2 x) \cdot \tan x + \sec^2 x \cdot \frac{d}{dx}(\tan x) \right]$$
Substitute the previously calculated derivatives:
$$\frac{d^3}{dx^3}\tan x = 2 \left[ (2\sec^2 x \tan x) \cdot \tan x + \sec^2 x \cdot (\sec^2 x) \right] = 2\sec^2 x (2\tan^2 x + \sec^2 x)$$
Using sec²(x) = 1 + tan²(x), this expands into 2 sec²(x)(3 tan²(x) + 1) or 6 sec⁴(x) – 4 sec²(x).
Evaluating tangent slopes and finding line equations
To find the equation of a tangent line to y = tan(x) at x = a, evaluate two values. First, calculate the height tan(a). Next, evaluate the slope sec²(a).

Example: Line at x = π/4
- Find the point: y = tan(π/4) = 1. The point is (π/4, 1).
- Find the slope: m = sec²(π/4) = 1 / cos²(π/4) = 1 / (1/2) = 2.
- Write the point-slope form equation: y – 1 = 2(x – π/4).
- Convert to slope-intercept form: y = 2x – π/2 + 1.
This linear equation y ≈ 1 + 2(x – π/4) provides an excellent local linear approximation. For instance, estimating tan(π/4 + 0.01) gives 1 + 2(0.01) = 1.02, which matches the exact value 1.0202 to four decimal places.
Applications in related rates and calculus
The derivative of tangent plays a critical role in physics and engineering problems involving angle rates of change.
Rocket launch tracking problem
A ground camera sits 100 meters from a vertical rocket launch pad. The camera tilts upward at angle θ to track the rising rocket at height h. The relationship is:
$$\tan\theta = \frac{h}{100}$$
Differentiate both sides with respect to time t using implicit differentiation:
$$\sec^2\theta \cdot \frac{d\theta}{dt} = \frac{1}{100} \cdot \frac{dh}{dt}$$
When the rocket reaches a height of 100 meters (making θ = π/4 and sec²θ = 2) and is ascending at 20 m/s (dh/dt = 20):
$$2 \cdot \frac{d\theta}{dt} = \frac{1}{100} \cdot 20 \implies \frac{d\theta}{dt} = \frac{0.2}{2} = 0.1 \text{ rad/s}$$
This pattern is central to many related rates problems involving rotating searchlights, elevation angles, or shadow lengths.
Reversing this differentiation rule gives the standard integration formula integral of sec²x:
$$\int \sec^2 x \, dx = \tan x + C$$
All six trigonometric derivatives compared
Understanding how the derivative of tan(x) relates to the other basic trigonometric functions makes memorization much easier.
| Function | Derivative |
|---|---|
| sin(x) | cos(x) |
| cos(x) | -sin(x) |
| tan(x) | sec²(x) |
| sec(x) | sec(x)tan(x) |
| csc(x) | -csc(x)cot(x) |
| cot(x) | -csc²(x) |
Notice the relationship between tan(x) and its co-function cot(x):
$$\frac{d}{dx}\cot x = \frac{d}{dx}\left(\frac{\cos x}{\sin x}\right) = \frac{-\sin^2 x - \cos^2 x}{\sin^2 x} = -\frac{1}{\sin^2 x} = -\csc^2 x$$
First, tan(x) differentiates to sec²(x) with a positive sign because tangent curves slope upward. However, cot(x) differentiates to -csc²(x) with a negative sign because cotangent curves slope downward.
Common mistakes to avoid on tests
- Confusing tan(x) and sec(x) derivatives: A common error is writing the derivative of tan(x) as sec(x)tan(x). However, sec(x)tan(x) is the derivative of sec(x). The derivative of tan(x) is sec²(x). See the derivative of sec x for comparison.
- Forgetting the inner derivative in chain rule: Writing d/dx[tan(5x)] as sec²(5x) misses the inner factor. The correct answer is 5sec²(5x).
- Confusing tan²(x) with tan(x²): As shown in worked examples, tan²(x) is a squared function with derivative 2tan(x)sec²(x), whereas tan(x²) has an inner x² giving derivative 2x sec²(x²).
- Working in degrees without conversion: Standard calculus derivative formulas rely on radian measure. If x is in degrees, d/dx[tan(x°)] requires adding a conversion factor of π/180, giving (π/180)sec²(x°).
- Evaluating at vertical asymptotes: You cannot calculate the derivative at x = π/2 or 3π/2. This is because both tan(x) and sec²(x) are undefined at those points.
Try it yourself
Type any tangent expression below to see the derivative steps calculated, or use the full derivative calculator for longer expressions.

Step-by-step solver·Exact 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.
Input syntax
- Powers
x^2, rootssqrt(x),cbrt(x), absolute value|x| - Implicit multiplication works:
3x sin(2x) sin cos tan sec csc cot,asin acos atan,sinh cosh tanhe^xorexp(x);ln(x)is the natural log. In this solverlog(x)also means the natural log (the usual calculus convention); typelog10(x)for base 10- Constants
piande; bounds acceptinfand-inf
Practice problems
Work through these practice problems to test your understanding before checking the answers below.

- Find the derivative of f(x) = tan(5x).
- Find the derivative of f(x) = tan(√x).
- Find the derivative of f(x) = e^x tan(x).
- Next, find the derivative of f(x) = tan(2x + 1).
- Find the derivative of f(x) = tan(x) / x.
- Also, find the derivative of f(x) = sin(x) tan(x).
Solutions:
- 5sec²(5x)
- sec²(√x) / (2√x)
- e^x tan(x) + e^x sec²(x)
- 2sec²(2x + 1)
- (x sec²(x) – tan(x)) / x²
- sin(x) + sin(x)sec²(x)
Frequently asked questions
Is the derivative of tan x equal to sec x tan x?
No. sec(x)tan(x) is the derivative of sec(x). The derivative of tan(x) is sec²(x). See the derivative of sec x.
What is the second derivative of tan x?
The second derivative is 2sec²(x)tan(x). You obtain this by differentiating sec²(x) with the chain rule, giving 2 · sec(x) · [sec(x)tan(x)].
What is the integral of tan x?
The antiderivative is ∫ tan(x) dx = -ln|cos x| + C, which you can write as ln|sec x| + C. Also, you can find the full derivation in integral of tan x.
Is sec²x the same as 1 + tan²x?
Yes. Dividing the identity sin²(x) + cos²(x) = 1 by cos²(x) gives 1 + tan²(x) = sec²(x). So both representations are mathematically equivalent.
Why is the derivative of tan x never negative?
Because sec²(x) = 1/cos²(x) is a squared quantity, its value is always at least 1 wherever defined. As a result, tan(x) is an increasing function across every branch of its domain.
Further reading
- Paul’s Online Notes: Derivatives of Trig Functions — covers the two key trig limits. In addition, it shows derivations of all six trig derivatives with practice.
- Paul’s Online Notes: Product and Quotient Rule — a refresher on the quotient rule used in the main proof.
Calculators for this topic
Keep learning
Inverse Trig Functions: Arcsin, Arccos and Arctan
Arcsin, arccos and arctan explained: domains and ranges, how to evaluate them, graphs, derivatives, and the integrals that give inverse trig answers.
Derivative Rules: Every Differentiation Formula, Explained
All the derivative rules in one place: definition, power, product (uv), quotient and chain rules, plus trig, exponential, log and inverse trig derivatives.

