UNPKG

1.36 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function multiply
4
5Multiply two or more values, `x * y`.
6For matrices, the matrix product is calculated.
7
8
9## Syntax
10
11```js
12math.multiply(x, y)
13math.multiply(x, y, z, ...)
14```
15
16### Parameters
17
18Parameter | Type | Description
19--------- | ---- | -----------
20`x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix | First value to multiply
21`y` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix | Second value to multiply
22
23### Returns
24
25Type | Description
26---- | -----------
27number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix | Multiplication of `x` and `y`
28
29
30## Examples
31
32```js
33math.multiply(4, 5.2) // returns number 20.8
34math.multiply(2, 3, 4) // returns number 24
35
36const a = math.complex(2, 3)
37const b = math.complex(4, 1)
38math.multiply(a, b) // returns Complex 5 + 14i
39
40const c = [[1, 2], [4, 3]]
41const d = [[1, 2, 3], [3, -4, 7]]
42math.multiply(c, d) // returns Array [[7, -6, 17], [13, -4, 33]]
43
44const e = math.unit('2.1 km')
45math.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)