# Op-Amp Gain Calculator

> Computes the voltage gain (as a ratio and in dB) of the four basic operational-amplifier circuits from the feedback and input resistors, and optionally the output voltage for a given input, clipped to the supply rails.

- Calculator id: `op-amp-gain` · Category: Engineering & Automotive (`engineering`) · Tool name: `calculate_op_amp_gain`
- Canonical page: https://tttkmbb.com/engineering/op-amp-gain · This document: https://tttkmbb.com/engineering/op-amp-gain.md · JSON definition: https://tttkmbb.com/engineering/op-amp-gain.json

## Purpose

Computes the voltage gain (as a ratio and in dB) of the four basic operational-amplifier circuits from the feedback and input resistors, and optionally the output voltage for a given input, clipped to the supply rails.

**Use when:** You are designing or checking an op-amp stage and need the gain from resistor values, the resistor ratio for a target gain, or the expected output voltage and whether it will saturate.

**Do not use when:** Frequency response, bandwidth or slew-rate limits matter (this is the ideal DC gain), the circuit is a filter, integrator or instrumentation amplifier, or you only need a passive divider (use voltage-divider).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `configuration` | enum: inverting \| non_inverting \| voltage_follower \| differential |  | required | Basic op-amp circuit topology. |
| `feedback_resistor_ohms` | number | Ω | optional | Resistor from the output to the inverting input, in ohms (1 kΩ = 1000). Not needed for the voltage follower. (> 0, max 1000000000000) |
| `input_resistor_ohms` | number | Ω | optional | Resistor from the signal source (inverting) or from the inverting input to ground (non-inverting), in ohms. Not needed for the voltage follower. (> 0, max 1000000000000) |
| `input_voltage_v` | number | V | optional | Optional input voltage (V1 for the differential amplifier); enables the output-voltage result. (min -10000, max 10000) |
| `second_input_voltage_v` | number | V | optional | Differential amplifier only: voltage at the non-inverting side; output = gain × (V2 − input_voltage_v). (min -10000, max 10000) |
| `supply_voltage_v` | number | V | optional | Optional symmetric supply magnitude; the output is limited to ±supply_voltage_v (ideal rail-to-rail swing). (> 0, max 1000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `voltage_gain` | number |  | Closed-loop gain A = Vout / Vin (negative for the inverting amplifier). |
| `gain_db` | number | dB | 20 × log10 \|A\|. |
| `output_voltage_v` | number | V | A × input (or A × (V2 − V1)), clipped to ±supply_voltage_v when a supply is given; only when input_voltage_v is given. |
| `output_clipped` | boolean |  | True when the ideal output exceeded the supply rails and was limited (only when input and supply are given). |
| `input_impedance_note` | string |  | What impedance the signal source sees in this configuration. |
| `phase_inversion` | boolean |  | True when the output is inverted relative to the input (inverting amplifier). |
| `formula_used` | string |  | Gain expression for the chosen configuration. |

## Formula

`inverting: voltage_gain = −feedback_resistor_ohms / input_resistor_ohms; non_inverting: voltage_gain = 1 + feedback_resistor_ohms / input_resistor_ohms; voltage_follower: voltage_gain = 1; differential (matched resistor pairs): output_voltage_v = feedback_resistor_ohms / input_resistor_ohms × (second_input_voltage_v − input_voltage_v); gain_db = 20 × log10 |voltage_gain|; output_voltage_v = voltage_gain × input_voltage_v limited to ±supply_voltage_v`

Ideal op-amp model (infinite open-loop gain and input impedance, zero output impedance), valid while the closed-loop gain is far below the open-loop gain at the signal frequency. Real op-amps swing 1–2 V less than the rails unless rail-to-rail types are used, and the differential amplifier needs R1 = R2 and R3 = R4 for full common-mode rejection.

## Data Sources

- Wikipedia – Operational amplifier applications — https://en.wikipedia.org/wiki/Operational_amplifier_applications (reference, retrieved 2026-09-24)
- Wikipedia – Operational amplifier — https://en.wikipedia.org/wiki/Operational_amplifier (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/op-amp-gain?configuration=…`
- `POST https://tttkmbb.com/api/v1/calculate/op-amp-gain` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/op-amp-gain · OpenAPI operationId `calculate_op_amp_gain` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "op-amp-gain", "inputs": {…}}`

## Example

- Non-inverting, Rf 100 kΩ, Rin 10 kΩ, 0.5 V in, ±12 V supply: inputs `{"configuration":"non_inverting","feedback_resistor_ohms":100000,"input_resistor_ohms":10000,"input_voltage_v":0.5,"supply_voltage_v":12}` → `{"voltage_gain":11,"gain_db":20.83,"output_voltage_v":5.5,"output_clipped":false,"phase_inversion":false}`
- Inverting, Rf 100 kΩ, Rin 10 kΩ, 0.5 V in: inputs `{"configuration":"inverting","feedback_resistor_ohms":100000,"input_resistor_ohms":10000,"input_voltage_v":0.5}` → `{"voltage_gain":-10,"gain_db":20,"output_voltage_v":-5,"phase_inversion":true}`

```
GET https://tttkmbb.com/api/v1/calculate/op-amp-gain?configuration=non_inverting&feedback_resistor_ohms=100000&input_resistor_ohms=10000&input_voltage_v=0.5&supply_voltage_v=12
```

## Limitations

Frequency response, bandwidth or slew-rate limits matter (this is the ideal DC gain), the circuit is a filter, integrator or instrumentation amplifier, or you only need a passive divider (use voltage-divider). Ideal op-amp model (infinite open-loop gain and input impedance, zero output impedance), valid while the closed-loop gain is far below the open-loop gain at the signal frequency. Real op-amps swing 1–2 V less than the rails unless rail-to-rail types are used, and the differential amplifier needs R1 = R2 and R3 = R4 for full common-mode rejection. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why is the non-inverting gain never below 1?**

The feedback network divides the output before comparing it with the input, so the output must be at least as large as the input; an inverting stage or a passive divider is needed for attenuation.

**What happens when the output exceeds the supply?**

The op-amp saturates near its rail and the signal is clipped; with supply_voltage_v given, the calculator limits the output to ±supply and sets output_clipped.

**How is the differential amplifier wired?**

V1 through Rin to the inverting input with Rf as feedback; V2 through an equal Rin to the non-inverting input with an equal Rf to ground. The output is Rf/Rin × (V2 − V1), and mismatched resistors reduce common-mode rejection.

## Related

- [Voltage Divider Calculator](https://tttkmbb.com/engineering/voltage-divider.md) — Passive attenuation with two resistors.
- [Decibel Calculator](https://tttkmbb.com/engineering/decibel.md) — Convert the gain between ratio and dB.
- [Resistors in Series and Parallel Calculator](https://tttkmbb.com/physics/resistors-series-parallel.md) — Build non-standard Rf or Rin values from standard resistors.
