The TANH function in Oracle SQL is a mathematical function that returns the hyperbolic tangent of a number.
This is an exponential function, different from the standard trigonometric TAN (tangent) function. It's often used in physics, engineering, and complex calculations.
What is the TANH Function in Oracle?
The TANH(n) function takes a number n and returns its hyperbolic tangent. The calculation is equivalent to:
(EXP(n) - EXP(-n)) / (EXP(n) + EXP(-n))
Where EXP is e (Euler's number) raised to the power of n. The result is always a value between -1 and 1.
TANH Function Syntax
The syntax for TANH is very simple:
TANH(n)
Let's break that down:
n(the number): The number for which you want to find the hyperbolic tangent.
Oracle TANH Function Examples
Here are two practical examples of how to use TANH.
Example 1: Finding the Hyperbolic Tangent of 1
This example calculates the hyperbolic tangent of the number 1.
Query:
SELECT
TANH(1) AS "Hyperbolic_Tangent_of_1"
FROM DUAL;
Result:
Hyperbolic_Tangent_of_1
-----------------------
.761594156
Example 2: Finding the Hyperbolic Tangent of 0
This example calculates the hyperbolic tangent of 0, which is always 0.
Query:
SELECT
TANH(0) AS "Hyperbolic_Tangent_of_0"
FROM DUAL;
Result:
Hyperbolic_Tangent_of_0
-----------------------
0
