---
title: The op-amp golden rules
heading: Two rules that solve almost every op-amp circuit
eyebrow: C6 · Lesson 18 · The op-amp golden rules
xp: 50
---

::: hook
An op amp is a differential amplifier with enormous gain, typically 100,000 or more, and inputs that draw almost no current. On its own it's almost useless: the tiniest input difference slams its output into a supply rail. Wrapped in negative feedback, it becomes the most versatile part in analog electronics, and analyzing it becomes nearly trivial, thanks to two rules.

::: play
- A non-inverting amplifier: the signal goes into the + input, and a divider feeds a fraction of the output back to the − input. The meters read both inputs and the output.
- Compare the two input voltages. How close are they?
- Change $R_f$. The output changes, but the difference between the inputs doesn't. What sets the gain?
:::
:::

```sim circuit
V1 in 0 sine 0.5 V 1k Hz    @ 0,2 down 2
U1 in m out                 @ 2,1 flip
RF m out 9k                 @ 2,-1 right 3
RG m 0 1k                   @ 2,-1 up 2
slider: RF 1k..100k log
scope: v(in), v(out)
time: 0..3m s
meter: v(in), v(m), v(out)
```

::: predict
## An op amp with negative feedback has 2.000 V on its + input. What's on its − input?

- [ ] 0 V
- [x] Very nearly 2.000 V
- [ ] It depends only on the output
- [ ] −2 V

::: reveal
Very nearly 2.000 V. With an open-loop gain of 100,000, any output within the supply rails needs an input difference of well under a millivolt. The feedback adjusts the output until the − input matches the + input. This "virtual short" is the second golden rule; it holds only while feedback is negative and the output isn't stuck at a rail.
:::
:::

::: nameit
## The golden rules

With negative feedback and an ideal op amp:

1. **No current flows into either input.**
2. **The output does whatever it takes to make the two inputs equal**: $v_+ = v_-$.

**Non-inverting amplifier.** Input to $+$; output divided by $R_f$ and $R_g$ back to $-$. Rule 2 puts $v_-$ at $v_\text{in}$, so the divider must have $v_\text{in}$ at its middle:

$$v_\text{out} = v_\text{in}\left(1 + \frac{R_f}{R_g}\right)$$

with a very high input impedance (rule 1).

**Voltage follower.** $R_f = 0$, $R_g$ removed: gain exactly 1. Its point is impedance: it reproduces a voltage from a weak source with the strength of the op amp's output, a **buffer**.

**Inverting amplifier.** $+$ grounded; input through $R_\text{in}$ to $-$; $R_f$ from output to $-$. Rule 2 holds the $-$ input at 0 V, a **virtual ground**, so the input current $v_\text{in}/R_\text{in}$ all flows on through $R_f$ (rule 1):

$$v_\text{out} = -\frac{R_f}{R_\text{in}}v_\text{in}$$

with an input impedance of exactly $R_\text{in}$.

**When the rules fail.** They assume the output can reach the needed voltage (it saturates near the supplies, lesson 35), that the frequency is low enough for the gain to still be huge, and that the feedback is negative. Without feedback, the op amp is a comparator (lesson 48).

**With finite gain A**, a non-inverting amplifier's gain is $A/(1 + A\beta)$ with $\beta = R_g/(R_f + R_g)$ (lesson 16).
:::


::: example
## A non-inverting amplifier has $R_f$ = 47 kΩ and $R_g$ = 10 kΩ. What does 0.5 V in give?

::: solution
1. **Gain.**
   $$\begin{aligned} G &= 1 + \frac{47}{10} \\ &= 5.7 \end{aligned}$$
2. **Output.**
   $$0.5\ \text{V} \times 5.7 = 2.85\ \text{V}$$
3. **Loading.** The input draws no current: the source sees the op amp's input resistance.

**Answer:** 0.5 V in gives 2.85 V out.
:::
:::

::: example
## An inverting amplifier with $R_\text{in}$ = 10 kΩ and $R_f$ = 100 kΩ uses an op amp with a gain of only 10⁴. How far is its gain from −10?

::: solution
1. **Gain with a finite op amp.**
   $$\begin{aligned} G &= \frac{-10}{1 + 11/10^4} \\ &= -9.989 \end{aligned}$$
2. **How far short.** It's 0.11% short, which is the noise gain, 11, divided by the open-loop gain.

**Answer:** the gain is −9.989, 0.11% short of −10.
:::
:::

::: example
## An op amp with a 1 MHz gain-bandwidth product is used as a non-inverting amplifier with gain 5.7, and as an inverting amplifier with gain −4.7 from the same resistors. What's each one's bandwidth?

::: solution
1. **Noise gain.** Both have the same feedback divider, so both have a noise gain of
   $$1 + \frac{R_f}{R_g} = 5.7$$
2. **Bandwidth.** The closed loop's bandwidth is the gain-bandwidth product over the noise gain:
   $$\begin{aligned} f_{-3\text{dB}} &= \frac{1\ \text{MHz}}{5.7} \\ &= 175\ \text{kHz} \end{aligned}$$
   for both.
3. **Why the inverting one matches.** Its signal gain is only 4.7, but its bandwidth is set by the loop, which sees the same β, so the bandwidth follows the noise gain.

**Answer:** both amplifiers have a bandwidth of 175 kHz.
:::
:::

::: check
given: Rf = 9 | 19 | 47 | 99; Rg = 1 | 2.2
answer: 1 + Rf/Rg
tolerance: 0.5%

## A non-inverting amplifier has $R_f$ = {Rf} kΩ and $R_g$ = {Rg} kΩ. What's its gain?

::: right
Right. $1 + R_f/R_g$ = {answer}.
:::

