-
-
Save pitrou/9eb2a5651b99f2e3c4ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
from _decimal import * | |
def color_point(x0, y0, iters): | |
two = Decimal(2) | |
x = +x0 | |
y = +y0 | |
sq_x = x * x | |
sq_y = y * y | |
for i in range(iters): | |
y = two * (x * y) + y0 | |
x = sq_x - sq_y + x0 | |
sq_x = x * x | |
sq_y = y * y | |
return x | |
def main(): | |
prec, iters = [int(x) for x in sys.argv[1:]] | |
getcontext().prec = prec | |
x0 = Decimal("0.222") | |
y0 = Decimal("0.333") | |
clock = time.perf_counter | |
start_clock = clock() | |
x = color_point(x0, y0, iters) | |
end_clock = clock() | |
print(x) | |
print("time: %f\n\n" % (end_clock-start_clock)) | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment