1 |
|
2 |
|
3 | # Function multiply
|
4 |
|
5 | Multiply two or more values, `x * y`.
|
6 | For matrices, the matrix product is calculated.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.multiply(x, y)
|
13 | math.multiply(x, y, z, ...)
|
14 | ```
|
15 |
|
16 | ### Parameters
|
17 |
|
18 | Parameter | Type | Description
|
19 | --------- | ---- | -----------
|
20 | `x` | number | BigNumber | Fraction | Complex | Unit | Array | Matrix | First value to multiply
|
21 | `y` | number | BigNumber | Fraction | Complex | Unit | Array | Matrix | Second value to multiply
|
22 |
|
23 | ### Returns
|
24 |
|
25 | Type | Description
|
26 | ---- | -----------
|
27 | number | BigNumber | Fraction | Complex | Unit | Array | Matrix | Multiplication of `x` and `y`
|
28 |
|
29 |
|
30 | ## Examples
|
31 |
|
32 | ```js
|
33 | math.multiply(4, 5.2) // returns number 20.8
|
34 | math.multiply(2, 3, 4) // returns number 24
|
35 |
|
36 | const a = math.complex(2, 3)
|
37 | const b = math.complex(4, 1)
|
38 | math.multiply(a, b) // returns Complex 5 + 14i
|
39 |
|
40 | const c = [[1, 2], [4, 3]]
|
41 | const d = [[1, 2, 3], [3, -4, 7]]
|
42 | math.multiply(c, d) // returns Array [[7, -6, 17], [13, -4, 33]]
|
43 |
|
44 | const e = math.unit('2.1 km')
|
45 | math.multiply(3, e) // returns Unit 6.3 km
|
46 | ```
|
47 |
|
48 |
|
49 | ## See also
|
50 |
|
51 | [divide](divide.md),
|
52 | [prod](prod.md),
|
53 | [cross](cross.md),
|
54 | [dot](dot.md)
|