mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
1.4 KiB
1.4 KiB
| layout |
|---|
| default |
Function square #
Compute the square of a value, x * x.
For matrices, the function is evaluated element wise.
Syntax #
math.square(x)
Parameters #
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Fraction | Complex | Array | Matrix | Unit | Number for which to calculate the square |
Returns #
| Type | Description |
|---|---|
| number | BigNumber | Fraction | Complex | Array | Matrix | Unit | Squared value |
Examples #
math.square(2) // returns number 4
math.square(3) // returns number 9
math.pow(3, 2) // returns number 9
math.multiply(3, 3) // returns number 9
math.square([1, 2, 3, 4]) // returns Array [1, 4, 9, 16]