My amplifier produced a negative gain when it should be positive. Why?
The term "negative gain" is reserved for those cases where the line has a downward slope and so reverses the polarity of the signal (a 180° phase change). A op-amp in an inverting configuration is a prime example.

What you have is an attenuating amplifier; the signal out has a somewhat decreased amplitude from the signal coming in but not a different sign. (I'm ignoring the offset of the sloped line in order to keep it simple)

The relation of the voltage-over-voltage gain (V/V) to dB gain often confuses people since the dB measurement actually strips out the "inverting" property of negative-gain amplifiers (since you take the log of the absolute value of the gain). Let's set up fours scenarios for different line slopes (V/V gain):


Gain: 2 V/V or 20*log(|2|) = 6 dB and 0° phase difference
Gain: 0.5 V/V or 20*log(|0.5|) = -6 dB and 0° phase difference
Gain: -0.5 V/V or 20*log(|-0.5|) = -6 dB and 180° phase difference
Gain: -2 V/V or 20*log(|-2|) = 6 dB and 180° phase difference


Scenarios 1 and 2 have a positive slope/gain and thereby a 0° phase difference while scenarios 3 and 4 have negative gain (signal inverting) and thereby a 180° phase difference. Scenarios 2 and 3 have a gain who's absolute value is less than one and thereby are attenuating amplifiers, expressed by a negative dB gain, while scenarios 1 and 4 are "amplifying amplifiers".

The Wikipedia page on Gain might explain it better then I can.

The purpose of an amplifier isn't always to increase the voltage amplitude of a signal being passed through. It might for example be used to drive a current-hungry device when the source signal/device can't, like loudspeaker power amplifiers do.