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 ``log(1+x)``, where ``log`` refers to the natural (base ``e``) logarithm, having domain ``[-1, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element ``x_i`` of the input array ``x``.
1178
+
r"""
1179
+
Calculates an implementation-dependent approximation to ``log(1+x)``, where ``log`` refers to the natural (base ``e``) logarithm, for each element ``x_i`` of the input array ``x``.
1180
1180
1181
1181
.. note::
1182
1182
The purpose of this function is to calculate ``log(1+x)`` more accurately when `x` is close to zero. Accordingly, conforming implementations should avoid implementing this function as simply ``log(1+x)``. See FDLIBM, or some other IEEE 754-2019 compliant mathematical library, for a potential reference implementation.
1183
1183
1184
1184
**Special cases**
1185
1185
1186
-
For floating-point operands,
1186
+
For real-valued floating-point operands,
1187
1187
1188
1188
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1189
1189
- If ``x_i`` is less than ``-1``, the result is ``NaN``.
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
1194
1194
1195
+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1196
+
1197
+
- If ``a`` is ``-1`` and ``b`` is ``+0``, the result is ``-infinity + 0j``.
1198
+
- If ``a`` is a finite number and ``b`` is ``+infinity``, the result is ``+infinity + πj/2``.
1199
+
- If ``a`` is a finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1200
+
- If ``a`` is ``-infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + πj``.
1201
+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + 0j``.
1202
+
- If ``a`` is ``-infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + 3πj/4``.
1203
+
- If ``a`` is ``+infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + πj/4``.
1204
+
- If ``a`` is either ``+infinity`` or ``-infinity`` and ``b`` is ``NaN``, the result is ``+infinity + NaN j``.
1205
+
- If ``a`` is ``NaN`` and ``b`` is a finite number, the result is ``NaN + NaN j``.
1206
+
- If ``a`` is ``NaN`` and ``b`` is ``+infinity``, the result is ``+infinity + NaN j``.
1207
+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1208
+
1209
+
.. note::
1210
+
For complex floating-point operands, ``log1p(conj(x))`` must equal ``conj(log1p(x))``.
1211
+
1212
+
.. note::
1213
+
By convention, the branch cut of the natural logarithm is the negative real axis :math:`(-\infty, 0)`.
1214
+
1215
+
The natural logarithm is a continuous function from above the branch cut, taking into account the sign of the imaginary component.
1216
+
1217
+
Accordingly, for complex arguments, the function returns the natural logarithm in the range of a strip in the interval :math:`[-\pi j, +\pi j]` along the imaginary axis and mathematically unbounded along the real axis.
1218
+
1219
+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
1220
+
1195
1221
Parameters
1196
1222
----------
1197
1223
x: array
1198
-
input array. Should have a real-valued floating-point data type.
1224
+
input array. Should have a floating-point data type.
1199
1225
1200
1226
Returns
1201
1227
-------
1202
1228
out: array
1203
-
an array containing the evaluated result for each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1229
+
an array containing the evaluated result for each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
0 commit comments