The problem I'm trying to solve is described here.
In my script, I used Euler's identity to calculate z^-n, such that z^-n = cos(omegan) - jsin(omegan). I find the magnitude of these values from a range of 0 to pi, and then plot them. However, the resulting graph aperiodically oscillates between 0 and ~ -8 dB, and I'm honestly not sure why.
I'd appreciate any help! The code is as follows:
import math import matplotlib.pyplot as plt # define constants b0 = .125 a1 = .875 x =  total = 0 while total <= math.pi: x.append(total) total += math.pi/256 return the magnitude of z-n def find_z(n, omega): # z = re^jw # e^jw = cos(w) + jsin(w) # z^-n = cos(wn) - jsin(wn) ret = abs(math.cos(omega * n) - (1j * math.sin(omega * n))) return ret h =  for i in x: h.append(b0 / (1 - (a1 * find_z(-1, i)))) for i in range(len(h)): h[i] = 20 * math.log10(h[i]) plt.plot(x, h, color='blue', marker='o', linestyle='-', linewidth=2, markersize=12) plt.xscale("log") fig = plt.figure(figsize=(12, 6)) plt.show() print(h)