Skip to content

Instantly share code, notes, and snippets.

@riceissa
Created August 1, 2020 01:21
Show Gist options
  • Save riceissa/1c268b3483c09382876fed40c1c86626 to your computer and use it in GitHub Desktop.
Save riceissa/1c268b3483c09382876fed40c1c86626 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
def f(x, j, n):
if ((j-1)/(n+1) <= x) and (x <= (j - 1/2)/(n+1)):
return 2 * (n+1) * (x - (j-1)/(n+1))
if ((j - 1/2)/(n+1) <= x) and (x <= j/(n+1)):
return -2 * (n+1) * (x - j/(n+1))
return 0
n = 10
fig, axs = plt.subplots(n+1)
xs = np.arange(0.0, 1.0, 0.001)
for j in range(1, n+1+1):
axs[j-1].plot(xs, [f(x, j, n) for x in xs])
axs[j-1].set_title('f_' + str(j))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment