What is Tangent Function?
The tangent function is a periodic function which is very important in trigonometry.
The simplest way to understand the tangent function is to use the unit circle. In trigonometry, a unit circle is the circle of radius one centered at the origin \(\left( {0,0} \right)\) in the Cartesian coordinate system.
Now that we have seen how to define trigonometric ratios for arbitrary angles, we are ready to study trigonometric ratios from the perspective of functions. Let's try to understand the Graph of Tangent Function.
Graph of Tangent Function:
We define the \(\tan \) function as
\[f\left( x \right) = \tan x\]
Let us study the variation in the \(\tan \) function as \(x\) goes from 0 to \(\frac{\pi }{2}\). Consider the following figure, which shows \(P\) moving through the first quadrant:
We make the following observations:

Initially, when \(x = 0\), the perpendicular \(PQ = 0\) while the base \(OQ = 1\). Thus, \(\tan 0 = 0\).

As \(x\) increases, \(PQ\) increases, while \(OQ\) decreases. Thus, \(\tan x = \frac{{PQ}}{{OQ}}\) increases.

When \(x = \frac{\pi }{4}\), \(PQ = OQ\), so that \(\tan \frac{\pi }{4} = 1\).

As \(x\) increases further, \(PQ\) increases towards 1, while \(OQ\) decreases towards 0.

As \(x\) nears \(\frac{\pi }{2}\), \(PQ\) comes closer and closer to 1, while \(OQ\) comes closer and closer to 0. Thus, \(\frac{{PQ}}{{OQ}}\) will become larger and larger. In fact, it will go towards infinity as \(x\) comes very close to \(\frac{\pi }{2}\).

Exactly at \(x = \frac{\pi }{2}\), \(PQ\) becomes exactly 1, while \(OQ\) becomes exactly 0. The ratio \(\frac{{PQ}}{{OQ}}\) becomes mathematically undefined. Thus, \(\tan \frac{\pi }{2}\) is undefined.
Making use of these observations, the graph of \(f\left( x \right) = \tan x\) for \(x\) in the range \(\left[ {0,\frac{\pi }{2}} \right)\) is shown below:
Now how the curve shoots up towards infinity as \(x\) nears \(\frac{\pi }{2}\). Exactly at \(x = \frac{\pi }{2}\), the tan function is undefined. The vertical dashed line in the graph highlights the fact that the curve tends towards this line, but never actually manages to touch this line, no matter how close we come to \(x = \frac{\pi }{2}\).
Let us now study the variation in the \(\tan x\) function as \(x\) goes from \(\frac{\pi }{2}\) to \(\pi \). The following figure shows \(P\) moving through the second quadrant:
Note the following observations:

When \(P\) just crosses from the \(y\)axis over into the second quadrant (when \(x\) increases just slightly above \(\frac{\pi }{2}\)), the perpendicular \(PQ\) is still very close to 1, while the base \(OQ\) is still very close to 0. However, \(OQ\) is now negative, which means that \(\frac{{PQ}}{{OQ}}\) will be very large in magnitude but negative in sign. Thus, if \(x\) is larger than \(\frac{\pi }{2}\) but comes closer and closer to \(\frac{\pi }{2}\), \(\tan x\) will shoot off towards negative infinity.

As \(P\) moves further into the second quadrant, \(PQ\) decreases in magnitude, while \(OQ\) increases in magnitude (but is still negative). Thus, \(\frac{{PQ}}{{OQ}}\) decreases in magnitude but stays negative.

When \(x = \frac{{3\pi }}{4}\) (135^{0}), \(\left {PQ} \right = \left {OQ} \right\), so \(\tan \frac{{3\pi }}{4} =  1\).

As \(P\) moves towards the position of \(180^\circ \) or \(\pi \) radians, \(PQ\) comes closer to 0 while \(\left {OQ} \right\) comes closer to 1. Thus, the ratio \(\frac{{PQ}}{{OQ}}\) comes closer to 0 (but stays negative all this while).

