The OpenD Programming Language

sumOfLogs

Compute the sum of binary logarithms of the input range r. The error of this method is much smaller than with a naive sum of log.

sumOfLogs
(
Range
)
(
Range r
)

Examples

import mir.math: LN2, approxEqual;
assert([ 0.25, 0.25, 0.25, 0.125 ].sumOfLogs.approxEqual(-9 * double(LN2)));

Meta