UNPKG

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