# Math Operations

This function block performs arithmetic on a selectable number of numeric inputs. Use it to combine measurements, compute ratios, totals, products or differences in simple visual workflows — no programming required.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Number` One or more numeric input sockets. The block starts with two numeric inputs by default and can be expanded up to 20 inputs using the control below.

Note: Unconnected input sockets are ignored when the block runs. Only connected numeric values are used in the calculation.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Number` The numeric result of the selected arithmetic operation applied to the provided inputs.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Input size` Choose how many numeric input sockets are available (2–20). The block will add or remove input sockets to match this setting.

`Select a method` Choose the arithmetic method to apply across provided inputs. Available methods: ADD, SUBTRACT, MULTIPLY, DIVIDE.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* The block reads all connected numeric inputs when it runs.
* It applies the chosen method across those values:
  * ADD: sums all inputs.
  * SUBTRACT: subtracts the sum of all following inputs from the first input.
  * MULTIPLY: multiplies all inputs together.
  * DIVIDE: performs sequential division starting from the first input by each following input.
* The computed single numeric result is presented on the output socket.

This block skips empty/unconnected sockets automatically so you can change how many inputs to use without reconfiguring connections.

## 🎯 Features <a href="#features" id="features"></a>

* Expandable input count (2–20) for flexible calculations.
* Simple UI controls to switch arithmetic method instantly.
* Ignores unconnected inputs to avoid errors when wiring dynamic systems.
* Designed for visual assembly with other measurement and logic blocks.

## 📝 Usage guide <a href="#usage" id="usage"></a>

1. Set `Input size` to the number of values you want to combine.
2. Connect numeric-producing blocks (sensors, counters, measurement outputs, manual inputs) to the numeric input sockets.
3. Choose the desired operation with `Select a method`.
4. Read the result from the output `Number` and feed it into downstream blocks (logging, thresholds, or actuators).

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Combine with `Number Input` when you need a manual value to be part of the calculation (for offsets or thresholds).
* Use with `Counter` or `Get Batch Size` to compute averages, rates, or ratios from counted values.
* Feed outputs from measurement blocks like `Measure Position Distance` or `Image Resolution and Channel Value` into this block to derive derived metrics (e.g., distance per pixel, normalized sizes).
* After a math operation, use `Round` or `Absolute` to format the result before display or logging.
* To compute element-wise or aggregated values from lists, pair with `Get Element` or batch-control blocks to extract individual numbers first.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If the output is unexpected, check that all required inputs are connected and contain numeric values (use `Number Input` or debug blocks to verify).
* For division, ensure none of the divisor inputs are zero to avoid invalid results.
* If you change `Input size` and get unexpected wiring, re-check connections — adding/removing sockets may shift input order.

Use this block to keep arithmetic simple and visual when building measurement or decision pipelines.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/data-logic/mathmetical-operations/math-operations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
