```python
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sympy as sym
```


```python
t = sym.symbols('t', real=True)
k = sym.symbols('k')

w_0 = 5
w_s = 50
x = sym.cos(w_0 * t)
```


```python
s = sym.sequence(x.subs(t, k * 2 * sym.pi / w_s), (k, 0, 100))
s
```




    SeqFormula(cos(pi*k/5), (k, 0, 100))




```python
a = np.fromiter(s, float)
```


```python
plt.plot(a);
```


```python
s.formula
```




    cos(pi*k/5)




```python
s.interval
```




    [0, 100]




```python
s.length
```




    101




```python
s.start
```




    0




```python
s.stop
```




    100




```python
s.variables
```




    (k,)




```python
s.free_symbols
```




    set()




```python
s.coeff_mul(42)
```




    SeqFormula(42*cos(pi*k/5), (k, 0, 100))




```python
s.coeff(1)
```




    1/4 + sqrt(5)/4




```python
s[1]
```




    1/4 + sqrt(5)/4




```python
s[:10]
```




    [1,
     1/4 + sqrt(5)/4,
     -1/4 + sqrt(5)/4,
     -sqrt(5)/4 + 1/4,
     -sqrt(5)/4 - 1/4,
     -1,
     -sqrt(5)/4 - 1/4,
     -sqrt(5)/4 + 1/4,
     -1/4 + sqrt(5)/4,
     1/4 + sqrt(5)/4]




```python
def sinc(x):
    return sym.sin(x) / x
```


```python
T = 2 * sym.pi / w_s

y = sum(s[n] * sinc(sym.pi / T * (t - n * T))
        for n in range(s.start, s.stop + 1))
```


```python
sym.plot(y, (t, 0, 5), xlabel='$t$', ylabel='$y(t)$', ylim=(-1.2, 1.2));
```


```python
random = sum(np.random.normal(scale=0.5) * sinc(sym.pi / T * (t - n * T))
             for n in range(s.start, s.stop + 1))
```


```python
sym.plot(random, (t, 0, 5), xlabel='$t$', ylabel='$y(t)$', ylim=(-1.2, 1.2));
```

eadb46c246f6c81bb7c79bce4a376f8709b5e3de
ipynb
Jupyter Notebook
sympy/sequence.ipynb
mgeier/python-audio
70d4d62b148c08c50ec0057f8d4fd9876ce67a13
CC0-1.0
2015-04-14T20:13:25.000Z
2022-03-26T20:00:27.000Z
sympy/sequence.ipynb
mgeier/python-audio
70d4d62b148c08c50ec0057f8d4fd9876ce67a13
CC0-1.0
2017-05-02T13:22:41.000Z
2017-05-03T13:17:15.000Z
sympy/sequence.ipynb
mgeier/python-audio
70d4d62b148c08c50ec0057f8d4fd9876ce67a13
CC0-1.0
2015-04-19T14:08:37.000Z
2021-04-21T14:24:37.000Z
Qwen/Qwen-72B
1. YES
2. YES