Derivative of tan x
The first derivative of \( \tan (x)\) is calculated using the derivative of \( \sin x \) and \( \cos x \) and the quotient rule of derivatives.
Calculation of the Derivative of tan x
A trigonometric identity relating \( \tan x \), \( \sin x \) and \( \cos x \) is given by \[ \tan x = \dfrac { \sin x }{ \cos x } \] One way to find the derivative of \( \tan x \) is to use the quotient rule of differentiation; hence\( \displaystyle {\dfrac {d}{dx} \tan x = \dfrac {d}{dx} (\dfrac{\sin x }{\cos x}) = (\dfrac{{ (\dfrac {d}{dx}\sin x) }{ \cos x }  \sin x (\dfrac {d}{dx} \cos x) }{\cos^2 x}} \)
Use the formulae for the derivative of the trigonometric functions \( \sin x \) and \( \cos x \) given by \( \dfrac {d}{dx}\sin x = \cos x \) and \( \dfrac {d}{dx}\cos x =  \sin x \) and substitute to obtain
\( \displaystyle {\dfrac {d}{dx} \tan x = (\dfrac{{ \cos x \cos x }  \sin x (\sin x) }{\cos^2 x}} \)
Simplify
\( \displaystyle {= \dfrac{ \cos^2 x + \sin^2 x } {\cos^2 x} = \dfrac{ 1 }{\cos^2 x} = \sec^2 x }\)
conclusion
\[ \displaystyle {\dfrac {d}{dx} \tan x = \sec^2 x} \]
Graph of tan x and its Derivative
The graphs of \( \tan(x) \) and its derivative are shown below.
Derivative of the Composite Function tan (u(x))
We now have a composite function which is a function (tan) of another function (u). Use the chain rule of differentiation to write\( \displaystyle \dfrac{d}{dx} \tan (u(x)) = (\dfrac{d}{du} \tan u) (\dfrac{d}{dx} u ) \)
Simplify
\( = \sec^2 u \dfrac{d}{dx} u \)
Conclusion
\[ \displaystyle \dfrac{d}{dx} \tan (u(x)) = \sec^2 u \dfrac{d}{dx} u \]
Example 1
Find the derivative of the composite tan functions
 \( f(x) = \tan (2x 1) \)
 \( g(x) = \tan (\cos(x)) \)
 \( h(x) = \tan (\dfrac{x1}{x+2}) \)
Solution to Example 1

Let \( u(x) = 2x  1 \) and therefore \( \dfrac{d}{dx} u = \dfrac{d}{dx} (2x  1) = 2 \) and apply the rule
\( \displaystyle \dfrac{d}{dx} f(x) = (\sec^2 u \dfrac{d}{dx} u = \sec^2 (2x1) \times 2 = 2 \sec^2 (2x1) ) \)

Let \( u(x) = \cos x \) and therefore \( \dfrac{d}{dx} u = \dfrac{d}{dx} \cos x =  \sin x \) and apply the rule
\( \displaystyle \dfrac{d}{dx} g(x) = (\sec^2 u \dfrac{d}{dx} u = \sec^2 (\cos x) \times ( \sin x) =  \sin x \sec^2 (\cos x) \)

Let \( u(x) = \dfrac{x1}{x+2} \) and therefore \( \dfrac{d}{dx} u = \dfrac{3}{(x+2)^2} \) and apply the rule obtained above
\( \displaystyle \dfrac{d}{dx} h(x) = \sec^2 u \dfrac{d}{dx} u = \sec^2 (\dfrac{x1}{x+2}) \times \dfrac{3}{(x+2)^2} = \dfrac {3 \sec^2 (\dfrac{x1}{x+2})}{(x+2)^2} \)
More References and links
Rules of Differentiation of Functions in Calculus .Trigonometric Identities and Formulas .
Derivatives of the Trigonometric Functions .
Chain Rule of Differentiation in Calculus .