r8_cube_root <- function ( x ) #*****************************************************************************80 # ## r8_cube_root() returns the cube root of an R8. # # Discussion: # # This routine is designed to avoid the possible problems that can occur # when formulas like 0.0^(1/3) or (-1.0)^(1/3) are to be evaluated. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 12 May 2021 # # Author: # # John Burkardt # # Input: # # real X, the number whose cube root is desired. # # Output: # # real VALUE, the cube root of X. # { xnrm = abs ( x ) if ( x < 0.0 ) { s = -1.0 } else { s = +1.0 } p = 1.0 / 3.0 value = s * ( xnrm ^ p ) return ( value ) }