Skip to content

Kh-NJ2/Root_Finding_Algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Numerical Root-Finding Algorithms

This Python script implements and compares five common numerical methods for finding the roots of a mathematical function. The program calculates the root for a predefined function (f(x) = x² - 3) using each method and displays the step-by-step iterations in a series of tables for easy comparison.

Project Structure

The script is organized into functions, each implementing a specific root-finding algorithm:

  • bisection(f, a, b, E): Implements the Bisection method.
  • secant(f, a, b, E): Implements the Secant method.
  • modified_secant(f, a, b, E): Implements a modified version of the Secant method.
  • newton_raphson(f, df, x, N, E): Implements the Newton-Raphson method, which requires the function's derivative.
  • fixed_point(f, g, a, N, E): Implements the Fixed-Point Iteration method.
  • display_tables(...): A helper function that uses matplotlib to render the results from each algorithm in a clean, tabular format.

Requirements

The script requires the following Python libraries:

  • pandas
  • matplotlib

You can install them by running:

pip install pandas matplotlib

How to Run it

  1. Save the code: Ensure the code is saved in a Python file (e.g., root_finder.py).

  2. Run from the terminal: Navigate to the file's directory and execute the script. The tables will be displayed in a plot window.

    python root_finder.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages