mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
1.0 KiB
1.0 KiB
Function pow
Calculates the power of x to y, x ^ y.
Matrix exponentiation is supported for square matrices x, and positive
integer exponents y.
Syntax
math.pow(x, y)
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
Number | BigNumber | Boolean | Complex | Array | Matrix | null | The base |
y |
Number | BigNumber | Boolean | Complex | null | 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
var a = math.complex(2, 3);
math.pow(a, 2) // returns Complex -5 + 12i
var b = [[1, 2], [4, 3]];
math.pow(b, 2); // returns Array [[9, 8], [16, 17]]