mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif
55 lines (37 loc) • 1.54 kB
Markdown
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
Calculate the cubic root of a value.
For matrices, the function is evaluated element wise.
```js
math.cbrt(x)
math.cbrt(x, allRoots)
```
Parameter | Type | Description
--------- | ---- | -----------
`x` | number &
`allRoots` | boolean | Optional, false by default. Only applicable when `x` is a number or complex number. If true, all complex roots are returned, if false (default) the principal root is returned.
### Returns
Type | Description
---- | -----------
number | BigNumber &
```js
math.cbrt(27) // returns 3
math.cube(3) // returns 27
math.cbrt(-64) // returns -4
math.cbrt(math.unit('27 m^3')) // returns Unit 3 m
math.cbrt([27, 64, 125]) // returns [3, 4, 5]
const x = math.complex('8i')
math.cbrt(x) // returns Complex 1.7320508075689 + i
math.cbrt(x, true) // returns Matrix [
// 1.7320508075689 + i
// -1.7320508075689 + i
// -2i
// ]
```
[ ](square.md),
[ ](sqrt.md),
[ ](cube.md)