# Vector approx equal

`vector-approx-equal` · version 1.0.0 · Vectors & matrices · free, no key needed

Compare two equal-length finite-number vectors for approximate equality within an absolute tolerance.

**Use when you need to: vector approximate equality · compare vectors within tolerance · floating-point vector equality.**

## Supported

- vector approximate equality
- compare vectors within tolerance
- floating-point vector equality

## Not supported

- vectors of different lengths
- relative (percentage) tolerance
- exact bitwise equality

## Behavior

- Inputs a and b are arrays of finite JSON numbers with the same length, from 1 to 64 entries, magnitude bounded to at most 1000000.
- Optional input tolerance (default 1e-9, range 0 to 1) is an absolute per-entry threshold.
- max_absolute_difference is max(|a[i] - b[i]|) across all entries, computed in IEEE-754 double precision.
- equal is true exactly when max_absolute_difference is less than or equal to tolerance.

## Input

- `a` (array of number, required): min items 1; max items 64
- `b` (array of number, required): min items 1; max items 64
- `tolerance` (number, optional): min 0; max 1

## Output

- `equal` (boolean, required)
- `max_absolute_difference` (number, required)

## Limits

- max dim: 64
- max abs value: 1000000

## Example

Request input:

```json
{
  "a": [
    1,
    2,
    3
  ],
  "b": [
    1,
    2,
    3.5
  ],
  "tolerance": 1
}
```

Response:

```json
{
  "result": {
    "equal": true,
    "max_absolute_difference": 0.5
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "vector-approx-equal",
  "version": "1.0.0",
  "input": {
    "a": [
      1,
      2,
      3
    ],
    "b": [
      1,
      2,
      3.5
    ],
    "tolerance": 1
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/vector-approx-equal/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":[1,2,3],"b":[1,2,3.5],"tolerance":1}'
```

The machine-readable contract is at [/v1/tools/vector-approx-equal/versions/1.0.0](/v1/tools/vector-approx-equal/versions/1.0.0).

### CLI

```sh
node cli.mjs run vector-approx-equal 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Vector add](/tools/vector-add): Add two equal-length finite-number vectors elementwise.
- [Vector angle](/tools/vector-angle): Compute the angle in radians between two equal-length finite-number vectors.
- [Vector dot](/tools/vector-dot): Compute the dot (scalar) product of two equal-length finite-number vectors.
- [Vector lerp](/tools/vector-lerp): Linearly interpolate (or extrapolate) between two equal-length finite-number vectors.
- [Vector outer product](/tools/vector-outer-product): Compute the outer product of two finite-number vectors, producing a matrix.
- [Matrix vector multiply](/tools/matrix-vector-multiply): Multiply an MxN finite-number matrix by a length-N finite-number vector, producing a length-M vector.
