|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# Covercosine |
| 22 | + |
| 23 | +> Compute the [coversed cosine][coversed-cosine] of a single-precision floating-point number (in radians). |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [coversed cosine][coversed-cosine] is defined as |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:covercosine" align="center" raw="\operatorname{covercos}(\theta) = 1 + \sin \theta" alt="Coversed cosine."> --> |
| 30 | + |
| 31 | +```math |
| 32 | +\mathop{\mathrm{covercos}}(\theta) = 1 + \sin \theta |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- </equation> --> |
| 36 | + |
| 37 | +</section> |
| 38 | + |
| 39 | +<!-- /.intro --> |
| 40 | + |
| 41 | +<section class="usage"> |
| 42 | + |
| 43 | +## Usage |
| 44 | + |
| 45 | +```javascript |
| 46 | +var covercosf = require( '@stdlib/math/base/special/covercosf' ); |
| 47 | +``` |
| 48 | + |
| 49 | +#### covercosf( x ) |
| 50 | + |
| 51 | +Computes the [coversed cosine][coversed-cosine] of a single-precision floating-point number (in radians). |
| 52 | + |
| 53 | +```javascript |
| 54 | +var v = covercosf( 0.0 ); |
| 55 | +// returns 1.0 |
| 56 | + |
| 57 | +v = covercosf( 3.141592653589793/2.0 ); |
| 58 | +// returns 2.0 |
| 59 | + |
| 60 | +v = covercosf( -3.141592653589793/6.0 ); |
| 61 | +// returns 0.5 |
| 62 | +``` |
| 63 | + |
| 64 | +</section> |
| 65 | + |
| 66 | +<!-- /.usage --> |
| 67 | + |
| 68 | +<section class="examples"> |
| 69 | + |
| 70 | +## Examples |
| 71 | + |
| 72 | +<!-- eslint no-undef: "error" --> |
| 73 | + |
| 74 | +```javascript |
| 75 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 76 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 77 | +var TWO_PI = require( '@stdlib/constants/float32/two-pi' ); |
| 78 | +var covercosf = require( '@stdlib/math/base/special/covercosf' ); |
| 79 | + |
| 80 | +var opts = { |
| 81 | + 'dtype': 'float32' |
| 82 | +}; |
| 83 | +var x = uniform( 100, 0.0, TWO_PI, opts ); |
| 84 | + |
| 85 | +logEachMap( 'covercosf(%0.4f) = %0.4f', x, covercosf ); |
| 86 | +``` |
| 87 | + |
| 88 | +</section> |
| 89 | + |
| 90 | +<!-- /.examples --> |
| 91 | + |
| 92 | +<!-- C interface documentation. --> |
| 93 | + |
| 94 | +* * * |
| 95 | + |
| 96 | +<section class="c"> |
| 97 | + |
| 98 | +## C APIs |
| 99 | + |
| 100 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 101 | + |
| 102 | +<section class="intro"> |
| 103 | + |
| 104 | +</section> |
| 105 | + |
| 106 | +<!-- /.intro --> |
| 107 | + |
| 108 | +<!-- C usage documentation. --> |
| 109 | + |
| 110 | +<section class="usage"> |
| 111 | + |
| 112 | +### Usage |
| 113 | + |
| 114 | +```c |
| 115 | +#include "stdlib/math/base/special/covercosf.h" |
| 116 | +``` |
| 117 | + |
| 118 | +#### stdlib_base_covercosf( x ) |
| 119 | + |
| 120 | +Computes the [coversed cosine][coversed-cosine] of a single-precision floating-point number (in radians). |
| 121 | + |
| 122 | +```c |
| 123 | +float out = stdlib_base_covercosf( 0.0f ); |
| 124 | +// returns 1.0f |
| 125 | + |
| 126 | +out = stdlib_base_covercosf( 3.141592653589793f / 2.0f ); |
| 127 | +// returns 2.0f |
| 128 | +``` |
| 129 | + |
| 130 | +The function accepts the following arguments: |
| 131 | + |
| 132 | +- **x**: `[in] float` input value. |
| 133 | + |
| 134 | +```c |
| 135 | +float stdlib_base_covercosf( const float x ); |
| 136 | +``` |
| 137 | +
|
| 138 | +</section> |
| 139 | +
|
| 140 | +<!-- /.usage --> |
| 141 | +
|
| 142 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 143 | +
|
| 144 | +<section class="notes"> |
| 145 | +
|
| 146 | +</section> |
| 147 | +
|
| 148 | +<!-- /.notes --> |
| 149 | +
|
| 150 | +<!-- C API usage examples. --> |
| 151 | +
|
| 152 | +<section class="examples"> |
| 153 | +
|
| 154 | +### Examples |
| 155 | +
|
| 156 | +```c |
| 157 | +#include "stdlib/math/base/special/covercosf.h" |
| 158 | +#include <stdio.h> |
| 159 | +
|
| 160 | +int main( void ) { |
| 161 | + const float x[] = { 0.0f, 0.523f, 0.785f, 1.047f, 3.14f }; |
| 162 | +
|
| 163 | + float y; |
| 164 | + int i; |
| 165 | + for ( i = 0; i < 5; i++ ) { |
| 166 | + y = stdlib_base_covercosf( x[ i ] ); |
| 167 | + printf( "covercosf(%f) = %f\n", x[ i ], y ); |
| 168 | + } |
| 169 | +} |
| 170 | +``` |
| 171 | + |
| 172 | +</section> |
| 173 | + |
| 174 | +<!-- /.examples --> |
| 175 | + |
| 176 | +</section> |
| 177 | + |
| 178 | +<!-- /.c --> |
| 179 | + |
| 180 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 181 | + |
| 182 | +<section class="related"> |
| 183 | + |
| 184 | +</section> |
| 185 | + |
| 186 | +<!-- /.related --> |
| 187 | + |
| 188 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 189 | + |
| 190 | +<section class="links"> |
| 191 | + |
| 192 | +[coversed-cosine]: https://en.wikipedia.org/wiki/Versine |
| 193 | + |
| 194 | +<!-- <related-links> --> |
| 195 | + |
| 196 | +<!-- </related-links> --> |
| 197 | + |
| 198 | +</section> |
| 199 | + |
| 200 | +<!-- /.links --> |
0 commit comments