2014-01-31 19:55:47 +01:00

1012 B

Function add

Add two values. Matrices are evaluated element wise.

Syntax

math.add(x, y)

Parameters

Parameter Type Description
x Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix Value to add y to
y Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix Value to be added to x

Returns

Type Description
Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix Sum of x and y

Examples

math.add(2, 3);               // returns Number 5

var a = math.complex(2, 3);
var b = math.complex(-4, 1);
math.add(a, b);               // returns Complex -2 + 2i

math.add([1, 2, 3], 4);       // returns Array [5, 6, 7]

var c = math.unit('5 cm');
var d = math.unit('2.1 mm');
math.add(c, d);               // returns Unit 52.1 mm