1 |
|
2 |
|
3 | # Function cbrt
|
4 |
|
5 | Calculate the cubic root of a value.
|
6 |
|
7 | For matrices, the function is evaluated element wise.
|
8 |
|
9 |
|
10 | ## Syntax
|
11 |
|
12 | ```js
|
13 | math.cbrt(x)
|
14 | math.cbrt(x, allRoots)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | number | BigNumber | Complex | Unit | Array | Matrix | Value for which to calculate the cubic root.
|
22 | `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.
|
23 |
|
24 | ### Returns
|
25 |
|
26 | Type | Description
|
27 | ---- | -----------
|
28 | number | BigNumber | Complex | Unit | Array | Matrix | Returns the cubic root of `x`
|
29 |
|
30 |
|
31 | ## Examples
|
32 |
|
33 | ```js
|
34 | math.cbrt(27) // returns 3
|
35 | math.cube(3) // returns 27
|
36 | math.cbrt(-64) // returns -4
|
37 | math.cbrt(math.unit('27 m^3')) // returns Unit 3 m
|
38 | math.cbrt([27, 64, 125]) // returns [3, 4, 5]
|
39 |
|
40 | const x = math.complex('8i')
|
41 | math.cbrt(x) // returns Complex 1.7320508075689 + i
|
42 | math.cbrt(x, true) // returns Matrix [
|
43 | // 1.7320508075689 + i
|
44 | // -1.7320508075689 + i
|
45 | // -2i
|
46 | // ]
|
47 | ```
|
48 |
|
49 |
|
50 | ## See also
|
51 |
|
52 | [square](square.md),
|
53 | [sqrt](sqrt.md),
|
54 | [cube](cube.md)
|