Mandelbrot Java

  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mandelbrot Java as PDF for free.

More details

  • Words: 184
  • Pages: 2
// by Erik Wrenholt import java.util.*; class Mandelbrot { static int BAILOUT = 16; static int MAX_ITERATIONS = 1000; private static int iterate(float x, float y) { float cr = y-0.5f; float ci = x; float zi = 0.0f; float zr = 0.0f; int i = 0; while (true) { i++; float temp = zr * zi; float zr2 = zr * zr; float zi2 = zi * zi; zr = zr2 - zi2 + cr; zi = temp + temp + ci; if (zi2 + zr2 > BAILOUT) return i; if (i > MAX_ITERATIONS) return 0; } } public static void run2() { int x,y; for (y = -39; y < 39; y++) { System.err.print("\n"); for (x = -39; x < 39; x++) { if (iterate(x/40.0f,y/40.0f) == 0) System.err.print("*"); else System.err.print(" "); } } } public static void run() { Date d1 = new Date(); for (int i = 0; i < 100; i++) run2(); Date d2 = new Date(); long diff = d2.getTime() - d1.getTime(); System.out.println("\nJava Elapsed " + diff/1000.0f); } public static void main(String args[]) { run(); run(); run(); }

}

Related Documents

Mandelbrot Java
August 2019 13
Mandelbrot Variations
June 2020 4
Mandelbrot C
August 2019 15
Benoit Mandelbrot
June 2020 21
Java Java
June 2020 44
Java
November 2019 24