View source code
Display the source code in std/complex.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.complex.log

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

Complex!T log(T) (
  Complex!T x
) pure nothrow @nogc @safe;

Parameters

NameDescription
x A complex number

Returns

The complex natural logarithm of x

Special Values
x log(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)

Example

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

auto a = complex(2.0, 1.0);
writeln(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));

writeln(log(complex(-1.0L, 0.0L))); // complex(0.0L, PI)
writeln(log(complex(-1.0L, -0.0L))); // complex(0.0L, -PI)

Authors

Lars Tandle Kyllingstad, Don Clugston

License

Boost License 1.0