# Apply a maths function

Shape / columns

numeric functions: arithmetic, rounding, trigonometry

Page: <https://meridian.online/operations/apply-a-maths-function>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

numeric functions

It reads the `orders` table the proofs share. Create it first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT amount, round(ln(amount), 3) AS ln_amount, sqrt(amount) AS root, amount % 7 AS mod7 FROM orders WHERE amount > 0;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT max(ln_amount) FILTER (WHERE amount = 120) = 4.787 AND max(mod7) FILTER (WHERE amount = 120) = 1 AND abs(max(root * root) FILTER (WHERE amount = 300) - 300) < 1e-9 FROM result)) THEN 'as expected' ELSE error('a logarithm, a root or a remainder is wrong') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## Variants

- [Add, subtract, multiply or divide](https://meridian.online/operations/apply-a-maths-function/add-subtract-multiply-or-divide): Combine numbers with arithmetic operators such as plus, minus, times, divide and remainder.
- [Operate on bits](https://meridian.online/operations/apply-a-maths-function/operate-on-bits): Apply bitwise AND, OR, XOR, NOT or shifts to integers.
- Apply a numeric function: Compute a logarithm, power, root, absolute value, trigonometric or other scalar function of a number in each row.
- [Round or limit numbers](https://meridian.online/operations/apply-a-maths-function/round-or-limit-numbers): Round to decimal places or significant figures, round up or down, or clip values to a lower and upper bound.
- Find the largest or total across columns: Return the maximum, minimum, sum or mean of several columns within each row.
- [Do arithmetic that tolerates nulls and zeros](https://meridian.online/operations/apply-a-maths-function/null-safe-arithmetic): Add or subtract with nulls treated as zero, or divide with null returned when the denominator is zero.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Azure Data Factory: [`Math functions`](https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions) (read 2026-09-27)
- Bruin: [`bruin.degrees_to_radians(degrees)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- Bruin: [`bruin.safe_add(fields)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- Bruin: [`bruin.safe_divide(numerator, denominator)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- Bruin: [`bruin.safe_subtract(fields)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- Apache DataFusion: [`Bitwise Operators`](https://datafusion.apache.org/user-guide/sql/operators.html) (read 2026-09-27)
- Apache DataFusion: [`Math Functions`](https://datafusion.apache.org/user-guide/sql/scalar_functions.html) (read 2026-09-27)
- Apache DataFusion: [`Numerical Operators`](https://datafusion.apache.org/user-guide/sql/operators.html) (read 2026-09-27)
- dbt-utils: [`safe_add`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- dbt-utils: [`safe_divide`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- dbt-utils: [`safe_subtract`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- DuckDB: [`Numeric Functions (family)`](https://duckdb.org/docs/current/sql/functions/numeric) (read 2026-09-27)
- Duckle: [`Absolute`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Clamp`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Logarithm`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Modulo`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Power`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Round`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Sign`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Square Root`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- AWS Glue: [`IsEven`](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-pyspark-transforms-IsEven.html) (read 2026-09-27)
- Ibis: [`Abs`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Acos`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Add`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Asin`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Atan`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Atan2`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BaseConvert`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BitwiseAnd`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BitwiseLeftShift`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BitwiseNot`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BitwiseOr`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BitwiseRightShift`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`BitwiseXor`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Ceil`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Clip`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Cos`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Cot`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Degrees`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Divide`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`E`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`Exp`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Floor`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`FloorDivide`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Greatest`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`IsInf`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`IsNan`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Least`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`Ln`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Log`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Log10`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Log2`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Modulus`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Multiply`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Negate`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Pi`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`Power`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Radians`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`RandomScalar`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`Round`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Sign`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Sin`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Sqrt`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Subtract`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Tan`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- Ibis: [`Tanh`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/numeric.py) (read 2026-09-27)
- KNIME Analytics Platform: [`Math Formula`](https://api.hub.knime.com/nodes/*2fI5rIsFDCFPHc0R?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Math Formula (Multi Column)`](https://api.hub.knime.com/nodes/*JMp9oaI_oEgkz6gh?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Number Rounder`](https://api.hub.knime.com/nodes/*pUuELUhDh08r8wjt?details=full) (read 2026-09-27)
- mlpack: [`Math`](https://www.mlpack.org/doc/user/core.html) (read 2026-09-27)
- Apache NiFi: [`Math Functions`](https://nifi.apache.org/nifi-docs/record-path-guide.html) (read 2026-09-27)
- Apache NiFi: [`Mathematical Operations and Numeric Manipulation`](https://nifi.apache.org/nifi-docs/expression-language-guide.html) (read 2026-09-27)
- OpenRefine: [`Math functions`](https://openrefine.org/docs/manual/grelfunctions#math-functions) (read 2026-09-27)
- Polars: [`DataFrame.max_horizontal`](https://docs.pola.rs/api/python/stable/reference/dataframe/aggregation.html) (read 2026-09-27)
- Polars: [`DataFrame.mean_horizontal`](https://docs.pola.rs/api/python/stable/reference/dataframe/aggregation.html) (read 2026-09-27)
- Polars: [`DataFrame.min_horizontal`](https://docs.pola.rs/api/python/stable/reference/dataframe/aggregation.html) (read 2026-09-27)
- Polars: [`DataFrame.sum_horizontal`](https://docs.pola.rs/api/python/stable/reference/dataframe/aggregation.html) (read 2026-09-27)
- Polars: [`Expr computation: mathematical functions (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/computation.html) (read 2026-09-27)
- Polars: [`Expr manipulation/selection: rounding and bounds (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- Polars: [`Expr operators: numeric (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/operators.html) (read 2026-09-27)
- Polars: [`Functions: horizontal aggregations (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/functions.html) (read 2026-09-27)
- Polars: [`Functions: two-argument arctangent (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/functions.html) (read 2026-09-27)
- Polars: [`SQL functions: Bitwise (group)`](https://docs.pola.rs/api/python/stable/reference/sql/functions/bitwise.html) (read 2026-09-27)
- Polars: [`SQL functions: Math (group)`](https://docs.pola.rs/api/python/stable/reference/sql/functions/math.html) (read 2026-09-27)
- Polars: [`SQL functions: Trigonometry (group)`](https://docs.pola.rs/api/python/stable/reference/sql/functions/trigonometry.html) (read 2026-09-27)
- Power Query M: [`Number functions`](https://learn.microsoft.com/en-us/powerquery-m/number-functions) (read 2026-09-27)
- RapidMiner Studio: [`Add Noise`](https://docs.rapidminer.com/latest/studio/operators/utility/random_data_generation/add_noise.html) (read 2026-09-27)
- RapidMiner Studio: [`Generate Absolutes`](https://docs.rapidminer.com/latest/studio/operators/blending/attributes/generation/generate_absolutes.html) (read 2026-09-27)
- RapidMiner Studio: [`Generate Gaussians`](https://docs.rapidminer.com/latest/studio/operators/blending/attributes/generation/generate_gaussians.html) (read 2026-09-27)
- RapidMiner Studio: [`Generate Products`](https://docs.rapidminer.com/latest/studio/operators/blending/attributes/generation/generate_products.html) (read 2026-09-27)
- Apache SeaTunnel: [`Numeric Functions`](https://seatunnel.apache.org/docs/2.3.13/transforms/sql-functions) (read 2026-09-27)
- SQLMesh: [`@SAFE_ADD`](https://github.com/SQLMesh/sqlmesh/blob/23b237cea7218cc8f338b89c14f0957394a0003b/docs/concepts/macros/sqlmesh_macros.md) (read 2026-09-27)
- SQLMesh: [`@SAFE_DIV`](https://github.com/SQLMesh/sqlmesh/blob/23b237cea7218cc8f338b89c14f0957394a0003b/docs/concepts/macros/sqlmesh_macros.md) (read 2026-09-27)
- SQLMesh: [`@SAFE_SUB`](https://github.com/SQLMesh/sqlmesh/blob/23b237cea7218cc8f338b89c14f0957394a0003b/docs/concepts/macros/sqlmesh_macros.md) (read 2026-09-27)
- subtoken: [`array_cross_product`](https://duckdb.org/docs/current/sql/functions/array.html) (read 2026-09-27)
- Tableau Prep: [`Number functions (group)`](https://help.tableau.com/current/prep/en-us/prep_function_reference.htm) (read 2026-09-27)
- Trifacta: [`Math Functions (group)`](https://help.alteryx.com/aac/en/trifacta-classic/wrangle-language/math-functions.html) (read 2026-09-27)
- Trifacta: [`Numeric Operators`](https://help.alteryx.com/aac/en/trifacta-classic/wrangle-language/math-functions/numeric-operators.html) (read 2026-09-27)
- Trifacta: [`Trigonometry Functions (group)`](https://help.alteryx.com/aac/en/trifacta-classic/wrangle-language/trigonometry-functions.html) (read 2026-09-27)
