Table of Contents

Tan

The Tan function returns the tangent of a numeric value. Tangent is a fundamental trigonometric function that represents the ratio between the opposite side and the adjacent side ($\frac{opposite}{adjacent}$) of a right triangle for a given angle. It is widely used in calculations involving slopes, camera perspectives in graphics, and various engineering applications where angular ratios are required.

On the Cubloc platform, all trigonometric functions—including Tan—use radians to measure angles. For the highest degree of precision, especially when calculating steep slopes or rapid transitions, it is recommended to use the Single data type for the input value.

Tan accepts any real number as an angle (except for values where the cosine is zero, such as $\frac{\pi}{2}, \frac{3\pi}{2}$, etc.) and returns the corresponding tangent ratio.

Example

Dim A As Single
Dim B As Single
B = 0.785398     ' 45 degrees in radians (PI / 4)
A = Tan(B)       ' Returns the tangent of B (approx. 1.0)

Explanation:

Tanh

The Tanh function returns the hyperbolic tangent of a numeric value. Unlike the standard tangent function used in circular geometry, the hyperbolic tangent is based on the geometry of a hyperbola. It is a crucial function in fields such as neural networks (as an activation function), statistics, and control systems where values need to be smoothly mapped or “squashed” into a specific range.

On the Cubloc platform, hyperbolic functions—including Tanh—use radians as the unit for the input value. For the most accurate results, particularly when used in recursive algorithms or signal processing, the Single data type is recommended.

One of the most important characteristics of Tanh is that it always returns a value in the range of -1.0 to +1.0, regardless of how large or small the input is.

Example

Dim A As Single
Dim B As Single
B = 0.5
A = Tanh(B)      ' Returns the hyperbolic tangent of B

Explanation:

Go CUBLOC home