1 |
|
2 |
|
3 | # Function square
|
4 |
|
5 | Compute the square of a value, `x * x`.
|
6 | For matrices, the function is evaluated element wise.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.square(x)
|
13 | ```
|
14 |
|
15 | ### Parameters
|
16 |
|
17 | Parameter | Type | Description
|
18 | --------- | ---- | -----------
|
19 | `x` | number | BigNumber | Fraction | Complex | Array | Matrix | Unit | Number for which to calculate the square
|
20 |
|
21 | ### Returns
|
22 |
|
23 | Type | Description
|
24 | ---- | -----------
|
25 | number | BigNumber | Fraction | Complex | Array | Matrix | Unit | Squared value
|
26 |
|
27 |
|
28 | ## Examples
|
29 |
|
30 | ```js
|
31 | math.square(2) // returns number 4
|
32 | math.square(3) // returns number 9
|
33 | math.pow(3, 2) // returns number 9
|
34 | math.multiply(3, 3) // returns number 9
|
35 |
|
36 | math.square([1, 2, 3, 4]) // returns Array [1, 4, 9, 16]
|
37 | ```
|
38 |
|
39 |
|
40 | ## See also
|
41 |
|
42 | [multiply](multiply.md),
|
43 | [cube](cube.md),
|
44 | [sqrt](sqrt.md),
|
45 | [pow](pow.md)
|