|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2024 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 | +# ahavercosf |
| 22 | + |
| 23 | +> Compute the [inverse half-value versed cosine][archavercosine] of a single-precision floating point number. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [inverse half-value versed cosine][archavercosine] is defined as |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:archavercosine" align="center" raw="\operatorname{ahavercos}(\theta) = 2 \cdot \arccos(\sqrt{\theta})" alt="Inverse half-value versed cosine."> --> |
| 30 | + |
| 31 | +```math |
| 32 | +\mathop{\mathrm{ahavercos}}(\theta) = 2 \cdot \arccos(\sqrt{\theta}) |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="\operatorname{ahavercos}(\theta) = 2 \cdot \arccos(\sqrt{\theta})" data-equation="eq:archavercosine"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/ahavercos/docs/img/equation_archavercosine.svg" alt="Inverse half-value versed cosine."> |
| 37 | + <br> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 41 | + |
| 42 | +</section> |
| 43 | + |
| 44 | +<!-- /.intro --> |
| 45 | + |
| 46 | +<section class="usage"> |
| 47 | + |
| 48 | +## Usage |
| 49 | + |
| 50 | +```javascript |
| 51 | +var ahavercosf = require( '@stdlib/math/base/special/ahavercosf' ); |
| 52 | +``` |
| 53 | + |
| 54 | +#### ahavercosf( x ) |
| 55 | + |
| 56 | +Computes the [inverse half-value versed cosine][archavercosine] of a single-precision floating point number (in radians). |
| 57 | + |
| 58 | +```javascript |
| 59 | +var v = ahavercosf( 0.0 ); |
| 60 | +// returns ~3.1416 |
| 61 | + |
| 62 | +v = ahavercosf( 1.0 ); |
| 63 | +// returns 0.0 |
| 64 | + |
| 65 | +v = ahavercosf( 0.5 ); |
| 66 | +// returns ~1.5708 |
| 67 | +``` |
| 68 | + |
| 69 | +If `x < 0`, `x > 1`, or `x` is `NaN`, the function returns `NaN`. |
| 70 | + |
| 71 | +```javascript |
| 72 | +var v = ahavercosf( 1.5 ); |
| 73 | +// returns NaN |
| 74 | + |
| 75 | +v = ahavercosf( -3.14 ); |
| 76 | +// returns NaN |
| 77 | + |
| 78 | +v = ahavercosf( NaN ); |
| 79 | +// returns NaN |
| 80 | +``` |
| 81 | + |
| 82 | +</section> |
| 83 | + |
| 84 | +<!-- /.usage --> |
| 85 | + |
| 86 | +<section class="examples"> |
| 87 | + |
| 88 | +## Examples |
| 89 | + |
| 90 | +<!-- eslint no-undef: "error" --> |
| 91 | + |
| 92 | +```javascript |
| 93 | +var linspace = require( '@stdlib/array/base/linspace' ); |
| 94 | +var ahavercosf = require( '@stdlib/math/base/special/ahavercosf' ); |
| 95 | + |
| 96 | +var x = linspace( 0.0, 1.0, 100 ); |
| 97 | + |
| 98 | +var i; |
| 99 | +for ( i = 0; i < x.length; i++ ) { |
| 100 | + console.log( ahavercosf( x[ i ] ) ); |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +</section> |
| 105 | + |
| 106 | +<!-- /.examples --> |
| 107 | + |
| 108 | +<!-- C interface documentation. --> |
| 109 | + |
| 110 | +* * * |
| 111 | + |
| 112 | +<section class="c"> |
| 113 | + |
| 114 | +## C APIs |
| 115 | + |
| 116 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 117 | + |
| 118 | +<section class="intro"> |
| 119 | + |
| 120 | +</section> |
| 121 | + |
| 122 | +<!-- /.intro --> |
| 123 | + |
| 124 | +<!-- C usage documentation. --> |
| 125 | + |
| 126 | +<section class="usage"> |
| 127 | + |
| 128 | +### Usage |
| 129 | + |
| 130 | +```c |
| 131 | +#include "stdlib/math/base/special/ahavercosf.h" |
| 132 | +``` |
| 133 | + |
| 134 | +#### stdlib_base_ahavercosf( x ) |
| 135 | + |
| 136 | +Computes the [inverse half-value versed cosine][archavercosine] of a single-precision floating-point number (in radians). |
| 137 | + |
| 138 | +```c |
| 139 | +float out = stdlib_base_ahavercosf( 0.0f ); |
| 140 | +// returns ~3.1416f |
| 141 | +``` |
| 142 | + |
| 143 | +If `x < 0`, `x > 1`, or `x` is `NaN`, the function returns `NaN`. |
| 144 | + |
| 145 | +```c |
| 146 | +float out = stdlib_base_ahavercosf( -3.14f ); |
| 147 | +// returns NaN |
| 148 | +``` |
| 149 | + |
| 150 | +The function accepts the following arguments: |
| 151 | + |
| 152 | +- **x**: `[in] float` input value. |
| 153 | + |
| 154 | +```c |
| 155 | +float stdlib_base_ahavercosf( const float x ); |
| 156 | +``` |
| 157 | +
|
| 158 | +</section> |
| 159 | +
|
| 160 | +<!-- /.usage --> |
| 161 | +
|
| 162 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 163 | +
|
| 164 | +<section class="notes"> |
| 165 | +
|
| 166 | +</section> |
| 167 | +
|
| 168 | +<!-- /.notes --> |
| 169 | +
|
| 170 | +<!-- C API usage examples. --> |
| 171 | +
|
| 172 | +<section class="examples"> |
| 173 | +
|
| 174 | +### Examples |
| 175 | +
|
| 176 | +```c |
| 177 | +#include "stdlib/math/base/special/ahavercosf.h" |
| 178 | +#include <stdio.h> |
| 179 | +
|
| 180 | +int main( void ) { |
| 181 | + const float x[] = { -2.0f, -1.6f, -1.2f, -0.8f, -0.4f, 0.4f, 0.8f, 1.2f, 1.6f, 2.0f }; |
| 182 | + |
| 183 | + float v; |
| 184 | + int i; |
| 185 | + for ( i = 0; i < 10; i++ ) { |
| 186 | + v = stdlib_base_ahavercosf( x[ i ] ); |
| 187 | + printf( "ahavercosf(%f) = %f\n", x[ i ], v ); |
| 188 | + } |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +</section> |
| 193 | + |
| 194 | +<!-- /.examples --> |
| 195 | + |
| 196 | +</section> |
| 197 | + |
| 198 | +<!-- /.c --> |
| 199 | + |
| 200 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 201 | + |
| 202 | +<section class="related"> |
| 203 | + |
| 204 | +</section> |
| 205 | + |
| 206 | +<!-- /.related --> |
| 207 | + |
| 208 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 209 | + |
| 210 | +<section class="links"> |
| 211 | + |
| 212 | +[archavercosine]: https://en.wikipedia.org/wiki/Versine |
| 213 | + |
| 214 | +<!-- <related-links> --> |
| 215 | + |
| 216 | +<!-- </related-links> --> |
| 217 | + |
| 218 | +</section> |
| 219 | + |
| 220 | +<!-- /.links --> |
0 commit comments