# fl

Dec 16th, 2019
200
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2. import random
3. import time
4.
5. MasA = [0] * 11
6. MasG = [0] * 11
7. MasX = [0] * 1001
8. MasY = [0] * 1001
9.
10. MasCosWXj = [0] * 20001
11. MasSinWXj = [0] * 20001
12. MasWj = [0] * 11
13. indCos = [0] * 11
14.
15. data = input().split('[')
16. data = data[1:]
17.
18. ans = [0] * 100
19.
20.
21. """ ------ Ввод пар (x, y) ------ """
22.
23. for i in range(2):
24.     if i % 2 == 0:
25.         r = 2
26.         cords = data[i].split(', ')
27.         cords[-1] = cords[-1][:-2]
28.         for cord in cords:
29.             if r % 2 == 0:
30.                 MasX[r // 2] = float(cord[1:])
31.             else:
32.                 num = float(cord[:-1])
33.                 MasY[r // 2] = num
34.             r += 1
35.
36.     else:
37.         xcords = data[i].split(', ')
38.         for i in range(len(xcords)):
39.             if i == 99:
40.                 ans[i] = float(xcords[i][:-2])
41.             else:
42.                 ans[i] = float(xcords[i])
43.
44. """ ---------------------------- """
45.
46. #for j in range(1, 1001):
47.    # MasX[j] = j * j
48.    # MasY[j] = 3 * math.sin(-0.333 * j * j) - 10 * math.cos(0.872 * j * j) + 2 * math.cos(0.7 * j * j)
49.
50. #start = time.time()
51. for i in range(1, 11):
52.     icos = 0
53.     AAm = 0
54.     for jw in range(20001):
55.         w = jw / 1000 - 10
56.         SummS = 0
57.         SummC = 0
58.         for j in range(1, 1001):
59.             SYY = 0
60.             for k in range(1, i):
61.                 if indCos[k] == 1:
62.                     SYY = SYY + MasA[k] * math.cos(MasWj[k] * MasX[j])
63.                 else:
64.                     SYY = SYY + MasA[k] * math.sin(MasWj[k] * MasX[j])
65.
66.             MasCosWXj[j] = math.cos(w * MasX[j])
67.             SummC = j / (j + 1) * SummC + (MasY[j] - SYY) * MasCosWXj[j] / (j + 1)
68.             MasSinWXj[j] = math.sin(w * MasX[j])
69.             SummS = j / (j + 1) * SummS + (MasY[j] - SYY) * MasSinWXj[j] / (j + 1)
70.
71.         #print(math.fabs(SummS), math.fabs(SummC))
72.         if math.fabs(SummS) < math.fabs(SummC):
73.             icos = 1
74.             AA = SummC
75.         else:
76.             icos = 0
77.             AA = SummS
78.
79.         AAA = math.fabs(AA)
80.
81.         if math.fabs(AAm) < AAA:
82.             AAm = AA
83.             wm = w
84.             iCosm = icos
85.     MasA[i] = 2 * AAm
86.     MasWj[i] = wm
87.     indCos[i] = iCosm
88.
89. #print(time.time() - start)
90.
91. print(*MasA)
92. print(*MasWj)
93. #print(*indCos)
94.
95.
96. #for i in range(1, 11):
97. #    indCos[i] = random.randint(0, 1)
98. print(*indCos)
99.
100. res = []
101. for ii in range(100):
102.     x = ans[ii]
103.     y = 0
104.     for i in range(1, 11):
105.         if indCos[i] == 0:
106.             y += MasA[i] * math.sin(x * MasWj[i])
107.         else:
108.             y += MasA[i] * math.cos(x * MasWj[i])
109.
110.     res.append(round(y, 2))
111.
112. print(res)