math.cbrt(x) returns the real cube root of x as a float. Unlike square roots, every negative real number has a real cube root, so math.cbrt(-27) returns -3.0 without raising an error.
Using fractional power syntax like (-27) ** (1 / 3) returns a complex number, and math.pow(-27, 1/3) raises ValueError, making math.cbrt() cleaner and more accurate.
math.cbrt() is a function in Python's standard math module: import it with import math and call math.cbrt(...), or import the name directly with from math import cbrt. Added in Python 3.11.
Syntax
Import math and pass any real number (Python 3.11+).
python
import math
side = math.cbrt(volume)
Call
What it does
math.cbrt(27)
Returns 3.0.
math.cbrt(-8)
Returns -2.0 (handles negative inputs directly).
math.cbrt(0.125)
Returns 0.5.
math.cbrt(2)
Returns approximately 1.2599....
Requires Python 3.11 or newer; check hasattr(math, "cbrt") if your code must run on older Python releases.
Function signatures
python
math.cbrt(x, /)
# added in Python 3.11; returns real cube root as float
Parameters
Parameter
Description
x
Required positional real number (int or float), positive, zero, or negative.
Return Value
Return Value
Description
float
Real cube root of x. Preserves -0.0, inf, -inf, and nan.
Python Examples
Example 1 — Find Edge Lengths From Cubic Volumes
Compute edge lengths for positive and negative cubic offsets using math.cbrt() (Python 3.11+).
python
import math
volumes = [1, 27, 125, -64, 0.125]
for vol in volumes:
edge = math.cbrt(vol)
print(f"volume={vol} -> edge={edge}")