add

x + y

add(x, y)

Try it yourself:

See also:

add(): Addition for Numbers, Units, and Collections

add() combines two or more compatible values. For ordinary numbers it performs familiar addition, but it is also valuable in programmatic expressions because it makes the operation explicit and composes naturally with other functions. For example, add(2, 3) returns 5.

Compatible inputs matter

Values must be mathematically compatible. Numbers can be added directly; compatible units can be converted and summed; and matrices generally require matching dimensions for element-wise addition. Adding incompatible dimensions, such as a length and a time, should be treated as an error rather than silently coerced.

Use subtract() to express a difference, multiply() for scaling, and sum() to aggregate a collection. For vectors and matrices, dot() is a different operation: it produces an inner product rather than a component-by-component sum.

Practical calculations

In a budget, add can combine expenses after bringing them to the same currency. In geometry, it can combine coordinate offsets. In a spreadsheet-like calculation, explicit add calls make nested formula order easy to read: add(base, multiply(rate, quantity)).

Floating-point arithmetic may show tiny rounding residues, so use round() when presenting monetary or measured results, not prematurely during intermediate calculations. Addition is associative in exact mathematics, but finite precision means that summing very differently sized values can slightly depend on order.

Try Add in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions