You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculates an implementation-dependent approximation to the hyperbolic tangent, having domain ``[-infinity, +infinity]`` and codomain ``[-1, +1]``, for each element ``x_i`` of the input array ``x``.
1345
+
r"""
1346
+
Calculates an implementation-dependent approximation to the hyperbolic tangent for each element ``x_i`` of the input array ``x``.
1347
+
1348
+
The mathematical definition of the hyperbolic tangent is
where :math:`\operatorname{sinh}(x)` is the hyperbolic sine and :math:`operatorname{cosh}(x)` is the hyperbolic cosine.
1347
1354
1348
1355
**Special cases**
1349
1356
1350
-
For floating-point operands,
1357
+
.. note::
1358
+
For all operands, ``tanh(-x)`` must equal ``-tanh(x)``.
1359
+
1360
+
For real-valued floating-point operands,
1351
1361
1352
1362
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1353
1363
- If ``x_i`` is ``+0``, the result is ``+0``.
1354
1364
- If ``x_i`` is ``-0``, the result is ``-0``.
1355
1365
- If ``x_i`` is ``+infinity``, the result is ``+1``.
1356
1366
- If ``x_i`` is ``-infinity``, the result is ``-1``.
1357
1367
1368
+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1369
+
1370
+
.. note::
1371
+
For complex floating-point operands, ``tanh(conj(x))`` must equal ``conj(tanh(x))``.
1372
+
1373
+
- If ``a`` is ``+0`` and ``b`` is ``+0``, the result is ``+0 + 0j``.
1374
+
- If ``a`` is a nonzero finite number and ``b`` is ``+infinity``, the result is ``NaN + NaN j``.
1375
+
- If ``a`` is ``+0`` and ``b`` is ``+infinity``, the result is ``+0 + NaN j``.
1376
+
- If ``a`` is a nonzero finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1377
+
- If ``a`` is ``+0`` and ``b`` is ``NaN``, the result is ``+0 + NaN j``.
1378
+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``1 + 0j``.
1379
+
- If ``a`` is ``+infinity`` and ``b`` is ``+infinity``, the result is ``1 + 0j`` (sign of the imaginary component is unspecified).
1380
+
- If ``a`` is ``+infinity`` and ``b`` is ``NaN``, the result is ``1 + 0j`` (sign of the imaginary component is unspecified).
1381
+
- If ``a`` is ``NaN`` and ``b`` is ``+0``, the result is ``NaN + 0j``.
1382
+
- If ``a`` is ``NaN`` and ``b`` is a nonzero number, the result is ``NaN + NaN j``.
1383
+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1384
+
1385
+
.. note::
1386
+
The hyperbolic tangent is an analytical function on the complex plane and has no branch cuts. The function is periodic, with period :math:`\pi j`, with respect to the imaginary component and has first order poles along the imaginary line at coordinates :math:`(0, \pi (\frac{1}{2} + n))`. However, IEEE 754 binary floating-point representation cannot represent :math:`\pi / 2` exactly, and, thus, no argument value is possible such that a pole error occurs.
1387
+
1358
1388
Parameters
1359
1389
----------
1360
1390
x: array
1361
-
input array whose elements each represent a hyperbolic angle. Should have a real-valued floating-point data type.
1391
+
input array whose elements each represent a hyperbolic angle. Should have a floating-point data type.
1362
1392
1363
1393
Returns
1364
1394
-------
1365
1395
out: array
1366
-
an array containing the hyperbolic tangent of each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1396
+
an array containing the hyperbolic tangent of each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
0 commit comments