# Confused about op amp equation derivation

I'm studying op amps and I'm a bit stumped on a part of the derivation of the difference amplifier. In equation 4-1, I understand that $$\R_G\$$ and $$\R_F\$$ form a voltage divider that divides $$\ V_{REF} \$$ into the voltage at the non-inverting terminal ($$\ =V_+ \$$). I also understand $$\ V_+ \$$ is the input to an inverting amplifier circuit, hence the $$\ -V_{in}\frac{R_F}{R_G} \$$ term. However, I'm struggling to understand intuitively where the third term comes from:

$$\ (\frac{R_F+R_G}{R_G}) \$$

You didn't explain how 4-1 arrived. But 4-1 isn't at all intuitive. A much better way to see it is to require (obviously) that the (+) and (-) inputs to the opamp are equal to each other. Like this:

$$\frac{V_\text{OUT}\cdot R_\text{G}+V_\text{IN}\cdot R_\text{F}}{R_\text{F}+R_\text{G}}=V_\text{REF}\cdot \frac{R_\text{F}}{R_\text{F}+R_\text{G}}$$

The left side is the equation for the (-) input node. The right side is the equation for the (+) input node. Just set them equal to each other (on the assumption that the designer wasn't an idiot and didn't get the input nodes reversed.)

The denominators on both sides cancel, immediately, and the solution is:

$$V_\text{OUT}=\left(V_\text{REF}-V_\text{IN}\right)\cdot\frac{R_\text{F}}{R_\text{G}}$$

In case you are wondering (and you shouldn't be because it should be as automatic as breathing is to you), any pair of voltage sources separated by two resistors will have the middle node voltage determined by an expression of the exact same topology as the left side of the first equation.

To make this clear, examine:

simulate this circuit – Schematic created using CircuitLab

$$V=\frac{V_\text{A}\cdot R_\text{B}+V_\text{B}\cdot R_\text{A}}{R_\text{A}+R_\text{B}}$$

This always works. (You should memorize it.) Sometimes, one of the voltages (with reference to ground) is $$\0\:\text{V}\$$. In those cases, the above equation simplifies a bit. But it is otherwise something to memorize.

So the topology simplifies into the right side voltage divider topology when either one of the voltage sources is assigned the value zero. (In the right hand expression of the first equation, that source was "ground," which is why it looks simpler. But in reality it is the same, more general equation as on the left side -- just that on the right side one of the sources was zero.)

So the above approach is obvious and very easy to understand. It's just two pairs of voltage dividing resistor equations set equal to each other. You are just lucky that one of four sources is ground. There's nothing at all difficult to explain about it. All the questions about odd factors just disappear.

I'll be happy to explain the factor you mentioned the moment you provide us with the logical flow used to develop 4-1. (Barry already provided you with an explanation you may like, though.)

Applying superposition, set Vin = 0. Then Vref is first input to the voltage divider consisting of Rg and Rf which yields the first part of the term for Vout. Now the opamp is acting as a non-inverting amplifier for the divided term with a gain equal to (Rf + Rg)/Rg since with Vin=0, the left end of Rg is grounded. This gives the second part of the term for Vout.

The term that you are asking for, is the gain of the OpAmp when the input is applied to the non inverting terminal (given there is ground instead of Vin in your circuit). The voltage at the non inverting terminal of the OpAmp is Vref*(Rf/(Rf+Rg)). Now this voltage is amplified by ((Rf+Rg)/Rg) to get the output contribution of Vref . Similarly there is contribution of output from Vin which equals, Vin*(-Rf/Rg). Adding these two contributions (Superposition) you get the total output Voltage.