def s(frequency, num_samples, color='red'):
f(x) = (sin(x*pi*frequency))
samples = map(f, range(num_samples))
points = zip(range(num_samples), samples)
p = plot( f,
xmin = 0,
xmax = num_samples,
figsize = (10,1.5),
color='lightblue'
)
q = line(points, color=color, marker='.')
return p+q
print "\n\nAn input waveform near the Nyquist frequency is distorted to a warbling one AT the Nyquist frequency."
show(s(0.98, 100))
show(s(0.95, 100))
show(s(0.90, 100))
print "\n\nNote that while there are stretched cycles that let the input wave catch up..."
show( s(0.98, 30) )
show( s(0.95, 30) + arrow((19,-1),(20,0)) )
show( s(0.90, 30) + arrow((9,-1), (10,0)) + arrow((21,-1),(20,0)) )
print "\n\n... which can also be considered phase distortion ..."
show( s(0.95,200) + s(0.98, 200, 'blue'))
print "\n\n... the actual output frequency is always the same: 1/2 the sample rate."
show( s(0.98,10) + s(0.95, 10) + s(0.90,10) )
An input waveform near the Nyquist frequency is distorted to a warbling one AT the Nyquist frequency.
Note that while there are stretched cycles that let the input wave catch up...
... which can also be considered phase distortion ...
... the actual output frequency is always the same: 1/2 the sample rate.