Skip to content

Latest commit

 

History

History
272 lines (168 loc) · 6 KB

File metadata and controls

272 lines (168 loc) · 6 KB

negaLucasf

Compute the nth negaLucas number in single-precision floating-point format.

The negaLucas numbers are the integer sequence

$$2, -1, 3, -4, 7, -11, 18, -29, 47, -76, 123, -199, 322, \ldots$$

The sequence is defined by the recurrence relation

$$L_{n-2} = L_{n} - L_{n-1}$$

which yields

$$L_{-n} = (-1)^{n} L_n$$

with seed values L_0 = 2 and L_{-1} = -1.

Usage

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

negalucasf( n )

Computes the nth negaLucas number in single-precision floating-point format.

var v = negalucasf( 0 );
// returns 2

v = negalucasf( -1 );
// returns -1

v = negalucasf( -2 );
// returns 3

v = negalucasf( -3 );
// returns -4

v = negalucasf( -34 );
// returns 12752043

If n < -34, the function returns NaN, as larger negaLucas numbers cannot be safely represented in single-precision floating-point format.

var v = negalucasf( -35 );
// returns NaN

If not provided a nonpositive integer value, the function returns NaN.

var v = negalucasf( -3.14 );
// returns NaN

v = negalucasf( 1 );
// returns NaN

If provided NaN, the function returns NaN.

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

Examples

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

var v;
var i;

for ( i = 0; i > -35; i-- ) {
    v = negalucasf( i );
    console.log( v );
}

C APIs

Usage

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

stdlib_base_negalucasf( n )

Computes the nth negaLucas number in single-precision floating-point format.

float out = stdlib_base_negalucasf( 0.0f );
// returns 2.0f

out = stdlib_base_negalucasf( -1.0f );
// returns -1.0f

The function accepts the following arguments:

  • n: [in] float input value.
float stdlib_base_negalucasf( const float n );

Examples

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

int main( void ) {
    float i;
    float v;

    for ( i = 0.0f; i > -35.0f; i-- ) {
        v = stdlib_base_negalucasf( i );
        printf( "negalucasf(%f) = %f\n", i, v );
    }
}