Advertisement
Guest User

ebanaya_xueta

a guest
Dec 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import math
  2. import matplotlib.pyplot as plt
  3.  
  4.  
  5. def fraction(x):
  6.     return x - int(x)
  7.  
  8.  
  9. v = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 3, 5, 15, 17, 51, 85, 255, 257, 771]]
  10. w = 0
  11. r = 0
  12. q = []
  13. p = 9
  14. Vx = []
  15. Vy = []
  16.  
  17. for i in range(1, p + 1):
  18.     m = 1 + int(math.log(i) / math.log(2))
  19.     for j in range(1, 3):
  20.         r = 0
  21.         for k in range(1, m + 1):
  22.             w = 0
  23.             for l in range(k, m + 1):
  24.                 w = w + int(2 * fraction(i * 2 ** (-l))) * int(2 * fraction((v[j - 1][l - 1] * 2 ** (k - 1 - l))))
  25.             r = r + (2 ** (-k + 1)) * fraction((1 / 2) * w)
  26.         q.append(r)
  27.         if j == 1:
  28.             X = r
  29.             Vx.append(X)
  30.         if j == 2:
  31.             Y = r
  32.             Vy.append(Y)
  33. print(q)
  34. plt.scatter(Vx, Vy)
  35. plt.xlim(0, 1)
  36. plt.ylim(0, 1)
  37. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement