# Relationship between Frequency response, magnitude spectrum and gain

I have been reading quite a lot of DSP related materials online and offline (books etc.) lately. I come across the terms frequency response and gain. I have also noticed that both are expressed in dB.

I do understand the fact that expressing the magnitude spectrum in dB is more informative and intuitive and helps identify the presence of different frequencies. But as seen here (or here) and here, the plots basically have the same/identical parameters on X-axis as well as Y-axis i.e, its dB vs frequency. This makes me a bit confused.

What is the relationship between frequency response and gain. Are they the same thing? Are they used according to the context (in that case on what occasions it is apt to use either of them?)?

• I think it's an okay question (wouldn't suggest closing the question), but, networks_hermit, this is about very fundamental concepts and language regarding Linear System Theory, sometimes called Signals and Systems, that is a rung down on the Electrical Engineering curriculum. So consider inputting to a linear system a sinusoidal waveform... Apr 9, 2019 at 19:19

ok let me give you a practical (discrete-time) example.

Consider a system with input-output relation of the form $$y[n] = x[n] + 0.5 x[n-1] + 0.25 x[n-2]$$

This input-output relation satisfies linearity and time-invariance properties and hence defines an LTI (linear time invariant) system and therefore it has an impulse response $$h[n]$$ found to be : $$h[n] = \delta[n] + 0.5 \delta[n-1] + 0.25 \delta[n-2]$$

Which signifies an FIR (finite impulse response) filter. Now since the system has an impulse response, then taking its Fourier transform will give us the system's so called complex valued Frequency Response function, denoted as $$H(\omega)$$ :

$$H(\omega) = \sum_n h[n] e^{-j \omega n}$$

For the above system, the frequency response can be shown to be:

$$H(\omega) = 1 + 0.5 e^{-j \omega} + 0.25 e^{-j2\omega}$$

The magnitude of $$H(\omega)$$ signifies the (linear) gain that the LTI system applies to its input at the frequency $$\omega$$. For example, if $$|H(\omega)| = 0$$ the system completely attenuates the input at that frequency, or if $$H(\omega) = 1$$ the signal passes unaltered and if $$|H(\omega)| = 10$$ then the system applies a linear gain of $$10$$ which corresponds to a dB scale of $$20$$ at that frequency.

Let's find the magnitude of the frequency response $$H(\omega)$$ :

\begin{align} H(\omega) &= 1 + 0.5 e^{-j \omega} + 0.25 e^{-j2\omega} \\ &= 1 + 0.5 (\cos(\omega)-j\sin(\omega) ) + 0.25 (\cos(2\omega)-j\sin(2\omega) ) \\ &= [ 1 + 0.5 \cos(\omega) + 0.25 \cos(2\omega)] -j [0.5 \sin(\omega) + 0.25 \sin(2\omega) ] \\ &= A(\omega) - j B(\omega) \\ |H(\omega)| &= \sqrt{ A^2(\omega) + B^2(\omega) } \\ |H(\omega)| &= \sqrt{ [ 1 + 0.5 \cos(\omega) + 0.25 \cos(2\omega)]^2 + [0.5 \sin(\omega) + 0.25 \sin(2\omega) ]^2 } \\ \end{align}

with the help of a computer you can evaluate this frequency response magnitude at any frequency you want and compute the gain of that filter that it applies to any input frequency at that frequency. Below figure shows the Frequency Response magnitude of this system (evaluated and plotted using Matlab) As you can see, the gain is about $$1.8$$ at frequencies close to zero radian per sample, and the gain is about unity at frequencies close to $$0.5 \pi$$ radians per sample. Most often but not always, this gain is defined in terms of a dB (deci Bell) scale (instead of a linear one) using the formula:

$$\text{Gain_dB} = 20 \log_{10}( \text{Gain_linear}) = 20 \log_{10}( |H(\omega)|)$$

which is plotted in the figure below: AS you can see, at the frequency about $$0.5 \pi$$ radians per sample, where the linear gain is about $$1$$, the corresponding deciBell gain is about $$0$$ dB.