Skip to content

Latest commit

 

History

History
241 lines (148 loc) · 5.62 KB

File metadata and controls

241 lines (148 loc) · 5.62 KB

digammaf

Digamma function (single-precision).

The digamma function ψ is the logarithmic derivative of the gamma function, i.e.

$$\psi(x) =\frac{d}{dx} \ln{\Gamma(x)}= \frac{\Gamma\,'(x)}{\Gamma(x)}$$

Usage

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

digammaf( x )

Evaluates the digamma function for a single-precision floating-point number.

var v = digammaf( -2.5 );
// returns ~1.103

v = digammaf( 1.0 );
// returns ~-0.577

v = digammaf( 10.0 );
// returns ~2.252

If x is 0 or a negative integer, the function returns NaN.

var v = digammaf( 0.0 );
// returns NaN

v = digammaf( -1.0 );
// returns NaN

v = digammaf( -2.0 );
// returns NaN

If provided NaN, the function returns NaN.

var v = digammaf( NaN );
// returns NaN

Examples

var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var digammaf = require( '@stdlib/math/base/special/digammaf' );

var opts = {
    'dtype': 'float32'
};
var x = uniform( 100, -5.0, 5.0, opts );

logEachMap( 'x: %0.4f, f(x): %0.4f', x, digammaf );

C APIs

Usage

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

stdlib_base_digammaf( x )

Evaluates the digamma function for a single-precision floating-point number.

float out = stdlib_base_digammaf( 1.0f );
// returns ~-0.577f

out = stdlib_base_digammaf( 2.0f );
// returns ~0.423f

The function accepts the following arguments:

  • x: [in] float input value.
float stdlib_base_digammaf( const float x );

Examples

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

int main( void ) {
    const float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };

    float y;
    int i;
    for ( i = 0; i < 5; i++ ) {
        y = stdlib_base_digammaf( x[ i ] );
        printf( "digamma(%f) = %f\n", x[ i ], y );
    }
}

See Also