@stdlib/math-base-special-kernel-cosf
v0.1.1
Published
Compute the cosine of a number on [-π/4, π/4] in single-precision floating-point format.
Readme
kernelCosf
Compute the cosine of a number on
[-π/4, π/4]in single-precision floating-point format.
Installation
npm install @stdlib/math-base-special-kernel-cosfUsage
var kernelCosf = require( '@stdlib/math-base-special-kernel-cosf' );kernelCosf( x )
Computes the cosine of a number on [-π/4, π/4] in single-precision floating-point format.
var v = kernelCosf( 0.0 );
// returns ~1.0
v = kernelCosf( 3.141592653589793/6.0 );
// returns ~0.866
v = kernelCosf( 0.785 );
// returns ~0.707
v = kernelCosf( NaN );
// returns NaNExamples
var linspace = require( '@stdlib/array-base-linspace' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var PI = require( '@stdlib/constants-float64-pi' );
var kernelCosf = require( '@stdlib/math-base-special-kernel-cosf' );
var x = linspace( -PI/4.0, PI/4.0, 100 );
logEachMap( 'kernelCosf(%0.4f) = %0.4f', x, kernelCosf );C APIs
Usage
#include "stdlib/math/base/special/kernel_cosf.h"stdlib_base_kernel_cosf( x )
Computes the cosine of a number on [-π/4, π/4] in single-precision floating-point format.
float v = stdlib_base_kernel_cosf( 0.0 );
// returns ~1.0f
v = stdlib_base_kernel_cosf( 3.141592653589793/6.0 );
// returns ~0.866fThe function accepts the following arguments:
- x:
[in] doubleinput value (in radians, assumed to be bounded by~pi/4in magnitude).
float stdlib_base_kernel_cosf( const double x );Examples
#include "stdlib/math/base/special/kernel_cosf.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_cosf( x[ i ] );
printf( "kernelCosf(%lf) = %f\n", x[ i ], 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.
