# The easiest way to calculate the tangent of a function

A tangent line to a function at a point is a line that is in contact with the graphical representation of the function only in that particular point.

The tangent line is only touching the function (graph) in the specified point. In other words the tangent line is barely in contact with function (graph).

The line which is crossing (intersecting) a function graph it’s called a secant line.

In the example above the red line is the tangent. It’s tangent to the f(x) function in the point P(x1, y1). The blue line is the secant and as you can see it’s crossing the function f(x) in two points.

Given a function f(x) and a point P1(x1, y1), how do we calculate the tangent? Finding the tangent means finding the equation of the line which is tangent to the function f(x) in the point P1(x1, y1).

Example: Find the tangent of the function f(x) defined below, in the point x1.

$f(x)=2-x^{3}, {\hspace 5mm} x_{1}=1$

Step 1: Calculate the (x, y) coordinates of the tangent point

The first thing to do is to evaluate the function in the tangent point x1.

$f(1)=2-1^{3}=1$

We know that:

$y_{1}=f(x_{1})$

This means that the result of the function evaluation in the point x1 is the y1 coordinate. We now have defined the point P1(1, 1). Let’s plot the function f(x) for x = 0 … 2 and the point P1 with x1 and y1 coordinates.

Step 2: Define two points P0 and P2, on the left and right of P1.

We’ll chose a point P0 at x0 = 0.6 and P2 at x2 = 1.4. These point must be equally distributed on the left and right of the P1 tangent point.

Step 3. Calculate the y coordinates of the P0 and P2 points

First let’s calculate the y coordinate of the P0 point.

$\begin{equation*} \begin{split} y_{0}&=f(x_{0})\\ f(0.6)&=2-{0.6}^{3}=1.784\\ y_{0}&=1.784 \end{split} \end{equation*}$

We now have defined the point P0 (0.6, 1.784).

Now we calculate the y coordinate of the P2 point:

$\begin{equation*} \begin{split} y_{2}&=f(x_{2})\\ f(1.4)&=2-{1.4}^{3}=-0.744\\ y_{2}&=-0.744 \end{split} \end{equation*}$

We now have defined the point P2 (1.4,-0.744).

Let’s now update our function graph with both P0 and P2 points and their coordinates.

Step 4. Calculate the slopes of the lines defined between the points P0-P1 and P1-P2

Having two points defined we can easily draw a straight line between them. Also with the coordinates of the two points we can calculate the slope of the line.

In our case we’ll have two lines, one between point P0 and P1 and the second between P1 and P2. For both lines we can calculate their slope.

The usual notation of the slope of a line is the letter m.

For the first line, the slope m0 is calculated as:

$\begin{equation*} \begin{split} m_{0}&=\frac{y_{1}-y_{0}}{x_{1}-x_{0}}=\frac{1-1.784}{1-0.6}=-1.96\\ m_{0}&=-1.96 \end{split} \end{equation*}$

For the second line, the slope m2 is calculated as:

$\begin{equation*} \begin{split} m_{2}&=\frac{y_{2}-y_{1}}{x_{2}-x_{1}}=\frac{-0.744-1}{1.4-1}=-4.36\\ m_{2}&=-4.36 \end{split} \end{equation*}$

Below is the graphical representation of the two lines and the f(x) function. Both lines are secant to our f(x) function.

Step 5. Calculate the slope of the line tangent in the point P1 (1, 1)

The slope of the line tangent in the point P1 will be the arithmetic mean of the slopes of the two secant lines. This method of calculation is possible because we have chosen the x0 and x2 points at equal distance from x1.

$\begin{equation*} \begin{split} m_{1}&=\frac{m_{0}+m_{2}}{2}=\frac{-1.96-4.36}{2}=-3.16\\ m_{1}&=-3.16 \end{split} \end{equation*}$

Step 6 (final step). Calculate the equation of the tangent line in the point P1.

Now that we know the coordinates of the tangent point P1 and the value of the slope, we can easily calculate the equation of the tangent line:

$\begin{equation*} \begin{split} y(x) &= y_{1} + m_1 \cdot (x – x_1)\\ y(x) & = 1 – 3.16 \cdot (x – 1) \end{split} \end{equation*}$

Having the tangent line equation we can plot on the same graph the function f(x) and the tangent line y(x).

As you can see the tangent line is “touching” the function f(x) in the point P1 (1, 1).

Using the same method we can calculate the tangent line in the point (1, 1) for the following functions:

$f(x)=x^2 + 2 \cdot x + 1$ $f(x)=10 \cdot \sqrt{2 \cdot x} + 3 \cdot x + 2$

Apply the same method to your function and let us now the result!

For any questions or observations regarding this tutorial please use the comment form below.

Don’t forget to Like, Share and Subscribe!