-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractal.py
55 lines (37 loc) · 1.18 KB
/
fractal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import math
from array import *
from pyde.de import DiffEvol
def fractalSolution():
x = 0
c = -2 + 2j
y = pow(x,3) + 2*c
print("<=================>")
b = 0
f = open("coordinates.txt", "w")
num=0
while c.real <= 2 and c.imag >= -2:
print(c)
for it in range(1,100):
if it%2==0:
num = int(it/2)
i = open("iter"+str(num)+".txt","a")
i.write(f'{"{:.3f}".format(c.real)}:{"{:.3f}".format(c.imag)}\n')
i.close()
y = pow(x,2) + c
x = y
if math.sqrt((pow(int(y.real),2)) + pow(int(y.imag),2)) >= 2:
break
if math.sqrt(pow( int(y.real),2 ) + pow( int(y.imag),2 )) < 2:
f.write(f'{"{:.3f}".format(c.real)}:{"{:.3f}".format(c.imag)}\n')
x = 0
y = 0
if math.trunc(c.real) < 2:
c = c + 0.002
if math.trunc(c.real) == 2:
if math.trunc(c.imag) == -2:
break
elif c.imag > -2:
c = c - 4 - 0.002j
b = b + 1
print(f'b:{b} ==========')
fractalSolution()