Image Generation (Newton Raphson 1)

Part of the goal of the image generation project was to break me out of just thinking of ideas and extending / perfecting them without ever doing anything and start working on some concrete projects and iteratively producing tangible results.

I thus of course spent the initial 2 weeks of this first task procrastinating and thinging of potential extensions. However, I have knuckled down today and got a very minimum newton raphson example together.

This image technique uses the newton raphson algorithm to find a root (see Newton’s Method ) near a root this method converges quickly and convexly however further from the root it can exhibit chaotic behavior.

The basic idea is to take a complex function and for each point in a region of the complex plane plot the amount of time it takes to converge to a root starting at that point. During my undergraduate degree I think I programmed this (I think in Java as we were doing a Java course at the time) and my father kindly printed the results to decorate my walls.

I didn’t play around with the program for that long I think the nicest image came from the settings that produced the following image:

Final Result.

(A greyscale image of the iteration time of z^6 + 20z^3 = -1)

Next steps

The code is quick simple and available at Github it takes a json file outlining the basic data and renders it. It is very naive and I spent no time optimising it. Some follow up I might do would be:

  • Optimisation – Multithreading, switching to 32 bit float, seeing how much can be done with integer maths. Caching results
  • Finding which roots we are converging to and colouring the image
  • Making an animation of slowly transforming polynomials – making a curve in polynomial space
  • Some image rendering imrpovements antialiasing / jittering
  • The rendering of the greyscale is currently a linear rescaling from 0 to a given maxmium iteration limit to 0-255. A better (and automatically determined) HDR type maping could make for nicer images.