I need help plotting the Heaviside function:
Real analysis often involves constructing bizarre functions which are intuitively correct, but ultimately wrong. See the great book Counterexamples in Analysis.
I wrote a numpy
script to plot the function $\displaystyle \sum_{n=1}^\infty \frac{1}{n^2} H\left(x - \frac{1}{n}\right)$ to illustrate some concepts in real analysis. This is in a response to another question on math.stackexchange:
Here is an example with an accompanying plot:
B = [ [1,n] for n in range(1,50) ]
N = 1000
y = np.zeros(N)
count = 1
for b in B:
x = np.zeros(N)
x[ np.arange(b[0]*1.0*N/b[1], N).astype(int)]=count**-2
y += x
count += 1
plt.plot(np.arange(0,1,1.0/N),y)
plt.axis("Equal")
How can I remove the vertical lines and really show the discontinuity?
np.nan
s. Would you mind reviewing the existing answers and selecting a good one? Thanks! $\endgroup$