How cbrt() Works in PostgreSQL

In PostgreSQL, the cbrt() function returns the cube root of its argument.

The cube root of a number x is a number y such that y3 = x.

Syntax

The syntax is quite simple:

cbrt(dp)

Where dp is a double precision value.

Example 1

Here’s an example to demonstrate its usage.

SELECT cbrt(27);

Result:

3

Example 2

You can pass expressions such as the following.

SELECT cbrt(20 + 7);

Result:

3

Example 3

Here’s another quick example that demonstrates how it works.

SELECT 
  (4 * 4 * 4),
  cbrt(4 * 4 * 4),
  cbrt(64);

Result:

 ?column? | cbrt | cbrt
----------+------+------
       64 |    4 |    4

Example 4

Here’s one that results in fractional seconds being returned.

SELECT cbrt(32);

Result:

3.174802103936399

Example 5

Here’s one where I include fractional seconds in the argument.

SELECT cbrt(0.123456);

Result:

0.4979327984674048