UNPKG

1.33 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function pow
4
5Calculates the power of x to y, `x ^ y`.
6Matrix exponentiation is supported for square matrices `x`, and positive
7integer exponents `y`.
8
9For cubic roots of negative numbers, the function returns the principal
10root by default. In order to let the function return the real root,
11math.js can be configured with `math.config({predictable: true})`.
12To retrieve all cubic roots of a value, use `math.cbrt(x, true)`.
13
14
15## Syntax
16
17```js
18math.pow(x, y)
19```
20
21### Parameters
22
23Parameter | Type | Description
24--------- | ---- | -----------
25`x` | number &#124; BigNumber &#124; Complex &#124; Unit &#124; Array &#124; Matrix | The base
26`y` | number &#124; BigNumber &#124; Complex | The exponent
27
28### Returns
29
30Type | Description
31---- | -----------
32number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | The value of `x` to the power `y`
33
34
35## Examples
36
37```js
38math.pow(2, 3) // returns number 8
39
40const a = math.complex(2, 3)
41math.pow(a, 2) // returns Complex -5 + 12i
42
43const b = [[1, 2], [4, 3]]
44math.pow(b, 2) // returns Array [[9, 8], [16, 17]]
45```
46
47
48## See also
49
50[multiply](multiply.md),
51[sqrt](sqrt.md),
52[cbrt](cbrt.md),
53[nthRoot](nthRoot.md)