A Java implementation of the Secant method for finding roots of complex polynomials, extended to visualise Newton/Secant fractals — striking images that emerge from colouring each point in the complex plane by which root its iteration sequence converges to.
- Complex number arithmetic — a custom
Complexclass supporting the operations needed for root-finding on ℂ - Polynomial representation — a
Polynomialclass over ℂ[z], supporting efficient evaluation via nested (Horner's method) form rather than repeated exponentiation - Secant root-finding algorithm — implements the iterative scheme
- z(n+1) = z(n) - f(z(n)) * (z(n) - z(n-1)) / (f(z(n)) - f(z(n-1))) which converges to a root without requiring the derivative of f (unlike Newton-Raphson), handling convergence, divergence, and non-convergence cases explicitly
- Fractal generation — for a given polynomial and region of the complex plane, every pixel is mapped to a starting point, run through the Secant algorithm, and coloured according to which root it converges to (and optionally shaded by how many iterations it took) — producing fractal images like the classic root-finding fractals for f(z) = z³ - 1
Although the Secant method is a simple, well-understood numerical technique, which root a given starting point converges to is extremely sensitive to initial conditions — producing self-similar, fractal boundary structure between the basins of attraction of each root. This project explores that behaviour directly through visualisation.
Java, custom complex-number and polynomial arithmetic, PNG image generation
Complex.java— complex number representation and arithmeticPolynomial.java— polynomial representation and evaluation over ℂSecant.java— the Secant root-finding algorithmProject2.java— fractal image generation and renderingFractal.pdf— example output for a chosen polynomial and region of the complex plane