Skip to content

GeorgiosIoannouCoder/division-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Revolutionizing the Division Operation | Analysis and Implementation of Common Division Algorithms

Contributors Forks Stargazers Issues MIT License LinkedIn GitHub


Logo

Division is the most time-consuming, resource expensive, and complex arithmetic operation. Hardware and software support for floating-point arithmetic is a must in modern central processor units. Even though division is used the least compared to addition and multiplication, it is becoming increasingly important in modern complex applications. The performance of such applications is affected and limited by the algorithms used for division. This project and Report study some of the most used division algorithms such as long division, restoring, non-restoring, SRT, Newton-Raphson, Goldschmidt, accurate quotient approximations, polynomial long division, and polynomial extended synthetic division. The Report continues by comparing the fastest division algorithm with Python’s built-in integer division, divmod function, and polydiv function. Finally, the Report concludes that the Newton-Raphson division algorithm is the fastest for integers, and the polynomial extended synthetic division algorithm is the fastest for polynomials. Moreover, the Report illustrates that Newton-Raphson division algorithm and polynomial extended synthetic division algorithm are faster and more efficient than Python’s built-in algorithms.
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Code
  4. Report
  5. Slides
  6. Analysis and Conclusions
  7. Contributing
  8. License
  9. Contact

About The Project

Logo

Division Algorithms For This Project

Division Alogirthms can be categorized into:

1. Division of unsigned integers

2. Division of polynomials

Division Algorithms

Back to top

Key Features

  1. Excessively test each Division Algorithm with the number of digits starting from 0 and going up to 2,097,153.
  2. Excessively test each Polynomial Division Algorithm with the degree of the polynomial starting from 5,000 and going up to 300,002.
  3. A new unique way of implementing Newton Raphson Division Algorithm.

Back to top

Built With

Python JupyterNotebook Anaconda Pandas Matplotlib Git

Back to top

Getting Started

To get a local copy of the Revolutionizing the Division Operation project up and running locally follow these simple example steps:

Prerequisites

NOTE: How to check if Python is installed and what is its version

  python --version

NOTE: How to check if Git is installed and what is its version

  git -v
  1. Please make sure you have pyenv installed and use Python3 version 3.11.0:

  2. Please make sure you have git installed

  3. Please look at the setup folder found in this project to find the directions specific to your operating system. The general instructions can also be found below.

Setup

  1. Navigate to the directory where you want to clone/run/save the application:

    cd your_selected_directory
  2. Clone this repository:

    git clone https://github.com/GeorgiosIoannouCoder/division-algorithms.git
  3. Navigate to the realesrgan git repository:

    cd division-algorithms
  4. Use Python3 3.11.0 version in the cloned repository folder:

    pyenv local 3.11.0
  5. Create virtual environment in the cloned repository folder:

    python -m venv .division-algorithms-venv
  6. Activate the virtual environment (Windows OR Mac/Linux):

    1. Windows
    .\.division-algorithms-venv\Scripts\activate
    1. Mac/Linux
    source .division-algorithms-venv/bin/activate
  7. Install the dependencies listed in the requirements.txt file:

    pip install -r requirements.txt
  8. Install ipykernel:

    pip install ipykernel
  9. Install Jupyter Notebook:

    pip install jupyter notebook
  10. Add the kernel of the virtual environment in the Jupyter Notebook:

    ipython kernel install --user --name=.division-algorithms-venv
  11. Run the Jupyter Notebook:

    jupyter notebook
  12. Select the .division-algorithms-venv kernel to run the Jupyter Notebook.

  13. To Run The Notebook (4 Options):

    1. Steps above and also here
    2. Use Google Colaboratory
    3. Use Jupyter Notebboks Extension for VS Code
    4. Use Anaconda
      1. Download and install Anaconda
      2. Launch a jupyter notebook:
        1. MacOS users, open up terminal and type in jupyter notebook
        2. Window users, open up your Anaconda Power Shell, and type in jupyter notebook

Back to top

Code

The full project code with the output can be found here.

Back to top

Report

The report of this project with a comprehensive explanation of all the Division Algorithms is located here. The figures found inside the Report are located here and here.

Slides

The slides of this project are located here.

Back to top

Analysis and Conclusions

  • Number of atoms in the universe = 1078 to 1082
  • Newton Raphson division algorithm = 2,097,153 digits (able to carry the most complex tasks)
  • Polynomial extended synthetic division algorithm = 300,002 nd degree polynomials
  • Newton Raphson division algorithm is the fastest and faster than Python’s built in functions
  • None of the division algorithms is considered as the best
  • There is a trade off in choosing what division algorithm to use and it depends on the task needed to be done

From this Report and based on Table A5 and Graph A5, we concluded that the fastest division algorithm for large-scale complex tasks is the Newton Raphson division algorithm. However, it is also expected that the Goldschmidt division algorithm and the accurate quotient approximations division algorithm will also be fast. The Newton Raphson division algorithm is so fast that the Python programming language may want to override its integer division algorithm with this algorithm. For smaller scale and simpler tasks, the long division algorithm can also be used.

For polynomial division it is better to implement the polynomial extended synthetic division algorithm rather than the polynomial long division algorithm because it is faster, simpler, and uses fewer resources. The Python programming language may also consider in overriding its polydiv function with the polynomial extended synthetic division algorithm because it solves the issue of memory.

Below are the Figures found inside the Appendix and Slides.

UNSIGNED INTEGERS

Naive Division Algorithm

Long Division Algorithm

Restoring Division Algorithm

Non-Restoring Division Algorithm

Newton Raphson Division Algorithm

Python's divmod Function

Python's Integer Division

POLYNOMIALS

Polynomial Long Division Algorithm

Polynomial Extended Synthetic Division Algorithm

Back to top

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Back to top

License

Distributed under the MIT License. See LICENSE for more information.

MIT License

Copyright (c) 2021 Georgios Ioannou

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back to top

Contact

Georgios Ioannou - @LinkedIn

Georgios Ioannou - @georgiosioannoucoder - Please contact me via the form in my portfolio.

Project Link: https://github.com/GeorgiosIoannouCoder/division-algorithms

Back to top