UNPKG

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