> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spojit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Math Tools

> Calculate expressions, round numbers, statistics, and currency formatting.

The Math Tools connector provides mathematical operations including expression evaluation, rounding, statistics, and number formatting.

<Note>No connection required; this utility connector works out of the box.</Note>

## Tools

<AccordionGroup>
  <Accordion title="calculate: Evaluate math expression">
    Evaluate mathematical expressions with support for variables.

    <ParamField body="expression" type="string" required>
      Math expression (e.g., `2 + 3 * 4`, `sqrt(16)`, `price * quantity`).
    </ParamField>

    <ParamField body="variables" type="object">
      Variables for the expression (e.g., `{"price": 9.99, "quantity": 3}`).
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "expression": "price * quantity * (1 - discount)",
      "variables": { "price": 49.99, "quantity": 3, "discount": 0.1 }
    }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 134.973 }
    ```
  </Accordion>

  <Accordion title="round: Round to decimal places">
    <ParamField body="number" type="number" required>
      Number to round.
    </ParamField>

    <ParamField body="decimals" type="number" default="0">
      Decimal places.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": 134.973, "decimals": 2 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 134.97 }
    ```
  </Accordion>

  <Accordion title="floor: Round down">
    <ParamField body="number" type="number" required>
      Number to round down.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": 7.89 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 7 }
    ```
  </Accordion>

  <Accordion title="ceil: Round up">
    <ParamField body="number" type="number" required>
      Number to round up.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": 7.01 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 8 }
    ```
  </Accordion>

  <Accordion title="random: Generate random number">
    <ParamField body="min" type="number" default="0">
      Minimum value.
    </ParamField>

    <ParamField body="max" type="number" default="1">
      Maximum value.
    </ParamField>

    <ParamField body="integer" type="boolean" default="false">
      Generate an integer.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "min": 1, "max": 100, "integer": true }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 42 }
    ```
  </Accordion>

  <Accordion title="min: Find minimum">
    <ParamField body="numbers" type="number[]" required>
      Array of numbers.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "numbers": [14, 7, 23, 3, 19] }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 3 }
    ```
  </Accordion>

  <Accordion title="max: Find maximum">
    <ParamField body="numbers" type="number[]" required>
      Array of numbers.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "numbers": [14, 7, 23, 3, 19] }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 23 }
    ```
  </Accordion>

  <Accordion title="sum: Sum numbers">
    <ParamField body="numbers" type="number[]" required>
      Array of numbers.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "numbers": [10.5, 20.3, 15.2, 8.0] }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 54 }
    ```
  </Accordion>

  <Accordion title="average: Calculate mean">
    <ParamField body="numbers" type="number[]" required>
      Array of numbers.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "numbers": [85, 92, 78, 95, 88] }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 87.6 }
    ```
  </Accordion>

  <Accordion title="median: Calculate median">
    <ParamField body="numbers" type="number[]" required>
      Array of numbers.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "numbers": [12, 47, 23, 8, 35] }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 23 }
    ```
  </Accordion>

  <Accordion title="std-dev: Standard deviation">
    <ParamField body="numbers" type="number[]" required>
      Array of numbers.
    </ParamField>

    <ParamField body="population" type="boolean" default="false">
      Use population formula (instead of sample).
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "numbers": [10, 12, 23, 23, 16, 23, 21, 16], "population": true }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 4.898979485566356 }
    ```
  </Accordion>

  <Accordion title="percentage: Calculate percentage">
    <ParamField body="value" type="number" required>
      The value.
    </ParamField>

    <ParamField body="total" type="number" required>
      The total.
    </ParamField>

    <ParamField body="decimals" type="number" default="2">
      Decimal places.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "value": 347, "total": 1200, "decimals": 1 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 28.9, "formatted": "28.9" }
    ```
  </Accordion>

  <Accordion title="abs: Absolute value">
    <ParamField body="number" type="number" required>
      Number.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": -42.5 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 42.5 }
    ```
  </Accordion>

  <Accordion title="power: Raise to power">
    <ParamField body="base" type="number" required>
      Base number.
    </ParamField>

    <ParamField body="exponent" type="number" required>
      Exponent.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "base": 2, "exponent": 10 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 1024 }
    ```
  </Accordion>

  <Accordion title="sqrt: Square root">
    <ParamField body="number" type="number" required>
      Number (must be non-negative).
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": 144 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 12 }
    ```
  </Accordion>

  <Accordion title="modulo: Get remainder">
    <ParamField body="dividend" type="number" required>
      Dividend.
    </ParamField>

    <ParamField body="divisor" type="number" required>
      Divisor.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "dividend": 17, "divisor": 5 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": 2 }
    ```
  </Accordion>

  <Accordion title="format: Format number">
    Format a number with locale-specific formatting.

    <ParamField body="number" type="number" required>
      Number to format.
    </ParamField>

    <ParamField body="locale" type="string" default="en-US">
      Locale code.
    </ParamField>

    <ParamField body="decimals" type="number">
      Fixed decimal places.
    </ParamField>

    <ParamField body="useGrouping" type="boolean" default="true">
      Use thousand separators.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": 1548923.5, "locale": "de-DE", "decimals": 2 }
    ```

    **Example response:**

    ```json theme={null}
    { "result": "1.548.923,50" }
    ```
  </Accordion>

  <Accordion title="currency: Format as currency">
    <ParamField body="number" type="number" required>
      Amount.
    </ParamField>

    <ParamField body="currency" type="string" default="USD">
      Currency code (e.g., `USD`, `EUR`, `GBP`).
    </ParamField>

    <ParamField body="locale" type="string" default="en-US">
      Locale code.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "number": 1299.99, "currency": "EUR", "locale": "de-DE" }
    ```

    **Example response:**

    ```json theme={null}
    { "result": "1.299,99 €" }
    ```
  </Accordion>
</AccordionGroup>
