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 natural (base ``e``) logarithm, having domain ``[0, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element ``x_i`` of the input array ``x``.
1216
+
r"""
1217
+
Calculates an implementation-dependent approximation to the natural (base ``e``) logarithm for each element ``x_i`` of the input array ``x``.
1218
1218
1219
1219
**Special cases**
1220
1220
1221
-
For floating-point operands,
1221
+
For real-valued floating-point operands,
1222
1222
1223
1223
- If ``x_i`` is ``NaN``, the result is ``NaN``.
1224
1224
- If ``x_i`` is less than ``0``, the result is ``NaN``.
1225
1225
- If ``x_i`` is either ``+0`` or ``-0``, the result is ``-infinity``.
1226
1226
- If ``x_i`` is ``1``, the result is ``+0``.
1227
1227
- If ``x_i`` is ``+infinity``, the result is ``+infinity``.
1228
1228
1229
+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1230
+
1231
+
- If ``a`` is ``-0`` and ``b`` is ``+0``, the result is ``-infinity + πj``.
1232
+
- If ``a`` is ``+0`` and ``b`` is ``+0``, the result is ``-infinity + 0j``.
1233
+
- If ``a`` is a finite number and ``b`` is ``+infinity``, the result is ``+infinity + πj/2``.
1234
+
- If ``a`` is a finite number and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1235
+
- If ``a`` is ``-infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + πj``.
1236
+
- If ``a`` is ``+infinity`` and ``b`` is a positive (i.e., greater than ``0``) finite number, the result is ``+infinity + 0j``.
1237
+
- If ``a`` is ``-infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + 3πj/4``.
1238
+
- If ``a`` is ``+infinity`` and ``b`` is ``+infinity``, the result is ``+infinity + πj/4``.
1239
+
- If ``a`` is either ``+infinity`` or ``-infinity`` and ``b`` is ``NaN``, the result is ``+infinity + NaN j``.
1240
+
- If ``a`` is ``NaN`` and ``b`` is a finite number, the result is ``NaN + NaN j``.
1241
+
- If ``a`` is ``NaN`` and ``b`` is ``+infinity``, the result is ``+infinity + NaN j``.
1242
+
- If ``a`` is ``NaN`` and ``b`` is ``NaN``, the result is ``NaN + NaN j``.
1243
+
1244
+
.. note::
1245
+
The natural logarithm of a complex number :math:`z` with polar coordinates :math:`(r,\theta)` equals :math:`\ln r + (\theta + 2n\pi)j` with principal value :math:`\ln r + \theta j`.
1246
+
1247
+
.. note::
1248
+
For complex floating-point operands, ``log(conj(x))`` must equal ``conj(log(x))``.
1249
+
1250
+
.. note::
1251
+
By convention, the branch cut of the natural logarithm is the negative real axis :math:`(-\infty, 0)`.
1252
+
1253
+
The natural logarithm is a continuous function from above the branch cut, taking into account the sign of the imaginary component.
1254
+
1255
+
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.
1256
+
1257
+
*Note: branch cuts have provisional status* (see :ref:`branch-cuts`).
1258
+
1229
1259
Parameters
1230
1260
----------
1231
1261
x: array
1232
-
input array. Should have a real-valued floating-point data type.
1262
+
input array. Should have a floating-point data type.
1233
1263
1234
1264
Returns
1235
1265
-------
1236
1266
out: array
1237
-
an array containing the evaluated natural logarithm for each element in ``x``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
1267
+
an array containing the evaluated natural logarithm for each element in ``x``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
0 commit comments