Analyze a Unique Inverting Op Amp: An Op Amp Subtractor
There’s a special op amp circuit —a differential amplifier, or subtractor — that is actually a combination of a noninverting amplifier and inverting amplifier. A differential amplifier multiplies the difference between two voltages.
Here is an op amp subtractor.
You use superposition to determine the input and the output relationship. The superposition technique involves the following steps:

Turn on one source and turn off the others.

Determine the output of the source that’s on.

Repeat for each input, taking the sources one at a time.

Algebraically add up all the output contributions for each input to get the total output.
For sample circuit, first turn off voltage source v_{S}_{2} so that there’s no input at the noninverting terminal (v_{P} = 0). With the noninverting input grounded, the circuit acts like an inverting amplifier. You wind up with output contribution v_{O}_{1} due to v_{S}_{1}:
You next turn off voltage source v_{S}_{1} (v_{N} = 0) and turn v_{S}_{2} back on. The circuit now acts like a noninverting amplifier. Because this is an ideal op amp, no current (i_{P} = 0) is drawn from the series connection of resistors R_{3} and R_{4}, so you can use the voltage divider equation to determine v_{P}. The voltage at the noninverting input is given by
The noninverting input v_{P} is amplified to give you an output v_{O}_{2}:
You then add up the outputs v_{O}_{1} and v_{O}_{2} to get the total output voltage:
Here, –G_{1} is the inverting gain and G_{2} is the noninverting gain. You need the following constraint to form a subtractor:
Applying the constraint simplifies the output voltage, giving you
There you have it! You now have the output proportional to the difference between the two inputs.