Skip to content
ihateDesmos

Derivative of tan x

Updated 6 November 2026 · Checked numerically by the ihateDesmos engine
The derivative of tan x
ddx(tan(x))=sec(x)2

The derivative of tan x is sec²x, which equals 1/cos²x. It is always at least 1, so the tangent graph rises everywhere it is defined.

−3−2−1123−550
Open in calculator
y=tan(x)
in blue and its derivative
y=sec(x)2
in red. Defined for x ≠ π/2 + nπ, the same as tan x itself.

How to find the derivative of tan x

Method: quotient rule.

  1. 1
    Write tan x as a fraction: tan x = sin x / cos x.
  2. 2
    Apply the quotient rule: d/dx (f/g) = (f′g − fg′) / g².
  3. 3
    With f = sin x and g = cos x: (cos x · cos x − sin x · (−sin x)) / cos²x.
  4. 4
    Simplify the top: (cos²x + sin²x) / cos²x.
  5. 5
    Use the identity sin²x + cos²x = 1: this is 1/cos²x = sec²x.

What it means on the graph

At x = 0 the slope is exactly 1. Near the asymptotes at x = ±π/2, cos x approaches 0, so sec²x shoots up, matching how steep the tangent curve becomes there. The derivative is never below 1, and never negative.

Table of values

The derivative column uses the formula. The last column estimates the slope directly from the original function, as an independent check.

Values of tan x and its derivative
xtan xsec²xSlope, measured
−6/5−2.572157.615967.61596
−π/4−122
0011
π/6√3/34/34/3
π/4122
6/52.572157.615967.61596

Second derivative

Differentiating once more gives:

d2dx2(tan(x))=2sec(x)2tan(x)

The second derivative tells you which way the graph bends: positive means it curves upward, and negative means it curves downward.

Related derivatives

The same result with the chain or product rule. Each of these is checked numerically too.

Related derivatives
FunctionDerivative
tan(2x)
2sec(2x)2
tan(x2)
2xsec(x2)2
tan(x)2
2tan(x)sec(x)2

Common mistakes

  • Writing sec x instead of sec²x. The exponent matters.
  • Forgetting that sec²x and 1 + tan²x are the same thing, so your answer may look different from the back of the book but still be right.

Frequently asked questions

What is the derivative of tan x?
The derivative of tan x is sec²x, for x ≠ π/2 + nπ, the same as tan x itself.
What is the second derivative of tan x?
Differentiate sec²x again to get the second derivative. The result is shown on this page under “Second derivative”.
Is the derivative of tan x sec²x or 1 + tan²x?
Both. They are equal, because 1 + tan²x = sec²x. It also equals 1/cos²x.
What is the second derivative of tan x?
2 sec²x tan x, found with the chain rule.

Keep going

Differentiate any function

Type your own function into the derivative calculator and see every rule applied, step by step.

Open the derivative calculator