# Characterization of Systems in the Spectral Domain

*This Jupyter notebook is part of a [collection of notebooks](../index.ipynb) in the bachelors module Signals and Systems, Communications Engineering, Universität Rostock. Please direct questions and suggestions to [Sascha.Spors@uni-rostock.de](mailto:Sascha.Spors@uni-rostock.de).*

## Bode Plots

The Fourier domain transfer function $H(j \omega)$ characterizes the transmission properties of a linear time-incariant (LTI) system with respect to the [harmonic exponential signal](../continuous_signals/standard_signals.ipynb#Complex-Exponential-Signal) $e^{j \omega t}$ for the angular frequency $\omega = 2 \pi f$. In order to illustrate the characteristics of an LTI system, often the magnitude $| H(j \omega) |$ and phase $\varphi_H(j \omega)$ of the transfer function is regarded separately. Decomposing the output signal $Y(j \omega) = X(j \omega) \cdot H(j \omega)$ into its magnitude $| Y(j \omega) |$ and phase $\varphi_Y(j \omega)$ yields

\begin{align}
| Y(j \omega) | &= | X(j \omega) | \cdot | H(j \omega) | \\
\varphi_Y(j \omega) &= \varphi_X(j \omega) + \varphi_H(j \omega)
\end{align}

where $X(j \omega)$ denotes the input signal, and $| X(j \omega) |$ and $\varphi_X(j \omega)$ its magnitude and phase, respectively. It can be concluded from above equations, that the magnitude $| H(j \omega) |$ provides the frequency-dependent attenuation of the magnitude $| X(j \omega) |$ of the input signal by the system, while $\varphi_H(j \omega)$ provides the introduced phase-shift. 

A common graphical illustration of the sytem properties in terms of the magnitude and phase of the transfer function are [*bode plots*](https://en.wikipedia.org/wiki/Bode_plot). Here the logarithmic magnitude of the transfer function $20 \log_{10} | H(j \omega) |$ in [decibels](https://en.wikipedia.org/wiki/Decibel) is plotted against the logarithm of the frequency $\omega$ or $f$. The phase $\varphi_H(j \omega)$ is plotted linearly against the logarithm of the frequency. A transfer function $H(s)$ which is a rational function in $s$ can be represented [in terms of its poles and zeros](../laplace_transform/definition.ipynb#Representation). Applying this representation to the transfer function $H(j \omega)$ in the Fourier domain yields

\begin{equation}
H(j \omega) = K \cdot \frac{\prod_{\mu=0}^{Q} (j \omega - s_{0 \mu})}{\prod_{\nu=0}^{P} (j \omega - s_{\infty \nu})}
\end{equation}

where $s_{0 \mu}$ and $s_{\infty \nu}$ denote the $\mu$-th zero and $\nu$-th pole of $H(s)$, and $Q$ and $P$ the total number of zeros and poles, respectively. The logarithm of the magnitude and the phase can then be expressed as

\begin{align}
\log_{10} | H(j \omega) | &= \sum_{\mu=0}^{Q} \log_{10} |j \omega - s_{0 \mu}| - \sum_{\nu=0}^{P} \log_{10} |j \omega - s_{\infty \nu}| + \log_{10} |K|   \\
\varphi_H(j \omega) &= \sum_{\mu=0}^{Q} \arg (j \omega - s_{0 \mu}) - \sum_{\nu=0}^{P} \arg (j \omega - s_{\infty \nu})
\end{align}

where $\arg(\cdot)$ denotes the [argument](https://en.wikipedia.org/wiki/Argument_%28complex_analysis%29) (phase) of a complex function. It can be concluded from above result, that the individual contributions of the poles and zeros to the bode plot can be superimposed. This fact can be exploited to manually draw approximated bode plots illustrating the properties of an LTI system for a given set of poles and zeros. Rules for the asymptotic behavior of the magnitude and phase for single poles and zeros are available in the [literature](https://en.wikipedia.org/wiki/Bode_plot#Rules_for_handmade_Bode_plot). For instance it is stated that a single pole/zero results in a magnitude response in the bode plot that decreases/increases with a slope of 20 dB per decade. These rules provide insights into the influence of the location and order of poles and zeros on the properties of systems. They are of benefit when designing systems with given magnitude and phase properties.

**Example**

The bode plot of the [2nd order low-pass filter](../laplace_transform/network_analysis.ipynb#Example:-Second-Order-Low-Pass-Filter) is plotted. The transfer function $H(j \omega)$ of the low-pass filter can be derived from its Laplace domain counterpart $H(s)$ by

\begin{equation}
H(j \omega) = \frac{1}{C L s^2 + C R s + 1} \bigg\rvert_{s = j \omega}
\end{equation}


```python
%matplotlib inline
import sympy as sym
sym.init_printing()

w = sym.symbols('omega', real=True)
R, L, C = sym.symbols('R L C', positive=True)
s = sym.I * w

H = 1/(C*L*s**2 + C*R*s + 1)
H
```

The bode plot is generated for the normalized values $R = 1$, $L = 0.5$ and $C = 0.4$


```python
RLC = {R: 1, L: sym.Rational('.5'), C: sym.Rational('.4')}

sym.plot(20*sym.log(sym.Abs(H.subs(RLC)), 10), (w, 0.1, 10), xscale='log', xlabel='$\omega$', ylabel='$20 \log_{10} | H(j \omega) |$');
sym.plot(sym.arg(H.subs(RLC)), (w, 0.1, 10), xscale='log', xlabel='$\omega$', ylabel=r'$\varphi(j \omega)$');
```

**Example**

The bode plot of a second-order LTI system with the following transfer function

\begin{equation}
H(s) = \frac{(s - s_0)(s - s_0^*)}{(s - s_\infty)(s - s_\infty^*)}
\end{equation}

with 

\begin{align}
s_0 &= \sigma_0 + j \omega_0  &\text{with } \quad &\sigma_0 = 2000, \omega_0 = 2 \pi \cdot 100 \\
s_\infty  &= \sigma_\infty + j \omega_\infty & &\sigma_\infty = 20000, \omega_\infty = 2 \pi \cdot 4000
\end{align}

is constructed in this example. First the contribution of the zero $s_0$ to the magnitude of the transfer function $H(j \omega)$ is computed and plotted over the frequency $f$ using $\omega = 2 \pi f$.


```python
def db(x):
    return 20 * sym.log(sym.Abs(x), 10)
```


```python
f = sym.symbols('f', real=True)
s = sym.I * 2*sym.pi*f
s_0 = 2000 + sym.I * 2*sym.pi*100

H1 = (s - s_0)*(s - sym.conjugate(s_0))
Hlog1 = db(H1)

sym.plot(Hlog1, (f, 10, 10000), xscale='log', xlabel='$f$', ylabel='$20 \log_{10} |H_0(j \omega)|$ in dB');
```

Now the contribution of the pole $s_\infty$ is computed and plotted


```python
s_inf = 20000 + sym.I * 2*sym.pi*4000

H2 = 1/((s - s_inf)*(s - sym.conjugate(s_inf)))
Hlog2 = db(H2)
sym.plot(Hlog2, (f, 10, 20000), xscale='log', xlabel='$f$', ylabel='$20 \log_{10} |H_\infty(j \omega)|$ in dB');
```

The (logarithmic) magnitude frequency response of the system is given by superposition of the individual contributions from the zero and the pole


```python
Hlog = Hlog1 + Hlog2
sym.plot(Hlog, (f, 10, 50000), xscale='log', xlabel='$f$', ylabel='$20 \log_{10} |H(j \omega)|$ in dB');
```

**Exercise**

* Examine the bode plots for the contributions of the zero and the pole:
    * What regions show approximately linear behavior over the frequency $f$? 
    * What is the slope of these regions per octave/decade? 
    * At which frequency is the transition between the regions of linear behavior? How is the frequency related to the imaginary part of the zero/pole?

* Examine the bode plot of the system. How is it related to the bode plots of the individual zero/pole?

* Move the pole and/or zero closer to the imaginary axis by changing the values $\sigma_\infty$ and/or $\sigma_0$. What changes?

**Copyright**

The notebooks are provided as [Open Educational Resource](https://de.wikipedia.org/wiki/Open_Educational_Resources). Feel free to use the notebooks for your own educational purposes. The text is licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/), the code of the IPython examples under the [MIT license](https://opensource.org/licenses/MIT). Please attribute the work as follows: *Lecture Notes on Signals and Systems* by Sascha Spors.

e4d45140f673b87e9e0854ac303f1153fb0fe123
ipynb
Jupyter Notebook
systems_spectral_domain/bode_plot.ipynb
swchao/signalsAndSystemsLecture
7f135d091499e1d3d635bac6ddf22adee15454f8
MIT
2019-01-27T12:39:27.000Z
2022-03-15T10:26:12.000Z
systems_spectral_domain/bode_plot.ipynb
xushoucai/signals-and-systems-lecture
30dbbf9226d93b454639955f5462d57546a921c5
MIT
systems_spectral_domain/bode_plot.ipynb
xushoucai/signals-and-systems-lecture
30dbbf9226d93b454639955f5462d57546a921c5
MIT
2020-09-18T06:26:48.000Z
2021-12-10T06:11:45.000Z
Qwen/Qwen-72B
1. YES
2. YES