Giter Club home page Giter Club logo

anti-wallis's Introduction

Anti Wallis

John Wallis was a mathematician who found/discovered/invented the Wallis function (or Wallis product as its friends call it).

The Wallis function is the most used method to calculate pi.

As you have probably figured from the name of this repo I'm not the biggest fan of his function.

This repo is meant to show how horrible the Wallis function is and to ask every developer in the world to demolish it.

I implemented a better function to calculate pi, the code in the repo is running the function, and comparing it to the Wallis function.

Usage

Instead of going through all this trouble you can just view the Online Demo (press the "Run" button if needed)

Clone the repo

git clone https://github.com/donno2048/Anti-wallis
cd Anti-Wallis

Choose a language

You should run the C version, it has the fastest Wallis function...
You can also install every requirement (sudo apt update && sudo apt install gcc python3 nodejs golang-go -y) and run the interactive session (bash main.sh)
C

Install the requirements (just the GCC compiler)

sudo apt update
sudo apt install gcc -y

Compile

gcc c/main.c c/test.c c/pi.c -o main -lm

Run

./main
Python

Install the requirements (just the Python interpreter)

sudo apt update
sudo apt install python3 -y

Run

python3 py/main.py
JavaScript

Install the requirements (just the Node.js interpreter)

sudo apt update
sudo apt install nodejs -y

Run

(--experimental-modules is only needed for node version <= 12)

node --experimental-modules js/main.mjs
Go

Install the requirements (just the Go compiler)

sudo apt update
sudo apt install golang-go -y

Run

go run go/main.go go/pi.go go/test.go 
Rust

Install the requirements (just the Rust compiler)

sudo apt update
sudo apt install rustc -y

Compile

rustc rust/main.rs

Run

./main

Note

If you're wondering why so few digits of pi take so much time to evaluate note these two facts:

  1. To benchmark the functions I'm running them 100 times
  2. Not all the evaluated digits are being printed, simply because of the language itself or the properties of string formating in it

anti-wallis's People

Contributors

donno2048 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.