mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
1.7 KiB
1.7 KiB
| layout |
|---|
| default |
Function pow #
Calculates the power of x to y, x ^ y.
Matrix exponentiation is supported for square matrices x, and positive
integer exponents y.
For cubic roots of negative numbers, the function returns the principal
root by default. In order to let the function return the real root,
math.js can be configured with math.config({predictable: true}).
To retrieve all cubic roots of a value, use math.cbrt(x, true).
Syntax #
math.pow(x, y)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Complex | Array | Matrix | The base |
y |
number | BigNumber | Complex | The exponent |
Returns #
| Type | Description |
|---|---|
| number | BigNumber | Complex | Array | Matrix | The value of x to the power y |
Examples #
math.pow(2, 3) // returns number 8
const a = math.complex(2, 3)
math.pow(a, 2) // returns Complex -5 + 12i
const b = [[1, 2], [4, 3]]
math.pow(b, 2) // returns Array [[9, 8], [16, 17]]