Vector norm
vector-norm · version 1.0.0 · Vectors & matrices · free, no key needed
Compute the L1, L2 (Euclidean), or L-infinity (Chebyshev) norm of a finite-number vector.
Use when you need to: vector norm · vector magnitude · euclidean length.
Supported
- vector norm
- vector magnitude
- euclidean length
- L1 norm
- L2 norm
- infinity norm
Not supported
- general p-norms for non-integer or fractional p
- matrix norms (use matrix-frobenius-norm-style tools)
Behavior
- Input vector is an array of 1 to 64 finite JSON numbers, each bounded to at most 1000000 in magnitude.
- Optional input p selects the norm: 1 for the L1 (sum of absolute values) norm, 2 (default) for the Euclidean norm, or the string "inf" for the L-infinity (maximum absolute value) norm.
- The L2 norm uses Math.sqrt over an IEEE-754 double-precision sum of squares; results for irrational magnitudes are rounded to double precision, not exact.
- The result is always non-negative; -0 is normalized to 0.
Input
vector(array of number, required): min items 1; max items 64p(one of 1, 2 or one of "inf", optional)
Output
result(number, required)
Limits
- max dim: 64
- max abs value: 1000000
Example
Request input:
{
"vector": [
3,
4
]
}
Response:
{
"result": {
"result": 5
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "vector-norm",
"version": "1.0.0",
"input": {
"vector": [
3,
4
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/vector-norm/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"vector":[3,4]}'
The machine-readable contract is at /v1/tools/vector-norm/versions/1.0.0.
CLI
node cli.mjs run vector-norm 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Vector distance: Compute the Euclidean, Manhattan, or Chebyshev distance between two equal-length finite-number vectors.
- Vector normalize: Scale a finite-number vector to unit Euclidean length.
- 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.