Derivative of tangent

By Martin McBride, 2025-10-08
Tags: quotient rule first principles derivative tan
Categories: differentiation calculus
Level:


In this article we will find the derivative of the tan function. This can be done using the quotient rule (this article explains the quotient rule, and shows how to use it to differentiate tan). However, in this article, we will derive it from first principles.

There is nothing wrong with using the quotient rule, but it is always good to look at things from more than one angle.

First principles approach

We will start with the standard formula for the derivative of a function f(x), which is:

First principles

We can apply this to the tan function:

First principles

It will make things neater, later on, if we take the 1/h out as a separate factor:

First principles

Whenever we differentiate from first principles, the main thing we need to do is to get the limit into a form where it can be evaluated, so we can remove h from the equation. Often, sin and cos are easier to deal with than the tan function, so let's try this substitution (from the definition of tan):

First principles

We can apply that definition to both tan functions in the previous equation:

First principles

We now have a sum of two fractions. One thing to try might be to combine them into a single fraction by cross-multiplying:

First principles

Performing a trig substitution

This looks quite promising. Look at the numerator:

Trig substitution

This looks exactly like the RHS of the following well-known trig formula:

Trig substitution

To match equation (1), we need to use the following values for α and β. Notice this gives a nice, simple value for α - β:

Trig substitution

So we can put these values into equation (2) to obtain a simplified equation (1):

Trig substitution

Now let's substitute that back into the main equation:

Trig substitution

Separating the limits

When we have a complex limit like the one above, it can be useful to split it into separate limits. In our case, the two cosines are in a form that should be easy to deal with, so we can start by separating that out. Taking the 1/h back into the brackets, we can rearrange the fraction into two parts:

Finding limit

There is a rule of limits that says the limit of a product is equal to the product of the limits. That gives us:

Finding limit

Taking the second limit, this is a simple case. As h tends to 0, x + h tends to x, so we have:

Finding limit

The first limit isn't so obvious, although it is quite a famous limit, so you might recognise it. As h tends to 0, sin h also tends to 0, so the limit tends to 0/0, which is indeterminate. In this situation, we can apply L'Hôpital's rule. It says that, when a quotient of two functions is indeterminate, the limit of the quotient of the functions is equal to the limit of the quotient of the derivatives of the functions, that is:

Finding limit

In our case, the functions are sin x and x, so the derivatives are:

Finding limit

Substituting these into L'Hôpital's rule tells us that the limit is simply the limit of cos x as x goes to 0, which of course is 1:

Finding limit

This graph shows the functions sin x in red and x in cyan. The two functions become very close in value as x approaches 0, so it seems reasonable that their ratio at 0 should be 1. L'Hôpital's rule just formalises (and, importantly, proves) that intuition:

L'Hôpital's rule

If we put these values back into our previous equation for f'(x), we get:

Finding limit

Here is a graph of the tan function in red and its derivative in cyan.

tan and derivative

This (of course) is the same result obtained in using the quotient rule, in the linked article.

See also



Join the GraphicMaths Newsletter

Sign up using this form to receive an email when new content is added:

Popular tags

adder adjacency matrix alu and gate angle answers area argand diagram binary maths cartesian equation chain rule chord circle cofactor combinations complex modulus complex numbers complex polygon complex power complex root cosh cosine cosine rule countable cpu cube decagon demorgans law derivative determinant diagonal directrix dodecagon e eigenvalue eigenvector ellipse equilateral triangle erf function euclid euler eulers formula eulers identity exercises exponent exponential exterior angle first principles flip-flop focus gabriels horn galileo gamma function gaussian distribution gradient graph hendecagon heptagon heron hexagon hilbert horizontal hyperbola hyperbolic function hyperbolic functions infinity integration integration by parts integration by substitution interior angle inverse hyperbolic function inverse matrix irrational irrational number irregular polygon isomorphic graph isosceles trapezium isosceles triangle kite koch curve l system lhopitals rule limit line integral locus logarithm maclaurin series major axis matrix matrix algebra mean minor axis n choose r nand gate net newton raphson method nonagon nor gate normal normal distribution not gate octagon or gate parabola parallelogram parametric equation pentagon perimeter permutation matrix permutations pi pi function polar coordinates polynomial power probability probability distribution product rule proof pythagoras proof quadrilateral questions quotient rule radians radius rectangle regular polygon rhombus root sech segment set set-reset flip-flop simpsons rule sine sine rule sinh sloping lines solving equations solving triangles square square root squeeze theorem standard curves standard deviation star polygon statistics straight line graphs surface of revolution symmetry tangent tanh transformation transformations translation trapezium triangle turtle graphics uncountable variance vertical volume volume of revolution xnor gate xor gate