cbrt
Compute the cube root of x.
Interface Definition
C interface:
float cbrtf(float x);
double cbrt(double x);
double cbrt_18(double x);
long double cbrtl(long double x);
cbrt_18 is provided only in the high-precision version.
Fortran interface:
RES = CBRTF(X);
RES = CBRT(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- If input x is ±0, the return value is ±0.
- If input x is ±∞, the return value is ±∞.
- If input x is NaN, the return value is NaN.
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // typical usage double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0; // special handling double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN; // print result printf("cbrt(1.0) = %.15f\n", cbrt(x1)); printf("cbrt(2.0) = %.15f\n", cbrt(x2)); printf("cbrt(3.0) = %.15f\n", cbrt(x3)); printf("cbrt(4.0) = %.15f\n", cbrt(x4)); printf("cbrt(0.0) = %.15f\n", cbrt(a)); printf("cbrt(INFINITY) = %.15f\n", cbrt(b)); printf("cbrt(-INFINITY) = %.15f\n", cbrt(c)); printf("cbrt(NAN) = %.15f\n", cbrt(d)); /* * * cbrt(1.0) = 1.000000000000000 * cbrt(2.0) = 1.259921049894873 * cbrt(3.0) = 1.442249570307408 * cbrt(4.0) = 1.587401051968200 * cbrt(0.0) = 0.000000000000000 * cbrt(INFINITY) = inf * cbrt(-INFINITY) = -inf * cbrt(NAN) = nan * */ |
Fortran interface:
REAL(8) :: X = 3.0
PRINT*, CBRT(X)
!
! OUTPUT
! 1.442249570307408
!
Parent topic: Power and Root Functions