When \(x\) is exactly \(\pi \), \(PQ = 0\) while \(OQ =  1\), so \(\tan \pi = 0\).
We make use of these observations to extend the graph of \(f\left( x \right) = \tan x\) to include \(x\) in the interval \(\left( {\frac{\pi }{2},\pi } \right]\) :
Now how the curve shoots down towards negative infinity as \(x\) nears \(\frac{\pi }{2}\) from the right side.
To understand this behavior around \(\frac{\pi }{2}\) better, consider the following figure, which shows two positions of \(P\), one when \(x\) is just less than \(\frac{\pi }{2}\), and the other when \(x\) is just greater than \(\frac{\pi }{2}\):
For \({P_1},\,{P_1}{Q_1}\) will be very near to 1, and \(O{Q_1}\) will be positive and very small in magnitude (near to 0). Thus, \(\frac{{{P_1}{Q_1}}}{{O{Q_1}}}\) will be very large (it will approach positive infinity as \(x\) comes even closer to \(\frac{\pi }{2}\) from the lower side).
Now, consider the second position \({P_2}\). \({P_2}{Q_2}\) will also be very near to 1, and \(O{Q_2}\) will again be close to 0 in magnitude, but \(O{Q_2}\) will be negative. Thus, \(\frac{{{P_2}{Q_2}}}{{O{Q_2}}}\) will be very large in magnitude but negative in sign (it will approach negative infinity as \(x\) comes even closer to \(\frac{\pi }{2}\) from the upper side).
Thus, as \(x\) goes from slightly below \(\frac{\pi }{2}\) to slightly above \(\frac{\pi }{2}\), the curve of \(f\left( x \right) = \tan x\) jumps from nearing positive infinity to nearing negative infinity, through a discontinuity at \(x = \frac{\pi }{2}\).
It is not difficult to see that as \(P\) moves further, the variation in \(\tan x\) will start to repeat. As \(x\) increases from \(\pi \) to \(\frac{{3\pi }}{2}\), the variation in \(\tan x\) will be the same as the variation in \(\tan x\) for the range \(\left[ {0,\frac{\pi }{2}} \right)\).
As \(x\) increases from \(\frac{{3\pi }}{2}\) to \(2\pi \), the variation in \(\tan x\) will be the same as the variation in \(\tan x\) for the range \(\left( {\frac{\pi }{2},\pi } \right]\). Make sure you understand why this is so.
Thus, we can now extend our graph to obtain the complete graph of \(f\left( x \right) = \tan x\):
We make the following observations:

The \(\tan x\) functions is not defined for all odd multiples of \(\frac{\pi }{2}\). This is because the base is 0 for these positions. Thus, the domain of the \(\tan x\) function is \(\mathbb{R}\  \left\{ {\left( {2n + 1} \right)\frac{\pi }{2}} \right\}\), where \(n\) belongs to the set of integers.

The range of this function is \(\mathbb{R}\), as the \(y\)variation in the graph is from negative infinity to positive infinity.

The \(\tan x\) function has a cycle of \(\pi \), instead of \(2\pi \).
✍Note: Domain of the \(\tan x\) function is \(\mathbb{R}\  \left\{ {\left( {2n + 1} \right)\frac{\pi }{2}} \right\}\), where \(n\) belongs to the set of integers and the range of \(\tan x\) function is \(\mathbb{R}\).
Solved Example:
Example 1: Find all values of \(x\) such that \(\tan x = 1\).
Solution: The following figure shows the intersection of \(y = \tan x\) and \(y = 1\):
In the interval \(\left[ {0,\pi } \right]\) , we find one solution: \(x = \frac{\pi }{4}\). Since \(\tan x\) has a cycle of \(\pi \), we can write the set of all solutions as:
\[\boxed{x = n\pi + \frac{\pi }{4},\,\,\,n \in \mathbb{Z}}\]
Challenge: Find the domain of the following function:
\[f(x) = \frac{1}{{1  \tan x}}\]
⚡Tip: \(f(x)\) will be undefined when \({1  \tan x = 0}\).