# Vector distance

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

Compute the Euclidean, Manhattan, or Chebyshev distance between two equal-length finite-number vectors.

**Use when you need to: vector distance · euclidean distance · manhattan distance.**

## Supported

- vector distance
- euclidean distance
- manhattan distance
- chebyshev distance

## Not supported

- vectors of different lengths
- Minkowski distance with arbitrary p
- geographic/geodesic distance

## 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 metric selects euclidean (default, L2 of the difference), manhattan (L1 of the difference), or chebyshev (L-infinity of the difference).
- Computed with IEEE-754 double-precision arithmetic; the euclidean metric uses Math.sqrt and is rounded to double precision, not exact.
- The result is always non-negative; -0 is normalized to 0.

## Input

- `a` (array of number, required): min items 1; max items 64
- `b` (array of number, required): min items 1; max items 64
- `metric` (one of "euclidean", "manhattan", "chebyshev", optional)

## Output

- `result` (number, required)

## Limits

- max dim: 64
- max abs value: 1000000

## Example

Request input:

```json
{
  "a": [
    0,
    0
  ],
  "b": [
    3,
    4
  ]
}
```

Response:

```json
{
  "result": {
    "result": 5
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "vector-distance",
  "version": "1.0.0",
  "input": {
    "a": [
      0,
      0
    ],
    "b": [
      3,
      4
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/vector-distance/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":[0,0],"b":[3,4]}'
```

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

### CLI

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

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

## Related tools

- [Vector norm](/tools/vector-norm): Compute the L1, L2 (Euclidean), or L-infinity (Chebyshev) norm of a finite-number vector.
- [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.
- [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 approx equal](/tools/vector-approx-equal): Compare two equal-length finite-number vectors for approximate equality within an absolute tolerance.
- [Vector cross](/tools/vector-cross): Compute the 3-dimensional cross product of two finite-number vectors.
