The cbrt()
function in NumPy computes the cube root of each element in an input array.
numpy.cbrt(x, /, out=None, *, where=True)
The cbrt()
function takes the following parameter values:
x
: This represents the input array of values. This is a required parameter.out
: This represents the location where the result is stored. This is an optional parameter. where
: This is the condition over which the input is being broadcast. At a given location where this condition is True
, the resulting array will be set to the ufunc
result. Otherwise, the resulting array retains its original value.**kwargs
: This represents other keyword arguments. This is an optional parameter. The cbrt()
function returns an array of the same shape as the input array passed to it. This array holds the cube root values of the input array's elements.
import numpy as np# creating an input array of complex valuesx = np.array([1, 8, 27, 64, 125])# implementing the cbrt() functionmyarray = np.cbrt(x)print(x)print(myarray)
numpy
module.x
, using the array()
function.cbrt()
function on the input array. We assign the result to a variable, myarray
.x
.myarray
variable.