Python numpy cube root numpy.cbrt()
In this post, you will learn about the Python numpy cube root. The numpy.cbrt() is a function in the NumPy library that computes the cube root of each element in an array.
The syntax for using numpy.cbrt() in Python is straightforward.
numpy.cbrt(x)
Here, x is the input value(s). This can be a single number, a list, or a NumPy array. It returns an array of the same shape as x, containing the cube roots of the elements in x.
Python numpy.cbrt() example
Here's a basic example:
import numpy as np
# Single number
x = 27
cube_root_x = np.cbrt(x)
print(cube_root_x)
# Array of numbers
array_numbers = np.array([1, 8, 27, 64, 125])
cube_roots_array = np.cbrt(array_numbers)
print(cube_roots_array)
Output of the above code:
3.0000000000000004
[1. 2. 3. 4. 5.]
Related Articles
Trigonometric functions Python Numpy
Python convert dataframe to numpy array
Convert binary to decimal in Python
Multiply all elements in list Python
Multiply each element of a list by a number in Python
Python NumPy: Overview and Examples
Convert Python list to numpy array
numpy dot product
Python Pandas Plotting
Pandas string to datetime
Convert Excel to CSV Python Pandas
Python take screenshot of specific window
Read data from excel file using Python Pandas
Quick Introduction to Python Pandas
Python requests GET method
Python Convert XML to CSV
Python iterate list with index
Python add list to list
Python random choice
Python dict inside list
Bouncing ball game code in Python
Remove character from string Python
Python raise keyword