@stdlib/math-base-special-kernel-tanf
v0.1.1
Published
Compute the tangent of a number on [-π/4, π/4] in single-precision floating-point format.
Readme
kernelTanf
Compute the tangent of a number on
[-π/4, π/4]in single-precision floating-point format.
Installation
npm install @stdlib/math-base-special-kernel-tanfUsage
var kernelTanf = require( '@stdlib/math-base-special-kernel-tanf' );kernelTanf( x, iy )
Computes the tangent of a number on [-π/4, π/4] in single-precision floating-point format.
var out = kernelTanf( 3.141592653589793/4.0, 1 );
// returns ~1.0
out = kernelTanf( 3.141592653589793/6.0, 1 );
// returns ~0.577
out = kernelTanf( 0.664, 1 );
// returns ~0.783If k = 1, the function returns tan(x). To return the negative inverse -1/tan(x), set k = -1.
var out = kernelTanf( 3.141592653589793/4.0, -1 );
// returns ~-1.0If provided NaN for x, the function returns NaN.
var out = kernelTanf( NaN, 1 );
// returns NaN
out = kernelTanf( NaN, -1 );
// returns NaNExamples
var linspace = require( '@stdlib/array-base-linspace' );
var PI = require( '@stdlib/constants-float32-pi' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var kernelTanf = require( '@stdlib/math-base-special-kernel-tanf' );
var x = linspace( -PI/4.0, PI/4.0, 100 );
logEachMap( 'kernelTanf(%0.4f, %d) = %0.4f', x, 1, kernelTanf );C APIs
Usage
#include "stdlib/math/base/special/kernel_tanf.h"stdlib_base_kernel_tanf( x, iy )
Computes the tangent of a number on [-π/4, π/4] in single-precision floating-point format.
float out = stdlib_base_kernel_tanf( 3.141592653589793/4.0, 1 );
// returns ~1.0f
out = stdlib_base_kernel_tanf( 3.141592653589793/6.0, 1 );
// returns ~0.577fThe function accepts the following arguments:
- x:
[in] doubleinput value (in radians, assumed to be bounded by~pi/4in magnitude). - iy:
[in] int32_tindicates whethertan(x)(ifiy = 1) or-1/tan(x)(ifiy = -1) is returned.
float stdlib_base_kernel_tanf( const double x, const int32_t iy );Examples
#include "stdlib/math/base/special/kernel_tanf.h"
#include <stdio.h>
int main( void ) {
const double x[] = { -0.7853981633974483, -0.6108652381980153, -0.4363323129985824, -0.26179938779914946, -0.08726646259971649, 0.08726646259971649, 0.26179938779914935, 0.43633231299858233, 0.6108652381980153, 0.7853981633974483 };
float out;
int i;
for ( i = 0; i < 10; i++ ) {
out = stdlib_base_kernel_tanf( x[ i ], 1 );
printf( "kernelTanf(%lf, %d) = %f\n", x[ i ], 1, out );
}
}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
Copyright
Copyright © 2016-2026. The Stdlib Authors.
