Physics · function

exactLog

Math.log, reproducibly: fdlibm's algorithm, which is also V8's.

Explained in Your first game, Rigid bodies.

function exactLog(x: number): number
import { exactLog } from '@driftengine/physics';

Parameters

ParameterTypeDescription
xnumber

In depth

Take the power of two out as k and leave a significand in [√2/2, √2), so that f = m - 1 is small either side of zero; then log(1 + f) = f - f²/2 + s·(f²/2 + R(s²)) with s = f/(2 + f), and k·ln 2 added back in two parts so the large part loses nothing. The exponent is read and the significand rescaled through the double's own words — integer operations, not transcendentals.