What is TANH() in SQL?

The TANH() method in SQL returns the hyperbolic tangent of a parametric value. More precisely, it takes a double-precision number in arguments that specify the angle in radians. TANH() returns the hyperbolic tangent of this specific angle.

Figure 1 illustrates the mathematical representation of the hyperbolic tangent method. Figure 2 demonstrates the graphical behavior of TANH() between a -5 to +5 interval.

Figure 1: Mathematical representation of hyperbolic tangent function
Figure 2: Graphical illustration of TANH(θ)
Figure 2: Graphical illustration of TANH(θ)

Syntax

TANH(θ) //θ should be Radian angle

To convert degrees to radians, use this formula: Radian angle = Degree angle * π/180

Parameter

The TANH() method requires a double-precision number as an argument.

Return value

TANH() returns the hyperbolic tangent (double-precision number) of the value that is sent as a parameter.

  • On passing NULL as a parameter, it will return NULL.
  • On passing 0 as an argument, it will return 0.

Example

The following example illustrates how to use TANH(x) in SQL and shows its behavior in different scenarios.

-- Example showing how to use TANH(x)
/*Positive number*/
SELECT TANH(2); -- return 0.9640275800758169
/*Negative number*/
select TANH(-1); -- return -0.7615941559557649
/*Fractional number*/
select TANH(0.6); -- return 0.5370495669980353

Free Resources