Qu

cbrt

Builtin index · Core maths

result = cbrt(x)

Input: x · Output: result

What it is

Real cube root, elementwise — unlike x^(1/3), correctly handles a negative x (cbrt(-8) = -2, not NaN). x is a scalar, Vec, or Mat/Signal.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = cbrt(x)
x scalar, Vec, Mat, or Signalnot documented yet
result —
Returns exactly the same type and shape as x.

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.

How it works

cbrt(x): unlike x^(1/3) (or Rust's own x.powf(1.0/3.0), which is NaN for negative x -- there is no real branch cut to pick a real cube root from a fractional power), f64::cbrt is defined for the whole real line and gets the sign right (cbrt(-8) = -2, not a complex value). That correctness for negative input is the entire reason this exists as its own builtin rather than reusing ^.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.