# Ideal gas state solve

`ideal-gas-state-solve` · version 1.0.0 · Units & sizes · free, no key needed

Solve one missing ideal-gas state variable from exact decimal SI inputs using the pinned 2019 SI gas constant.

**Use when you need to: solve ideal gas pressure · compute ideal gas volume · calculate amount of ideal gas.**

## Decide before calling

Read the [versioned contract](/v1/tools/ideal-gas-state-solve/versions/1.0.0) and the supported scope below. Reuse `ideal-gas-state-solve@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `ideal-gas-state-solve@1.0.0` for solve ideal gas pressure. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- solve ideal gas pressure
- compute ideal gas volume
- calculate amount of ideal gas
- find ideal gas temperature
- solve PV equals nRT
- ideal gas state calculation

## Not supported

- apply a real gas equation of state
- convert non-SI customary units

## Behavior

- Exactly the variable named by solve_for must be omitted; the other three state quantities must be present and positive.
- R is pinned to 8.31446261815324 Pa m3 mol^-1 K^-1; supported units convert exactly to SI.
- result is the exact reduced rational and an 18-significant-digit decimal rounded to nearest, ties to even.

## Input

- `solve_for` (one of "pressure", "volume", "amount", "temperature", required)
- `pressure` (object, optional)
- `volume` (object, optional)
- `amount` (object, optional)
- `temperature` (object, optional)

## Output

- `solve_for` (one of "pressure", "volume", "amount", "temperature", required)
- `value` (string, required): min length 1
- `unit` (one of "Pa", "m3", "mol", "K", required)
- `exact_fraction` (object, required)
- `gas_constant` (constant "8.31446261815324", required)

## Limits

- max input bytes: 1024
- max decimal chars: 64
- max decimal digits: 50
- max decimal scale: 24

## Example

Request input:

```json
{
  "solve_for": "pressure",
  "volume": {
    "value": "1",
    "unit": "m3"
  },
  "amount": {
    "value": "1",
    "unit": "mol"
  },
  "temperature": {
    "value": "1",
    "unit": "K"
  }
}
```

Response:

```json
{
  "result": {
    "solve_for": "pressure",
    "value": "8.31446261815324",
    "unit": "Pa",
    "exact_fraction": {
      "numerator": "207861565453831",
      "denominator": "25000000000000"
    },
    "gas_constant": "8.31446261815324"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "ideal-gas-state-solve",
  "version": "1.0.0",
  "input": {
    "solve_for": "pressure",
    "volume": {
      "value": "1",
      "unit": "m3"
    },
    "amount": {
      "value": "1",
      "unit": "mol"
    },
    "temperature": {
      "value": "1",
      "unit": "K"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/ideal-gas-state-solve/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"solve_for":"pressure","volume":{"value":"1","unit":"m3"},"amount":{"value":"1","unit":"mol"},"temperature":{"value":"1","unit":"K"}}'
```

The machine-readable contract is at [/v1/tools/ideal-gas-state-solve/versions/1.0.0](/v1/tools/ideal-gas-state-solve/versions/1.0.0).

### CLI

```sh
node cli.mjs run ideal-gas-state-solve 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Pressure unit convert](/tools/pressure-unit-convert): Convert exact decimal pressure values among seven units and return a reduced exact fraction.
- [Temperature compare](/tools/temperature-compare): Compare two temperatures in C, F, or K by converting both to Kelvin rationals.
- [Temperature convert](/tools/temperature-convert): Convert a decimal temperature between Celsius, Fahrenheit, and Kelvin as an exact rational.
- [Volume unit convert](/tools/volume-unit-convert): Convert exact decimal volumes among SI, cubic, US liquid, and imperial units with explicit half-even rounding.
- [Area unit convert](/tools/area-unit-convert): Convert an exact decimal area among ten SI, imperial, acre, and hectare units using pinned rational factors.
- [Byte size add](/tools/bytesize-add): Add non-negative integer byte-size terms in mixed IEC units and return the exact sum in a chosen unit.
