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