# Vector projection

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

Compute the vector projection of a finite-number vector onto another.

**Use when you need to: vector projection · project a vector onto another vector.**

## Supported

- vector projection
- project a vector onto another vector

## Not supported

- scalar projection only (this returns the full vector projection)
- projecting onto a zero vector

## Behavior

- Inputs a and onto are arrays of finite JSON numbers with the same length, from 1 to 64 entries, magnitude bounded to at most 1000000.
- The result is the vector projection proj_onto(a) = ((a . onto) / (onto . onto)) * onto, computed in IEEE-754 double precision.
- Optional input tolerance (default 1e-9, range 0 to 1) is the minimum value of (onto . onto) accepted; smaller values are rejected as projecting onto a zero (or effectively zero) vector.
- A result entry of -0 is normalized to 0.
- Every result entry is checked to be a finite number before it is returned; a non-finite intermediate is rejected as invalid input rather than silently serialized.

## Input

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

## Output

- `result` (array of number, required)

## Limits

- max dim: 64
- max abs value: 1000000

## Example

Request input:

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

Response:

```json
{
  "result": {
    "result": [
      3,
      0
    ]
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "vector-projection",
  "version": "1.0.0",
  "input": {
    "a": [
      3,
      4
    ],
    "onto": [
      1,
      0
    ]
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [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 scale](/tools/vector-scale): Multiply every entry of a finite-number vector by a scalar.
- [Vector subtract](/tools/vector-subtract): Subtract two equal-length finite-number vectors elementwise (a minus b).
- [Matrix determinant](/tools/matrix-determinant): Compute the determinant of a small square finite-number matrix.
- [Matrix inverse](/tools/matrix-inverse): Compute the inverse of a small square finite-number matrix.
- [Matrix scale](/tools/matrix-scale): Multiply every entry of a finite-number matrix by a scalar.
