# Exercise 10




```python
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
from math import *
from scipy.signal import *
```


```python
b = [ 0.85, 0.1]
a = [ 1, -0.4, -0.05 ]
r, p, k = residue(b, a)
print("residues:", r)
print("poles:", p)
print("direct polynomial term:", k)
```

    residues: [-0.025  0.875]
    poles: [-0.1  0.5]
    direct polynomial term: [0.]


$$ H(s) = \frac{0.85 s + 0.1}{s^2 - 0.4 s - 0.05} = - \frac{0.025}{s + 0.1} + \frac{0.875}{s - 0.5} $$

$$ h(t) = -0.025 \exp(-0.1 t) + 0.875 \exp(0.5 t) $$

---
# Exercise 11



```python
b = [ 2, -11, 12]
a = [ 1, -7, 18, -20, 8 ]
r, p, k = residue(b, a)
print("residues:", r)
print("poles:", p)
print("direct polynomial term:", k)
```

    residues: [-3.+0.j  3.+0.j -1.+0.j -2.+0.j]
    poles: [1.+0.j 2.+0.j 2.+0.j 2.+0.j]
    direct polynomial term: [0.]


$$ H(s) = \frac{2 s^2 - 11 s + 12}{s^4 - 7 s^3 + 18 s^2 - 20 s + 8} =
          -\frac{3}{s-1} +\frac{3}{s-2}-\frac{1}{(s-2)^2}-\frac{2}{(s-2)^3} $$
$$ h(t) = -3e^t + 3e^{2t} -t e^{2t} -t^2 e^{2t} $$


```python
import sympy as sp
sp.init_printing()
s, t = sp.symbols('s t')
Hs = (2*s**2 -11*s +12) / (s**4-7*s**3+18*s**2-20*s+8)
sp.Eq(Hs, Hs.apart())
```


```python
sp.inverse_laplace_transform(Hs.apart(), s, t)
```

---
# Exercise 12



```python
Hs = 2*s/(s+1)/(s+3)
sp.Eq(Hs, Hs.apart())
```


```python
sp.inverse_laplace_transform(2*s/(s+1)/(s+3), s, t)
```

---
# Exercise 13



```python
f0 = 100 # Hertz
b = [ 2, -11, 12 ]
a = [ 1, -7, 18, -20, 8 ]

filter = lti(b, a)
filter
```




    TransferFunctionContinuous(
    array([  2., -11.,  12.]),
    array([  1.,  -7.,  18., -20.,   8.]),
    dt: None
    )




```python
Omega, Gain, Phase = filter.bode()
Omega *= f0

fig, (ax1, ax2) = plt.subplots(2,1, sharex=True)
ax1.semilogx(Omega, Gain)
ax1.set_ylabel('gain [dB]')
ax1.grid()
ax2.semilogx(Omega, Phase)
ax2.set_xlabel('frequency [Hz]')
ax2.set_ylabel('phase [deg]')
ax2.grid()
```


    <IPython.core.display.Javascript object>






---

f60caa105947abff0f2510bfd3610e8cd658cf4a
ipynb
Jupyter Notebook
Exercise 10 - 13.ipynb
variance/PHU.011UB
75a82a9fc2d61aeef0b9237f2fb77fe3270973f7
BSD-3-Clause
Exercise 10 - 13.ipynb
variance/PHU.011UB
75a82a9fc2d61aeef0b9237f2fb77fe3270973f7
BSD-3-Clause
Exercise 10 - 13.ipynb
variance/PHU.011UB
75a82a9fc2d61aeef0b9237f2fb77fe3270973f7
BSD-3-Clause
Qwen/Qwen-72B
1. YES
2. YES