1 |
|
2 |
|
3 | # Function divide
|
4 |
|
5 | Divide two values, `x / y`.
|
6 | To divide matrices, `x` is multiplied with the inverse of `y`: `x * inv(y)`.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.divide(x, y)
|
13 | ```
|
14 |
|
15 | ### Parameters
|
16 |
|
17 | Parameter | Type | Description
|
18 | --------- | ---- | -----------
|
19 | `x` | number | BigNumber | Fraction | Complex | Unit | Array | Matrix | Numerator
|
20 | `y` | number | BigNumber | Fraction | Complex | Array | Matrix | Denominator
|
21 |
|
22 | ### Returns
|
23 |
|
24 | Type | Description
|
25 | ---- | -----------
|
26 | number | BigNumber | Fraction | Complex | Unit | Array | Matrix | Quotient, `x / y`
|
27 |
|
28 |
|
29 | ## Examples
|
30 |
|
31 | ```js
|
32 | math.divide(2, 3) // returns number 0.6666666666666666
|
33 |
|
34 | const a = math.complex(5, 14)
|
35 | const b = math.complex(4, 1)
|
36 | math.divide(a, b) // returns Complex 2 + 3i
|
37 |
|
38 | const c = [[7, -6], [13, -4]]
|
39 | const d = [[1, 2], [4, 3]]
|
40 | math.divide(c, d) // returns Array [[-9, 4], [-11, 6]]
|
41 |
|
42 | const e = math.unit('18 km')
|
43 | math.divide(e, 4.5) // returns Unit 4 km
|
44 | ```
|
45 |
|
46 |
|
47 | ## See also
|
48 |
|
49 | [multiply](multiply.md)
|