UNPKG

1.16 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function subtract
4
5Subtract two values, `x - y`.
6For matrices, the function is evaluated element wise.
7
8
9## Syntax
10
11```js
12math.subtract(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 | Initial value
20`y` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix | Value to subtract from `x`
21
22### Returns
23
24Type | Description
25---- | -----------
26number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix | Subtraction of `x` and `y`
27
28
29## Examples
30
31```js
32math.subtract(5.3, 2) // returns number 3.3
33
34const a = math.complex(2, 3)
35const b = math.complex(4, 1)
36math.subtract(a, b) // returns Complex -2 + 2i
37
38math.subtract([5, 7, 4], 4) // returns Array [1, 3, 0]
39
40const c = math.unit('2.1 km')
41const d = math.unit('500m')
42math.subtract(c, d) // returns Unit 1.6 km
43```
44
45
46## See also
47
48[add](add.md)