Function log [src]
Alias for std.math.complex.log.log
Returns the natural logarithm of z.
Prototype
pub fn log(z: anytype) Complex(@TypeOf(z.re, z.im))
Example
test log {
const epsilon = math.floatEps(f32);
const a = Complex(f32).init(5, 3);
const c = log(a);
try testing.expectApproxEqAbs(1.7631803, c.re, epsilon);
try testing.expectApproxEqAbs(0.5404195, c.im, epsilon);
}
Source
pub fn log(z: anytype) Complex(@TypeOf(z.re, z.im)) {
const T = @TypeOf(z.re, z.im);
const r = cmath.abs(z);
const phi = cmath.arg(z);
return Complex(T).init(@log(r), phi);
}