Skip to content

mbn-code/Newton-Raphsons-Root-Finder

Repository files navigation

Comprehensive Newton-Raphson Method Implementations

Welcome to my repository dedicated to providing robust implementations of the Newton-Raphson method across multiple programming languages, namely JavaScript, Python, and Rust. The Newton-Raphson method is a well-known root-finding algorithm that employs iteration to accurately determine the roots of a real-valued function.

Third Degree Polynomial

Table of Contents

Detailed Introduction

The Newton-Raphson method is a highly effective numerical technique used for finding the roots of a real-valued function. It leverages the concept that a continuous and differentiable function can be approximated by a straight line tangent to it. This repository offers comprehensive implementations of the Newton-Raphson method in JavaScript, Python, and Rust, providing a valuable resource for those interested in numerical methods and their applications.

In-depth Project Structure

This project is meticulously structured to provide clear and organized access to the various implementations:

Project Structure

The project is structured as follows:

Getting Started

Prerequisites

Before you can run the code in this repository, you need to have the following installed:

  • Node.js and npm: You can download and install them from here.
  • Python: You can download and install it from here.
  • Rust and Cargo: You can download and install them from here.

Installation

  1. Clone the repository:
git clone https://github.com/mbn-code/newton-raphson-root-finder.git
  1. Navigate into the project directory
cd newton-raphson-root-finder
  1. Insatll the neccessary p5 extensions ( using vscode )

    3.1 windows ctrl + shift + x to go to extensions 3.1 macOS command + shift + x to go to extensions

    3.2 search live p5 and install the following:

    live-p5

Running The Visualisation part

To run the visual part of this demonstration we focus on the newton.js file. This file contains the implementation of newton raphson method in p5

To run the simulation use the shortcut ctrl + shift + p or command + shift + p and type Open live p5 panel To get the panel to show, to load a new random polynomium (graph) use the shortcut ctrl + s or command + s which saves the file, and acts as reloading the live preview and running the script.

Visualisation of Newton Method

Running the terminal scripts

To run the javascript code simiple use node src_js/newton_rec.js, this is the recursive implementation of the newton raphson method which shows the method in a recursive manner. The benchmarking script related to the newton_rec.js is the newton_rec_benchmark.test.js which is a javascript test file to test n amount of different functions (based on how many there are in the array) and benchmark the time it takes to find a root, based on x0 initial guess.

When running rust you use cargo run in the src_rust/newton_rec project folder

Running the python visualisation

Use python src_python/newton.py when running the visualisation.

Contact Information

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages