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 64b(array of number, required): min items 1; max items 64metric(one of "euclidean", "manhattan", "chebyshev", optional)
Output
result(number, required)
Limits
- max dim: 64
- max abs value: 1000000
Example
Request input:
{
"a": [
0,
0
],
"b": [
3,
4
]
}
Response:
{
"result": {
"result": 5
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "vector-distance",
"version": "1.0.0",
"input": {
"a": [
0,
0
],
"b": [
3,
4
]
}
}
HTTP (no key)
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.
CLI
node cli.mjs run vector-distance 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Vector norm: Compute the L1, L2 (Euclidean), or L-infinity (Chebyshev) norm of a finite-number vector.
- Matrix vector multiply: Multiply an MxN finite-number matrix by a length-N finite-number vector, producing a length-M vector.
- Vector add: Add two equal-length finite-number vectors elementwise.
- Vector angle: Compute the angle in radians between two equal-length finite-number vectors.
- Vector approx equal: Compare two equal-length finite-number vectors for approximate equality within an absolute tolerance.
- Vector cross: Compute the 3-dimensional cross product of two finite-number vectors.