Giter Club home page Giter Club logo

bernoulli's Introduction

Bernoulli

Bernoulli using bernoulli.py

This Python package offers robust tools for calculating partial sums of powers of natural numbers and managing Bernoulli numbers with optimized caching techniques. Ideal for mathematicians, researchers, and software developers interested in number theory or computational mathematics.

Features 🌟

  • Compute LARGE Partial Sums: Utilize Faulhaber's formula to compute sums of powers of very long natural numbers.
  • Bernoulli Numbers Generation: Efficiently generate Bernoulli numbers using the Akiyama–Tanigawa algorithm.
  • Caching System: Persistent caching of computations to enhance performance of successive operations.
  • Command Line Interface: Versatile CLI support for interactive and script-based usage.
  • Library for your app: You can import bernoulli to make it a part of your app.

Getting Started 🚀

To get started with bernoulli.

  1. Clone the repository.
git clone https://github.com/Siiir/bernoulli
  1. Go to the repo folder.
cd bernoulli
  1. Run the following command in your terminal:
python bernoulli.py help

Examples

Here are some quick examples to show you the power of the Bernoulli package.

Calculating the nth Bernoulli Number

This command prints the 6th Bernoulli number.

python bernoulli.py nth 6

Or, in interactive mode type nth(6).

Printing Bernoulli Numbers up to k

Lists the first 11 Bernoulli numbers (0 to 10).

python bernoulli.py up_to 10

Or, in interactive mode type up_to(10).

Sum of Powerful Powers

  • Calculates the sum of the the first (1 vigintillion + ...) of positive natural numbers, each taken to the power of k=1873.
python bernoulli.py psum 1509096632309561804061385286158050392946131124427766465467743034  1873
  • Or, in interactive mode type
psum(1509096632309561804061385286158050392946131124427766465467743034, 1873)
  • I have choosen a "small" n for the purpose of readability. You can try increasing the first argument quite freely. Whereas increasing the k will have a noticable computional cost.

Complex equations using Python3's math functions and builtins

Interactive mode only.

sin(psum(20, 3) - psum(10, 3)) + 2**6

Documentation 📚

Interactive documentation

Detailed documentation is available within the module. Use the help command for more information on specific functions:

python bernoulli.py help nth_Bernoulli_num

Or, in interactive mode type

help(nth_Bernoulli_num)

You can even use short aliases.

help(nth)

Thinking in big terms

  • As of time of writing the most optimized is the interactive mode as it doesn't need to perform the startup (big cache deserialization) between calls to different app commands. It also supports session-local, in-RAM caching.
  • Currently caching is set to 3000 [u], but only 2000*u+2 numbers are saved on GitHub. This means that performing operations like nth k or psum n k with
    1. k ≤ 2000 from GitHub clone should be almost const time.
    2. k ≤ 3000 will trigger full caching increasing the app startup time and enhancing large k computations.
    3. k > 3000 will trigger only in-RAM caching enhancing computations during one interactive session..

Contributing

Interested in contributing? We're always looking for help to improve documentation, fix issues, or make optimizations.

License

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

Author

Bernoulli was created by Tomasz Nehring, a creative mathematician and software engineer.


⚠️ Note: Not suitable for server use. Has many vulnerabilities. Can launch arbitrary code.

bernoulli's People

Contributors

siiir avatar

Stargazers

Mateusz Laskowski avatar  avatar  avatar Maciej Dziurzyński avatar

Watchers

 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.