# Matrix identity

`matrix-identity` · version 1.0.0 · Vectors & matrices · free, no key needed

Construct the NxN identity matrix for a given size.

**Use when you need to: identity matrix · construct an identity matrix.**

## Supported

- identity matrix
- construct an identity matrix

## Not supported

- non-square diagonal matrices with custom diagonal values
- matrices larger than 20x20

## Behavior

- Input size is an integer from 1 to 20.
- The result is the NxN identity matrix: result[r][c] = 1 when r === c, otherwise 0, where N is size. Values are exact integers, not subject to floating-point rounding.

## Input

- `size` (integer, required): min 1; max 20

## Output

- `result` (array of array of number, required)

## Limits

- max dim: 20

## Example

Request input:

```json
{
  "size": 3
}
```

Response:

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

## How to call it

### MCP

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

```json
{
  "id": "matrix-identity",
  "version": "1.0.0",
  "input": {
    "size": 3
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/matrix-identity/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"size":3}'
```

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

### CLI

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

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

## Related tools

- [Matrix add](/tools/matrix-add): Add two equal-shape finite-number matrices elementwise.
- [Matrix determinant](/tools/matrix-determinant): Compute the determinant of a small square finite-number matrix.
- [Matrix hadamard](/tools/matrix-hadamard): Multiply two equal-shape finite-number matrices elementwise (Hadamard product).
- [Matrix inverse](/tools/matrix-inverse): Compute the inverse of a small square finite-number matrix.
- [Matrix multiply](/tools/matrix-multiply): Multiply an MxK finite-number matrix by a KxN finite-number matrix, producing an MxN matrix.
- [Matrix rank](/tools/matrix-rank): Compute the numerical rank of a finite-number matrix (square or rectangular).
