# Rational add

`rational-add` · version 1.0.0 · Numbers & math · free, no key needed

Add two rational numbers given as numerator/denominator integer strings and return the reduced sum.

**Use when you need to: rational add · add two rational numbers · add fractions as rationals.**

## Supported

- rational add
- add two rational numbers
- add fractions as rationals
- sum two rationals

## Not supported

- rational multiply
- decimal add
- float addition
- mixed numbers
- continued fractions
- IEEE-754 arithmetic

## Behavior

- Each operand is an object with canonical integer-string numerator and denominator fields.
- The denominator must be a positive canonical integer; zero and negative denominators are rejected.
- Inputs may use -0, which is canonicalized to 0; every other integer must match 0 or -?[1-9][0-9]*.
- The sum is (a.numerator * b.denominator + b.numerator * a.denominator) / (a.denominator * b.denominator).
- The result is reduced by gcd, with the sign only on the numerator; 0 is numerator 0 over denominator 1.
- Input, intermediate, and output numerators and denominators may have at most 1000 digits excluding sign.

## Input

- `a` (object, required)
- `b` (object, required)

## Output

- `numerator` (string, required)
- `denominator` (string, required)

## Limits

- max digits: 1000

## Example

Request input:

```json
{
  "a": {
    "numerator": "1",
    "denominator": "2"
  },
  "b": {
    "numerator": "1",
    "denominator": "3"
  }
}
```

Response:

```json
{
  "result": {
    "numerator": "5",
    "denominator": "6"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "rational-add",
  "version": "1.0.0",
  "input": {
    "a": {
      "numerator": "1",
      "denominator": "2"
    },
    "b": {
      "numerator": "1",
      "denominator": "3"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/rational-add/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"a":{"numerator":"1","denominator":"2"},"b":{"numerator":"1","denominator":"3"}}'
```

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

### CLI

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

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

## Related tools

- [Array rational sum](/tools/array-rational-sum): Sum an array of canonical rationals and return the reduced total.
- [Rational compare](/tools/rational-compare): Compare two rational numbers given as numerator/denominator integer strings by exact value.
- [Rational multiply](/tools/rational-multiply): Multiply two rational numbers given as numerator/denominator integer strings and return the reduced product.
- [Rational subtract](/tools/rational-subtract): Subtract one rational number from another, given as numerator/denominator integer strings, and return the reduced difference.
- [Array rational mean](/tools/array-rational-mean): Return the reduced arithmetic mean of an array of canonical rationals.
- [Array rational min max](/tools/array-rational-min-max): Return the reduced numeric minimum and maximum of an array of canonical rationals.
