function log
log(x: number): number

Computes the natural logarithm (base e).

Computes the natural logarithm (base e) for each element in a number, array, or matrix.

Examples

Natural logarithm of a single number

import { assertEquals } from "jsr:@std/assert";

assertEquals(log(6), 1.791759469228055);

Natural logarithm of an array of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(log([5, 6, 3]), [1.6094379124341003, 1.791759469228055, 1.0986122886681096]);

Natural logarithm of a matrix of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(log([[5, 6, 5], [7, 8, 2]]), [
  [1.6094379124341003, 1.791759469228055, 1.6094379124341003],
  [1.9459101490553132, 2.0794415416798357, 0.6931471805599453]
]);

Parameters

x: number

The input value(s)

Return Type

number

The natural logarithm of the input value(s)

Throws

If no arguments are provided

log(x: array): array

Computes the natural logarithm (base e).

Computes the natural logarithm (base e) for each element in a number, array, or matrix.

Examples

Natural logarithm of a single number

import { assertEquals } from "jsr:@std/assert";

assertEquals(log(6), 1.791759469228055);

Natural logarithm of an array of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(log([5, 6, 3]), [1.6094379124341003, 1.791759469228055, 1.0986122886681096]);

Natural logarithm of a matrix of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(log([[5, 6, 5], [7, 8, 2]]), [
  [1.6094379124341003, 1.791759469228055, 1.6094379124341003],
  [1.9459101490553132, 2.0794415416798357, 0.6931471805599453]
]);

Parameters

The input value(s)

Return Type

The natural logarithm of the input value(s)

Throws

If no arguments are provided

log(x: matrix): matrix

Computes the natural logarithm (base e).

Computes the natural logarithm (base e) for each element in a number, array, or matrix.

Examples

Natural logarithm of a single number

import { assertEquals } from "jsr:@std/assert";

assertEquals(log(6), 1.791759469228055);

Natural logarithm of an array of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(log([5, 6, 3]), [1.6094379124341003, 1.791759469228055, 1.0986122886681096]);

Natural logarithm of a matrix of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(log([[5, 6, 5], [7, 8, 2]]), [
  [1.6094379124341003, 1.791759469228055, 1.6094379124341003],
  [1.9459101490553132, 2.0794415416798357, 0.6931471805599453]
]);

Parameters

The input value(s)

Return Type

The natural logarithm of the input value(s)

Throws

If no arguments are provided