The OpenD Programming Language

log

Calculate the natural logarithm of x. The branch cut is along the negative axis.

@safe pure nothrow @nogc
log
(
T
)

Parameters

x Complex!T

A complex number

Return Value

Type: Complex!T

The complex natural logarithm of x

Special Values
xlog(x)
(-0, +0)(-∞, π)
(+0, +0)(-∞, +0)
(any, +∞)(+∞, π/2)
(any, NaN)(NaN, NaN)
(-∞, any)(+∞, π)
(+∞, any)(+∞, +0)
(-∞, +∞)(+∞, 3π/4)
(+∞, +∞)(+∞, π/4)
(±∞, NaN)(+∞, NaN)
(NaN, any)(NaN, NaN)
(NaN, +∞)(+∞, NaN)
(NaN, NaN)(NaN, NaN)

Examples

import core.math : sqrt;
import std.math.constants : PI;
import std.math.operations : isClose;

auto a = complex(2.0, 1.0);
assert(log(conj(a)) == conj(log(a)));

auto b = 2.0 * log10(complex(0.0, 1.0));
auto c = 4.0 * log10(complex(sqrt(2.0) / 2, sqrt(2.0) / 2));
assert(isClose(b, c, 0.0, 1e-15));

assert(log(complex(-1.0L, 0.0L)) == complex(0.0L, PI));
assert(log(complex(-1.0L, -0.0L)) == complex(0.0L, -PI));

Meta