# Rational power

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

Raise a rational number to an integer exponent and return the exact reduced result.

**Use when you need to: rational power · rational exponentiation · raise a fraction to an integer power.**

## Supported

- rational power
- rational exponentiation
- raise a fraction to an integer power
- integer power of a rational

## Not supported

- rational exponent
- fractional exponent
- nth root
- floating-point power

## Behavior

- base is an object with canonical integer-string numerator and denominator fields; denominator must be a positive canonical integer.
- exponent is a JSON integer from -1000 to 1000 inclusive.
- base^0 is 1/1 for every base, including base 0/1 (0^0 is defined as 1 by this contract).
- A negative exponent requires a non-zero base numerator; base 0 with a negative exponent is rejected as undefined.
- The result is computed by exact exponentiation by squaring and reduced by gcd, sign only on the numerator.
- Every intermediate and the final numerator and denominator may have at most 1000 digits excluding sign.

## Input

- `base` (object, required)
- `exponent` (integer, required): min -1000; max 1000

## Output

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

## Limits

- max digits: 1000
- max abs exponent: 1000

## Example

Request input:

```json
{
  "base": {
    "numerator": "2",
    "denominator": "3"
  },
  "exponent": 3
}
```

Response:

```json
{
  "result": {
    "numerator": "8",
    "denominator": "27"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "rational-power",
  "version": "1.0.0",
  "input": {
    "base": {
      "numerator": "2",
      "denominator": "3"
    },
    "exponent": 3
  }
}
```

### HTTP (no key)

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

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

### CLI

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

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

## Related tools

- [Array integer GCD](/tools/array-integer-gcd): Compute the non-negative greatest common divisor of an array of canonical integer strings.
- [Array integer LCM](/tools/array-integer-lcm): Compute the non-negative least common multiple of an array of canonical integer strings.
- [Array rational sum](/tools/array-rational-sum): Sum an array of canonical rationals and return the reduced total.
- [Rational reciprocal](/tools/rational-reciprocal): Invert a rational number given as a numerator/denominator integer-string pair.
- [Array integer median](/tools/array-integer-median): Select lower and upper middle canonical integers; emit median only for odd length.
- [Array rational mean](/tools/array-rational-mean): Return the reduced arithmetic mean of an array of canonical rationals.
