Newton Fractal - Basin of Attraction

Version 1.0.0 (1.64 KB) by Owais Ali
Explore fractals made by Newton's method.
Updated 12 Apr 2022

View License

the code is set and you just have to run the script, nothing else.
to get a fractal for some different function, one have to make the following changes:
  1. function 'f' and the first derivative 'f1' of the function.
  2. note that we are dealing with martix input, therefore, it is necessary to use element wise multiplication, division and exponenciation (.* ./ and .^), instead of regular multiplication, division and exponenciation (* / and ^)
  3. the information of roots must be updated, and assigned to r1, r2, ... so on.
  4. the logical matrices must set accordingly, each for a root and one in negation of each logical matrix (see script).
  5. the colour-map must be updated and the number of colours will be one greater than the number of roots, obviously one extra colour for divergence (black usually [0 0 0]).
  6. update the Z matrix which is the sum of every logical matrix multiplied by the row number of the colour-map, to assign a colour to it.
in the file, some lines are commented (starting with a % sign) to show how to make the aforementioned changes. now you have it and i'll ask you to go wild with it

Cite As

Owais Ali (2024). Newton Fractal - Basin of Attraction (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes