Optimizing math in finding Mandelbrot set