Rate This Document
Findability
Accuracy
Completeness
Readability

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

  • For cbrtf, x is of single-precision floating-point type.
  • For cbrt and cbrt_18, x is of double-precision floating-point type.
  • For cbrtl, x is of long double-precision floating-point type.

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.

Dependency

C: "km.h"

Examples

C interface:
    // typical usage 
    double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0; 
    // special handing 
    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
    !