MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / ln

Function ln

src/compute-engine/interval/elementary.ts:331–352  ·  view source on GitHub ↗
(x: Interval | IntervalResult)

Source from the content-addressed store, hash-verified

329 * - Contains/touches zero: partial with -Infinity lower bound
330 */
331export function ln(x: Interval | IntervalResult): IntervalResult {
332 const unwrapped = unwrapOrPropagate(x);
333 if (!Array.isArray(unwrapped)) return unwrapped;
334 const [xVal] = unwrapped;
335 // Case 1: Entirely non-positive - no valid values
336 if (xVal.hi <= 0) {
337 return { kind: 'empty' };
338 }
339
340 // Case 2: Entirely positive - straightforward
341 if (xVal.lo > 0) {
342 return ok({ lo: Math.log(xVal.lo), hi: Math.log(xVal.hi) });
343 }
344
345 // Case 3: Includes zero or negative values
346 // ln(x) -> -Infinity as x -> 0+
347 return {
348 kind: 'partial',
349 value: { lo: -Infinity, hi: Math.log(xVal.hi) },
350 domainClipped: 'lo',
351 };
352}
353
354/**
355 * Base-10 logarithm.

Callers 1

Calls 3

unwrapOrPropagateFunction · 0.90
okFunction · 0.90
logMethod · 0.65

Tested by

no test coverage detected