|
| 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 | +# rcbrtf |
| 22 | + |
| 23 | +> Compute the reciprocal of the principal [cube root][cube-root] of a single-precision floating-point number. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The reciprocal of the principal [cube root][cube-root] is defined as |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:reciprocal_cube_root" align="center" raw="\operatorname{rcbrt}(x)=\frac{1}{\sqrt[3]{x}}" alt="Reciprocal cube root"> --> |
| 30 | + |
| 31 | +```math |
| 32 | +\mathop{\mathrm{rcbrt}}(x)=\frac{1}{\sqrt[3]{x}} |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="\operatorname{rcbrt}(x)=\frac{1}{\sqrt[3]{x}}" data-equation="eq:reciprocal_cube_root"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@b569df0e375cb7d535781320bf5e2299a0fbff25/lib/node_modules/@stdlib/math/base/special/rcbrt/docs/img/equation_reciprocal_cube_root.svg" alt="Reciprocal cube root"> |
| 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 rcbrtf = require( '@stdlib/math/base/special/rcbrtf' ); |
| 52 | +``` |
| 53 | + |
| 54 | +#### rcbrtf( x ) |
| 55 | + |
| 56 | +Computes the reciprocal cube root of a single-precision floating-point number. |
| 57 | + |
| 58 | +```javascript |
| 59 | +var v = rcbrtf( 1.0 ); |
| 60 | +// returns 1.0 |
| 61 | + |
| 62 | +v = rcbrtf( 8.0 ); |
| 63 | +// returns 0.5 |
| 64 | + |
| 65 | +v = rcbrtf( 1000.0 ); |
| 66 | +// returns ~0.1 |
| 67 | + |
| 68 | +v = rcbrtf( 0.0 ); |
| 69 | +// returns Infinity |
| 70 | + |
| 71 | +v = rcbrtf( NaN ); |
| 72 | +// returns NaN |
| 73 | + |
| 74 | +v = rcbrtf( Infinity ); |
| 75 | +// returns 0.0 |
| 76 | +``` |
| 77 | + |
| 78 | +</section> |
| 79 | + |
| 80 | +<!-- /.usage --> |
| 81 | + |
| 82 | +<section class="examples"> |
| 83 | + |
| 84 | +## Examples |
| 85 | + |
| 86 | +<!-- eslint no-undef: "error" --> |
| 87 | + |
| 88 | +```javascript |
| 89 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 90 | +var rcbrtf = require( '@stdlib/math/base/special/rcbrtf' ); |
| 91 | + |
| 92 | +var x; |
| 93 | +var i; |
| 94 | +for ( i = 0; i < 100; i++ ) { |
| 95 | + x = discreteUniform( 0.0, 100.0 ); |
| 96 | + console.log( 'rcbrtf(%d) = %d', x, rcbrtf( x ) ); |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +</section> |
| 101 | + |
| 102 | +<!-- /.examples --> |
| 103 | + |
| 104 | +<!-- C interface documentation. --> |
| 105 | + |
| 106 | +* * * |
| 107 | + |
| 108 | +<section class="c"> |
| 109 | + |
| 110 | +## C APIs |
| 111 | + |
| 112 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 113 | + |
| 114 | +<section class="intro"> |
| 115 | + |
| 116 | +</section> |
| 117 | + |
| 118 | +<!-- /.intro --> |
| 119 | + |
| 120 | +<!-- C usage documentation. --> |
| 121 | + |
| 122 | +<section class="usage"> |
| 123 | + |
| 124 | +### Usage |
| 125 | + |
| 126 | +```c |
| 127 | +#include "stdlib/math/base/special/rcbrtf.h" |
| 128 | +``` |
| 129 | + |
| 130 | +#### stdlib_base_rcbrtf( x ) |
| 131 | + |
| 132 | +Computes the reciprocal [cube root][cube-root] of a single-precision floating-point number. |
| 133 | + |
| 134 | +```c |
| 135 | +float y = stdlib_base_rcbrtf( 8.0f ); |
| 136 | +// returns 0.5f |
| 137 | +``` |
| 138 | + |
| 139 | +The function accepts the following arguments: |
| 140 | + |
| 141 | +- **x**: `[in] float` input value. |
| 142 | + |
| 143 | +```c |
| 144 | +float stdlib_base_rcbrtf( const float x ); |
| 145 | +``` |
| 146 | +
|
| 147 | +</section> |
| 148 | +
|
| 149 | +<!-- /.usage --> |
| 150 | +
|
| 151 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 152 | +
|
| 153 | +<section class="notes"> |
| 154 | +
|
| 155 | +</section> |
| 156 | +
|
| 157 | +<!-- /.notes --> |
| 158 | +
|
| 159 | +<!-- C API usage examples. --> |
| 160 | +
|
| 161 | +<section class="examples"> |
| 162 | +
|
| 163 | +### Examples |
| 164 | +
|
| 165 | +```c |
| 166 | +#include "stdlib/math/base/special/rcbrtf.h" |
| 167 | +#include <stdio.h> |
| 168 | +
|
| 169 | +int main( void ) { |
| 170 | + const float x[] = { 3.14f, 9.0f, 0.0f, 0.0f / 0.0f }; |
| 171 | +
|
| 172 | + float y; |
| 173 | + int i; |
| 174 | + for ( i = 0; i < 4; i++ ) { |
| 175 | + y = stdlib_base_rcbrtf( x[ i ] ); |
| 176 | + printf( "rcbrt(%f) = %f\n", x[ i ], y ); |
| 177 | + } |
| 178 | +} |
| 179 | +``` |
| 180 | + |
| 181 | +</section> |
| 182 | + |
| 183 | +<!-- /.examples --> |
| 184 | + |
| 185 | +</section> |
| 186 | + |
| 187 | +<!-- /.c --> |
| 188 | + |
| 189 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 190 | + |
| 191 | +<section class="related"> |
| 192 | + |
| 193 | +</section> |
| 194 | + |
| 195 | +<!-- /.related --> |
| 196 | + |
| 197 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 198 | + |
| 199 | +<section class="links"> |
| 200 | + |
| 201 | +[cube-root]: https://en.wikipedia.org/wiki/Cube_root |
| 202 | + |
| 203 | +<!-- <related-links> --> |
| 204 | + |
| 205 | +<!-- </related-links> --> |
| 206 | + |
| 207 | +</section> |
| 208 | + |
| 209 | +<!-- /.links --> |
0 commit comments