Function cbrt #

Calculate the cubic root of a value.

To avoid confusion with the matrix cube root, this function does not apply to matrices. For a matrix, to take the cube root elementwise, see the examples.

Syntax #

math.cbrt(x)
math.cbrt(x, allRoots)

Parameters #

Parameter Type Description
x number | BigNumber | Complex | Unit Value for which to calculate the cubic root.
allRoots boolean Optional, false by default. Only applicable when x is a number or complex number. If true, all complex roots are returned, if false (default) the principal root is returned.

Returns #

Type Description
number | BigNumber | Complex | Unit Returns the cubic root of x

Throws #

Type | Description —- | ———–

Examples #

math.cbrt(27)                  // returns 3
math.cube(3)                   // returns 27
math.cbrt(-64)                 // returns -4
math.cbrt(math.unit('27 m^3')) // returns Unit 3 m
math.map([27, 64, 125], x => math.cbrt(x))       // returns [3, 4, 5]

const x = math.complex('8i')
math.cbrt(x)                   // returns Complex 1.7320508075689 + i
math.cbrt(x, true)             // returns Matrix [
                                //    1.7320508075689 + i
                                //   -1.7320508075689 + i
                                //   -2i
                                // ]

See also #

square, sqrt, cube

Fork me on GitHub