# subtract() Function & Examples

Use the subtract() operators function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## subtract

#### x - y

#### subtract(x, y)

Try it yourself:

```calculio
a = 5.3 - 2
a + 2
2/3 - 1/6
2 * 3 - 3
2.1 km - 500m
```

[add](https://calcul.io/function/add/index.md)

---

## subtract(): calculate a difference

**subtract(a, b)** returns a minus b. It works with ordinary numbers and, where shapes and units are compatible, with matrices and quantities.

## Examples and order

`subtract(10, 3)` is 7, while reversing the inputs gives −7. This order matters: subtraction is not commutative.

## Related operations

Use [add()](https://calcul.io/function/add/index.md) for accumulation, [unaryMinus()](https://calcul.io/function/unaryMinus/index.md) to negate a value, and [abs()](https://calcul.io/function/abs/index.md) for an unsigned difference. [compare()](https://calcul.io/function/compare/index.md) answers ordering directly; [multiply()](https://calcul.io/function/multiply/index.md) supports scaling.

## Caveat

Match units and matrix dimensions before subtracting. Close floating-point results may need a tolerance rather than exact zero testing.

[All functions](https://calcul.io/functions/index.md)
