0.2.4 • Published 4 months ago

@stdlib/math-base-special-ln v0.2.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 months ago

ln

NPM version Build Status Coverage Status

Evaluate the natural logarithm of a double-precision floating-point number.

Installation

npm install @stdlib/math-base-special-ln

Usage

var ln = require( '@stdlib/math-base-special-ln' );

ln( x )

Evaluates the natural logarithm of a double-precision floating-point number.

var v = ln( 4.0 );
// returns ~1.386

v = ln( 0.0 );
// returns -Infinity

v = ln( Infinity );
// returns Infinity

v = ln( NaN );
// returns NaN

For negative numbers, the natural logarithm is not defined.

var v = ln( -4.0 );
// returns NaN

Examples

var randu = require( '@stdlib/random-base-randu' );
var round = require( '@stdlib/math-base-special-round' );
var ln = require( '@stdlib/math-base-special-ln' );

var x;
var i;

for ( i = 0; i < 100; i++ ) {
    x = round( randu() * 100.0 );
    console.log( 'ln(%d) = %d', x, ln( x ) );
}

C APIs

Usage

#include "stdlib/math/base/special/ln.h"

stdlib_base_ln( x )

Evaluates the natural logarithm of a double-precision floating-point number.

double v = stdlib_base_ln( 2.0 );
// returns ~0.693

The function accepts the following arguments:

  • x: [in] double input value.
double stdlib_base_ln( const double x );

Examples

#include "stdlib/math/base/special/ln.h"
#include <stdlib.h>
#include <stdio.h>

int main( void ) {
    double out;
    double x;
    int i;

    for ( i = 0; i < 100; i++ ) {
        x = ( (double)rand() / (double)RAND_MAX ) * 100.0;
        out = stdlib_base_ln( x );
        printf( "ln(%lf) = %lf\n", x, out );
    }
}

See Also


Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


Copyright

Copyright © 2016-2024. The Stdlib Authors.

@everything-registry/sub-chunk-868@stdlib/math-base-special-roundsd@infinitebrahmanuniverse/nolb-_stdlib_m@stdlib/stats-base-dists-lognormal-pdf@stdlib/stats-base-dists-negative-binomial-logpmf@stdlib/stats-base-dists-negative-binomial-mgf@stdlib/stats-base-dists-negative-binomial-pmf@stdlib/stats-base-dists-invgamma-logpdf@stdlib/stats-base-dists-invgamma-pdf@stdlib/stats-base-dists-kumaraswamy-logcdf@stdlib/stats-base-dists-normal-entropy@stdlib/stats-base-dists-normal-logcdf@stdlib/stats-base-dists-normal-logpdf@stdlib/stats-base-dists-logistic-entropy@stdlib/stats-base-dists-logistic-logpdf@stdlib/stats-base-dists-logistic-quantile@stdlib/stats-base-dists-pareto-type1-entropy@stdlib/stats-base-dists-kumaraswamy-logpdf@stdlib/stats-base-dists-laplace-entropy@stdlib/stats-base-dists-lognormal-cdf@stdlib/stats-base-dists-lognormal-entropy@stdlib/stats-base-dists-lognormal-logcdf@stdlib/stats-base-dists-lognormal-logpdf@stdlib/stats-base-dists-levy-entropy@stdlib/stats-base-dists-levy-logcdf@stdlib/stats-base-dists-levy-logpdf@stdlib/stats-base-dists-laplace-logpdf@stdlib/stats-base-dists-laplace-quantile@stdlib/stats-base-dists-cosine-logpdf@stdlib/stats-base-dists-beta-logpdf@stdlib/stats-base-dists-beta-pdf@stdlib/stats-base-dists-discrete-uniform-entropy@stdlib/stats-base-dists-discrete-uniform-logcdf@stdlib/stats-base-dists-discrete-uniform-logpmf@stdlib/stats-base-dists-betaprime-logpdf@stdlib/stats-base-dists-binomial-entropy@stdlib/stats-base-dists-binomial-logpmf@stdlib/stats-base-dists-binomial-pmf@stdlib/stats-base-dists-cauchy-entropy@stdlib/stats-base-dists-cauchy-logcdf@stdlib/stats-base-dists-cauchy-logpdf@stdlib/stats-base-dists-chi-logpdf@stdlib/stats-base-dists-cosine-logcdf@stdlib/stats-base-dists-chisquare-entropy@stdlib/stats-kstest@stdlib/math-base-special-gamma1pm1@stdlib/math-base-special-gammainc@stdlib/math-base-special-gammaincinv@stdlib/math-base-special-gammaln@stdlib/math-base-special-fibonacci-index@stdlib/math-base-special-floorsd@stdlib/math-base-special-fast-acosh@stdlib/math-base-special-fast-asinh@stdlib/math-base-special-fast-atanh@stdlib/math-base-special-ellipe@stdlib/math-base-special-ellipk@stdlib/math-base-special-erfcinv@stdlib/math-base-special-erfinv@stdlib/math-base-special-ceilsd@stdlib/math-base-special-digamma@stdlib/math-base-special-kernel-betainc@stdlib/math-base-special-kernel-betaincinv@stdlib/math-base-special-log@stdlib/math-base-special-truncsd@stdlib/math-base-special-xlogy@stdlib/math-base-special-riemann-zeta@stdlib/math-base-special-log1mexp@stdlib/math-base-special-log1pmx@stdlib/math-base-special-logit@stdlib/math-base-special-sici@stdlib/math-base-special-spence@stdlib/math-base-special-nonfibonacci@stdlib/math-base-special-polygamma@stdlib/math-base-special-powm1@stdlib/stats-base-dists-arcsine-entropy@stdlib/stats-base-dists-arcsine-logcdf@stdlib/stats-base-dists-arcsine-logpdf@stdlib/stats-bartlett-test@stdlib/stats-base-dists-beta-logcdf@stdlib/stats-base-dists-bernoulli-entropy@stdlib/stats-incr-gmean@stdlib/stats-incr-mgmean@stdlib/random-base-erlang@stdlib/random-base-exponential@stdlib/random-base-frechet@stdlib/random-base-gamma@stdlib/random-base-geometric@stdlib/random-base-gumbel@stdlib/random-base-improved-ziggurat@stdlib/random-base-laplace@stdlib/random-base-logistic@stdlib/random-base-poisson@stdlib/random-base-rayleigh@stdlib/random-base-weibull@stdlib/random-base-beta@stdlib/random-base-binomial@stdlib/random-base-box-muller@stdlib/math-base-special@stdlib/math-base-special-acosh@stdlib/math-base-special-asinh
0.2.4

4 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.0

1 year ago

0.1.1

1 year ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago