This project visualizes the basins of attraction for the roots of a polynomial using the Newton-Raphson method. The visualization is rendered in real-time using a Tkinter GUI.
- Polynomial Evaluation: Supports complex coefficients and roots.
- Newton-Raphson Method: Iterative root-finding algorithm.
- Dynamic Visualization: Displays convergence basins with color-coded roots.
- Customizable Parameters: Easily modify polynomial coefficients, canvas size, and convergence criteria.
- Polynomial Definition: The polynomial is defined by its coefficients in ascending order (constant term first).
- Newton-Raphson Iteration: For each randomly sampled initial guess, the Newton-Raphson method is applied to find a root.
- Root Classification: Roots are classified and assigned unique colors. Points that converge to the same root share the same color.
- Real-Time Rendering: The canvas is updated in real-time to show the basins of attraction.
- Python 3.7+
- Required libraries:
numpy,tkinter
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd Newton-Basins - Install dependencies:
pip install numpy
To start the visualization, run the following command:
python newton.py- Polynomial Coefficients: Modify the
Poliinstance innewton.pyto change the polynomial. - Canvas Size and Limits: Adjust the
Basinclass initialization to change the visualization area and resolution.
Represents a polynomial and provides methods for evaluation, differentiation, and root classification.
Performs the Newton-Raphson iteration to find a root of the polynomial.
Handles the Tkinter GUI and visualization of the basins of attraction.
The default polynomial is:
P(x) = 48 + 8x + 4x^2 - 10x^3 + 2x^4 - 3x^5 + x^6
The visualization shows the basins of attraction for the roots of this polynomial.
This project is licensed under the MIT License. See the LICENSE file for details.
- Inspired by the mathematical beauty of fractals and root-finding algorithms.
- Special thanks to the Python community for providing excellent libraries like
numpyandtkinter.