Giter Site home page Giter Site logo

calacuda / calc-rs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.02 MB

a calculator module for Python and Rust capable of computing arbitrarily long equations and functions.

License: MIT License

Rust 76.02% Python 21.30% Shell 2.68%
calculator python3 python3-library rust

calc-rs's Introduction

calc-rs

a calculator module for Python and Rust capable of computing arbitrarily long equations and functions.

Speed Test

These tests were done using hyperfine and the speed-test.sh script in the test folder

testing python version:
Benchmark 1:  python -c "import calculator as calc; calc.solve_func(\"f(x)= 4+3x+x**2+x**3\", -1000, 1000)"
  Time (mean ± σ):      1.150 s ±  0.018 s    [User: 1.130 s, System: 0.016 s]
  Range (min … max):    1.126 s …  1.231 s    50 runs


testing rust version:
Benchmark 1:  python -c "import calculators as calc; calc.solve_func(\"f(x)= 4+3x+x^2+x^3\", -1000, 1000)"
  Time (mean ± σ):      11.8 ms ±   0.8 ms    [User: 10.6 ms, System: 3.6 ms]
  Range (min … max):    11.1 ms …  14.5 ms    25 runs

As you can see the rust version is significantly faster.

Usage

there are three functions that this libray exposes:

Function Args Description
solve equasions: list(str) takes a list of equations as strings and solves eatch one returning a list of answers.
solve_func f: str, start: int, stop: int solves the function, f, at all integer points between start and stop.
solve_funcs fs: list(str), start: int, stop: int solves a list of functions, fs, for all integer points between start and stop. returns a dictionary whose keys are function names and whose values are a tuple of a list of x values and a list of y values.

Installation

with pip:

pip install calc-rs

calc-rs's People

Contributors

calacuda avatar

Watchers

 avatar

calc-rs's Issues

function solver tries to solve equations containing Riemann sums.

Description

If the solve_func function is passed a non-function equation with a Riemann Sum, then the function will attempt to solve it. This is a bug, it should report an error.

Branch

feature and dev

Example

cmd: cd rust-lib; echo '3(i=0_5$(i))' | cargo run
output: 3(i=0_5$(i)) => ("3(i", ([0, 1, 2, 3, 4, 5], [Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0), Some(0.0)]))
expected: 3(i=0_5$(i)) => Some(45.0)

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.