::: misses
- [Rf/Rg] Add 1: the output is divided down to equal the input.
- [-Rf/Rg] That's the inverting amplifier.
- [any] Not yet. $1 + R_f/R_g$.
:::
:::

::: check
given: Rf = 10 | 47 | 100; Rin = 1 | 4.7 | 10; vin = 0.1 | 0.2
answer: -Rf/Rin*vin
unit: V
tolerance: 0.5%

## An inverting amplifier has $R_\text{in}$ = {Rin} kΩ and $R_f$ = {Rf} kΩ. The input is {vin} V. What's the output?

::: right
Right. $-\frac{R_f}{R_\text{in}}v_\text{in}$ = {answer}.
:::

::: misses
- [Rf/Rin*vin] An inverting amplifier flips the sign.
- [-(1 + Rf/Rin)*vin] That's the non-inverting gain with a minus sign. Inverting is just $-R_f/R_\text{in}$.
- [any] Not yet. $v_\text{out} = -(R_f/R_\text{in})v_\text{in}$.
:::
:::

::: check
given: vin = 0.5 | 1 | 2; Rin = 1 | 10
answer: vin/Rin
unit: mA
tolerance: 0.5%

## In an inverting amplifier with $R_\text{in}$ = {Rin} kΩ, {vin} V is applied. What current flows through the feedback resistor?

::: right
Right. The virtual ground puts all of $v_\text{in}$ across $R_\text{in}$, and that current continues through $R_f$: {answer}.
:::

::: misses
- [0] No current flows into the op amp's input, so it must go through $R_f$.
- [any] Not yet. $i = v_\text{in}/R_\text{in}$.
:::
:::

::: check
given: A = 1000 | 10000; Rf = 9 | 99; Rg = 1
answer: A/(1 + A*Rg/(Rf + Rg))
tolerance: 0.1%

## An op amp with open-loop gain {A} is used as a non-inverting amplifier with $R_f$ = {Rf} kΩ and $R_g$ = 1 kΩ. What's the actual gain?

::: right
Right. $\frac{A}{1 + A\beta}$ with $\beta = R_g/(R_f + R_g)$: {answer}.
:::

::: misses
- [1 + Rf] That's the ideal gain; with finite A it's a little less.
- [any] Not yet. $G = A/(1 + A\beta)$.
:::
:::

::: check
kind: choice

## Why is a voltage follower (gain 1) useful?

- [ ] It doubles the signal
- [x] It copies a voltage from a high-impedance source while being able to drive a heavy load
- [ ] It inverts the signal
- [ ] It removes DC

::: right
Right. It draws nothing from the source and supplies the load from the op amp's output.
:::

::: misses
- [1] Its gain is exactly 1.
- [3] It doesn't invert.
- [4] It passes DC.
:::
:::

::: check
kind: parts
given: G = 1 | 3 | 10; f = 1 | 10 | 50; Rg = 1 | 10

## An op amp with a {f} MHz gain-bandwidth product has $R_g$ = {Rg} kΩ and $R_f$ = {G} × $R_g$.

::: part
answer: f*1000/(1 + G)
unit: kHz
tolerance: 0.5%

### What's the bandwidth as an inverting amplifier?

::: misses
- [f*1000/G] Bandwidth follows the noise gain, $1 + \frac{R_f}{R_g}$.
- [any] $\frac{\text{GBW}}{1 + R_f/R_g}$.
:::
:::

::: part
answer: f*1000/(1 + G)
unit: kHz
tolerance: 0.5%

### And as a non-inverting amplifier with the same resistors?

::: misses
- [any] The same noise gain gives the same bandwidth.
:::
:::
:::

::: check
kind: derivation
vars: A = 100..10000000, f = 1000..100000000, g = 0.1..1000

## An op amp with open-loop gain A and gain-bandwidth f is used inverting with $R_f/R_\text{in}$ = g.

::: step
answer: -g/(1 + (1 + g)/A)

### What's its closed-loop gain?
:::

::: step
answer: f/(1 + g)

### What's its bandwidth?
:::

::: right
Right. Both the gain error and the bandwidth go with the noise gain, 1 + g.
:::
:::

::: explain
## Why do the two inputs of an op amp with negative feedback sit at almost the same voltage?

::: model
The op amp's output is its enormous gain times the difference between its inputs. If the inputs differed by more than a tiny amount, the output would race toward a supply rail. But with negative feedback, that output change is fed back to the inverting input in the direction that reduces the difference. The circuit settles where the output is just right to make the difference tiny, the output divided by the gain, which for a gain of 100,000 is microvolts. In practice the two inputs are equal.
:::
:::

::: practice

::: check
given: Rf = 1 | 2 | 3; Rg = 1
answer: 1 + Rf
tolerance: 0.5%

## Non-inverting, $R_f$ = {Rf} kΩ, $R_g$ = 1 kΩ. Gain?

::: misses
- [Rf] Add 1.
- [any] $1 + R_f/R_g$.
:::
:::

::: check
given: Rf = 22 | 47; Rin = 2.2 | 4.7
answer: -Rf/Rin
tolerance: 0.5%

## Inverting, $R_f$ = {Rf} kΩ, $R_\text{in}$ = {Rin} kΩ. Gain?

::: misses
- [Rf/Rin] Inverting.
- [any] $-R_f/R_\text{in}$.
:::
:::

::: check
given: vp = 1 | 2.5 | 3.3
answer: vp
unit: V
tolerance: 0.5%

## An op amp with negative feedback has {vp} V on its + input. Its − input?

::: misses
- [0] That's only when + is grounded.
- [any] The same, by the virtual short.
:::
:::
:::
