import numpy as np import matplotlib.pyplot as plt def x(n): return (1/n) * np.heaviside(n, 0.5) n = np.arange(1,100) y = x(n) E_x_total = 0 E_x = np.zeros(len(y)) for i in range(len(y)): E_x_total += abs(y[i])**2 E_x[i] = E_x_total fig, ax = plt.subplots() ax.scatter(n,y, label="$x[n]$") ax.scatter(n, E_x, c='red', label="$E_x$") ax.axhline(np.pi**2 / 6, linestyle='-', label="$\\frac{\pi^2}{6}$") ax.legend() plt.show()