code: def resonator(freq, bandwidth):
    
    bandwidth = thub(bandwidth, 1)
    R = exp(-bandwidth * .5)
    R = thub(R, 5)
    cost = cos(freq) * (2 * R) / (1 + R ** 2)
    cost = thub(cost, 2)
    gain = (1 - R ** 2) * sqrt(1 - cost ** 2)
    denominator = 1 - 2 * R * cost * z ** -1 + R ** 2 * z ** -2
    return gain / denominator
docs: Resonator filter with 2-poles (conjugated pair) and no zeros (constant
    numerator), with exponential approximation for bandwidth calculation.
  
    Parameters
    ----------
    freq :
      Resonant frequency in rad/sample (max gain).
    bandwidth :
      Bandwidth frequency range in rad/sample following the equation:
  
        ``R = exp(-bandwidth / 2)``
  
      where R is the pole amplitude (radius).
  
    Returns
    -------
    A ZFilter object.
    Gain is normalized to have peak with 0 dB (1.0 amplitude).