numpy
  1. numpy-tanh

tanh() - ( NumPy Functions )

Heading h2

Syntax

numpy.tanh(x)

Example

import numpy as np

x = np.array([0.5, 0.1, 0.7])

tanh_x = np.tanh(x)

print(tanh_x)

Output

[0.46211716 0.09966799 0.60436778]

Explanation

The tanh() function in NumPy returns the hyperbolic tangent of an array. The hyperbolic tangent is defined as the ratio of the hyperbolic sine to the hyperbolic cosine of a given value.

The tanh() function takes a single parameter, x - the array for which tanh() is to be calculated. The returned array will have the same shape as the input array.

Use

The tanh() function in NumPy is used to calculate the hyperbolic tangent of an array.

Important Points

  • The tanh() function in NumPy returns the hyperbolic tangent of an array.
  • The hyperbolic tangent is defined as the ratio of the hyperbolic sine to the hyperbolic cosine of a given value.
  • The tanh() function takes a single parameter, x - the array for which tanh() is to be calculated.
  • The returned array will have the same shape as the input array.

Summary

The tanh() function in NumPy is a useful mathematical function that can be used to calculate the hyperbolic tangent of an array. The function takes a single parameter, x, which is the array for which the tanh() function is to be calculated. The tanh() function returns an array with the same shape as the input array.

Published on: