negaLucas
Compute the nth negaLucas number in single-precision floating-point format.
The negaLucas numbers are the integer sequence
The sequence is defined by the recurrence relation
which yields
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 );
// returns 0.0f
out = stdlib_base_negalucasf( -1 );
// returns -1.0f
The function accepts the following arguments:
- n:
[in] int32_tinput value.
float stdlib_base_negalucasf( const int32_t n );
Examples
#include "stdlib/math/base/special/negalucasf.h"
#include <stdio.h>
#include <stdint.h>
int main( void ) {
int32_t i;
float v;
for ( i = 0; i > -35; i-- ) {
v = stdlib_base_negalucasf( i );
printf( "negalucasf(%d) = %f\n", i, v );
}
}