NumPy Tutorial NumPy Statistics NumPy References

NumPy - cbrt() function



The NumPy cbrt() function is used to calculate the cube root of the given number.

Syntax

numpy.cbrt(a, out=None)

Parameters

a Required. Specify array (array_like) containing elements, of which the cube root is calculated.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns the cube root of each element of a.

Example:

In the example below, numpy cbrt() function is used to calculate the cube root of each element present in array Arr.

import numpy as np

Arr = np.array([1, 8, 27, 64, 125])

print("The cube root of values:")
print(np.cbrt(Arr))

The output of the above code will be:

The cube root of values:
[ 1.  2.  3.  4.  5.]

❮ NumPy - Functions