A Python library created to assist programmers with complex mathematical functions

Overview

libmaths

python License

libmaths was created not only as a learning experience for me, but as a way to make mathematical models in seconds for Python users using math in their code. With pre-programmed mathematical functions ranging from linear to sextic and more, graphing in your code will be a breeze.

Quick Demo


Installation

The package is available on PyPI. Install with:

pip install libmaths

or

pip3 install libmaths

libmaths only supports Python 3.8 and above, so please make sure you are on the newest version.

General Usage

There are many functions, but here is one example:

from libmaths import polynomial

After that, graphing a quadratic function is as simple as:

polynomial.quadratic(2, 4, 6)

If you need more assistance, examples are provided here.

General Information

libmaths was created by me, a 14-year old high schooler at Lynbrook High School 3 days ago on 2/20/2021. libmaths exists to help reduce the incapability to make quick and accurate models in Python within seconds. With a limited usage of external libraries and access to a multitude of functions, libmaths' variety is one of the many things that makes it unique. With the creation of this library, I hope to bring simplicity and accuracy together.

Documentation

I am currently working on getting the documentation out to a website. It will be added upon completion.

Mathematical Functions

The mathematical functions provided in libmaths are listed below:

  1. Graphable Functions

    • Linear
      • Slope Intercept Form
      • Point Slope Form
      • Constant
    • Polynomial
      • Standard Quadratic
      • Vertex Form Quadratic
      • Cubic
      • Quartic
      • Quintic
      • Sextic
    • Trigonometry
      • Sine
      • Cosine
      • Tangent
  2. Visualizeable Functions

    • Constant Graph
      • ReLU
      • Sigmoid
  3. Others

    • Output / Graphable Functions
      • Logarithmic
      • Absolute Value
      • Sigmoid -> Int Output
      • Relu -> Int Output
      • isPrime
      • isSquare
      • Divisor

Public References

r/Python : r/Python Post

Future Plans

In the future, I plan on adding several different complex functions.

Contributing

First, install the required libraries:

pip install -r requirements.txt

Please remember that I am a high school student with less than half a year of experience in Python programming. I already know you can do better than me! If you have any issues, suggestions, or requests, please feel free to contact me by opening an issue or on my linkedin which can be found in my profile page.

Thanks for contributing!

Resources

Over the three days spent in creating this library, I used plenty of resources which can be found in my code. You will see links under many of my functions which you can read about the concepts in.

Feedback, comments, or questions

If you have any feedback or something you would like to tell me, please do not hesitate to share! Feel free to comment here on github or reach out to me through [email protected]!

©Vinay Venkatesh 2021

You might also like...
Lane assist for ETS2, built with the ultra-fast-lane-detection model.

Euro-Truck-Simulator-2-Lane-Assist Lane assist for ETS2, built with the ultra-fast-lane-detection model. This project was made possible by the amazing

Prototypical python implementation of the trust-region algorithm presented in Sequential Linearization Method for Bound-Constrained Mathematical Programs with Complementarity Constraints by Larson, Leyffer, Kirches, and Manns.

Prototypical python implementation of the trust-region algorithm presented in Sequential Linearization Method for Bound-Constrained Mathematical Programs with Complementarity Constraints by Larson, Leyffer, Kirches, and Manns.

An abstraction layer for mathematical optimization solvers.
An abstraction layer for mathematical optimization solvers.

MathOptInterface Documentation Build Status Social An abstraction layer for mathematical optimization solvers. Replaces MathProgBase. Citing MathOptIn

Source code, datasets and trained models for the paper Learning Advanced Mathematical Computations from Examples (ICLR 2021), by François Charton, Amaury Hayat (ENPC-Rutgers) and Guillaume Lample

Maths from examples - Learning advanced mathematical computations from examples This is the source code and data sets relevant to the paper Learning a

NaturalProofs: Mathematical Theorem Proving in Natural Language

NaturalProofs: Mathematical Theorem Proving in Natural Language NaturalProofs: Mathematical Theorem Proving in Natural Language Sean Welleck, Jiacheng

Framework that uses artificial intelligence applied to mathematical models to make predictions
Framework that uses artificial intelligence applied to mathematical models to make predictions

LiconIA Framework that uses artificial intelligence applied to mathematical models to make predictions Interface Overview Table of contents [TOC] 1 Ar

1st Solution For ICDAR 2021 Competition on Mathematical Formula Detection
1st Solution For ICDAR 2021 Competition on Mathematical Formula Detection

This project releases our 1st place solution on ICDAR 2021 Competition on Mathematical Formula Detection. We implement our solution based on MMDetection, which is an open source object detection toolbox based on PyTorch.

Official implementation for ICDAR 2021 paper "Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer"

Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer Description Convert offline handwritten mathematical expressi

PaddleRobotics is an open-source algorithm library for robots based on Paddle, including open-source parts such as human-robot interaction, complex motion control, environment perception, SLAM positioning, and navigation.

简体中文 | English PaddleRobotics paddleRobotics是基于paddle的机器人开源算法库集,包括人机交互、复杂运动控制、环境感知、slam定位导航等开源算法部分。 人机交互 主动多模交互技术TFVT-HRI 主动多模交互技术是通过视觉、语音、触摸传感器等输入机器人

Comments
  • Updated logic in isPrime to stay consistent

    Updated logic in isPrime to stay consistent

    Comment says "from 2 to value / 2" however the code uses a loop that goes all of the way up to value. I updated the logic to be more consistent with the comment above it.

    opened by alecgirman 9
  • Use OOP to simplify code

    Use OOP to simplify code

    First and foremost, it's amazing to see a 14 year old writing a library. Keep up the good work, this is a great beginning! I hope this project gets traction, it could be very useful for school/college students for their maths assignment.

    In terms of the code, there are a few ways you could improve them. Making a polynomial class is probably more efficient and scalable than writing a function for every degree.

    How to write such class can be found at https://www.python-course.eu/polynomial_class_in_python.php

    TLDR : See the code below (taken from the page above)

    
    import numpy as np
    import matplotlib.pyplot as plt
    
    
    class Polynomial:
     
    
        def __init__(self, *coefficients):
            """ input: coefficients are in the form a_n, ...a_1, a_0 
            """
            self.coefficients = list(coefficients) # tuple is turned into a list
    
            
        def __repr__(self):
            """
            method to return the canonical string representation 
            of a polynomial.
       
            """
            return "Polynomial" + str(self.coefficients)
    
        
        def __call__(self, x):    
            res = 0
            for coeff in self.coefficients:
                res = res * x + coeff
            return res 
    
        
        def degree(self):
            return len(self.coefficients)   
    
        
        def __add__(self, other):
            c1 = self.coefficients[::-1]
            c2 = other.coefficients[::-1]
            res = [sum(t) for t in zip_longest(c1, c2, fillvalue=0)]
            return Polynomial(*res)
    
        
        def __sub__(self, other):
            c1 = self.coefficients[::-1]
            c2 = other.coefficients[::-1]
            
            res = [t1-t2 for t1, t2 in zip_longest(c1, c2, fillvalue=0)]
            return Polynomial(*res)
     
    
        def derivative(self):
            derived_coeffs = []
            exponent = len(self.coefficients) - 1
            for i in range(len(self.coefficients)-1):
                derived_coeffs.append(self.coefficients[i] * exponent)
                exponent -= 1
            return Polynomial(*derived_coeffs)
    
        
        def __str__(self):
            
            def x_expr(degree):
                if degree == 0:
                    res = ""
                elif degree == 1:
                    res = "x"
                else:
                    res = "x^"+str(degree)
                return res
    
            degree = len(self.coefficients) - 1
            res = ""
    
            for i in range(0, degree+1):
                coeff = self.coefficients[i]
                # nothing has to be done if coeff is 0:
                if abs(coeff) == 1 and i < degree:
                    # 1 in front of x shouldn't occur, e.g. x instead of 1x
                    # but we need the plus or minus sign:
                    res += f"{'+' if coeff>0 else '-'}{x_expr(degree-i)}"  
                elif coeff != 0:
                    res += f"{coeff:+g}{x_expr(degree-i)}" 
    
            return res.lstrip('+')    # removing leading '+'
    
    opened by subash774 1
  • fleshed out ArithmeticSeries and GeometricSeries classes

    fleshed out ArithmeticSeries and GeometricSeries classes

    Fixed an import error and fleshed out ArithmeticSeries and GeometricSeries classes. This could be a good demo for generators, class methods and inheritance for you. :)

    opened by atharva-naik 0
  • Opening new file series and adding Polynomial class to polynomial.py

    Opening new file series and adding Polynomial class to polynomial.py

    I have added a new file for series, which you can use to implement sin, cosine series, arithmetic, geometric, harmonic etc. types of series, and I have also added a polynomial class which I talked about in my reddit post. I have made comments that might help you understand classes a bit. Please feel free to contact me if you face any issues. Best of luck and keep it up !!

    opened by atharva-naik 0
Owner
Simple
14 year old programming enthusiast with a strong passion toward AI and Machine Learning.
Simple
TFOD-MASKRCNN - Tensorflow MaskRCNN With Python

Tensorflow- MaskRCNN Steps git clone https://github.com/amalaj7/TFOD-MASKRCNN.gi

Amal Ajay 2 Jan 18, 2022
Romanian Automatic Speech Recognition from the ROBIN project

RobinASR This repository contains Robin's Automatic Speech Recognition (RobinASR) for the Romanian language based on the DeepSpeech2 architecture, tog

RACAI 10 Jan 01, 2023
Implementation of "RaScaNet: Learning Tiny Models by Raster-Scanning Image" from CVPR 2021.

RaScaNet: Learning Tiny Models by Raster-Scanning Images Deploying deep convolutional neural networks on ultra-low power systems is challenging, becau

SAIT (Samsung Advanced Institute of Technology) 5 Dec 26, 2022
The lightweight PyTorch wrapper for high-performance AI research. Scale your models, not the boilerplate.

The lightweight PyTorch wrapper for high-performance AI research. Scale your models, not the boilerplate. Website • Key Features • How To Use • Docs •

Pytorch Lightning 21.1k Jan 08, 2023
Solution to the Weather4cast 2021 challenge

This code was used for the entry by the team "antfugue" for the Weather4cast 2021 Challenge. Below, you can find the instructions for generating predi

Jussi Leinonen 13 Jan 03, 2023
Resources related to our paper "CLIN-X: pre-trained language models and a study on cross-task transfer for concept extraction in the clinical domain"

CLIN-X (CLIN-X-ES) & (CLIN-X-EN) This repository holds the companion code for the system reported in the paper: "CLIN-X: pre-trained language models a

Bosch Research 4 Dec 05, 2022
Server files for UltimateLabeling

UltimateLabeling server files Server files for UltimateLabeling. git clone https://github.com/alexandre01/UltimateLabeling_server.git cd UltimateLabel

Alexandre Carlier 4 Oct 10, 2022
Learning to Prompt for Continual Learning

Learning to Prompt for Continual Learning (L2P) Official Jax Implementation L2P is a novel continual learning technique which learns to dynamically pr

Google Research 207 Jan 06, 2023
Official implementation of FCL-taco2: Fast, Controllable and Lightweight version of Tacotron2 @ ICASSP 2021

FCL-Taco2: Towards Fast, Controllable and Lightweight Text-to-Speech synthesis (ICASSP 2021) Paper | Demo Block diagram of FCL-taco2, where the decode

Disong Wang 39 Sep 28, 2022
Official PyTorch implementation of the Fishr regularization for out-of-distribution generalization

Fishr: Invariant Gradient Variances for Out-of-distribution Generalization Official PyTorch implementation of the Fishr regularization for out-of-dist

62 Dec 22, 2022
A dataset for online Arabic calligraphy

Calliar Calliar is a dataset for Arabic calligraphy. The dataset consists of 2500 json files that contain strokes manually annotated for Arabic callig

ARBML 114 Dec 28, 2022
OptaPlanner wrappers for Python. Currently significantly slower than OptaPlanner in Java or Kotlin.

OptaPy is an AI constraint solver for Python to optimize the Vehicle Routing Problem, Employee Rostering, Maintenance Scheduling, Task Assignment, School Timetabling, Cloud Optimization, Conference S

OptaPy 211 Jan 02, 2023
Emblaze - Interactive Embedding Comparison

Emblaze - Interactive Embedding Comparison Emblaze is a Jupyter notebook widget for visually comparing embeddings using animated scatter plots. It bun

CMU Data Interaction Group 77 Nov 24, 2022
Deep learning (neural network) based remote photoplethysmography: how to extract pulse signal from video using deep learning tools

Deep-rPPG: Camera-based pulse estimation using deep learning tools Deep learning (neural network) based remote photoplethysmography: how to extract pu

Terbe Dániel 138 Dec 17, 2022
Official implementation of Meta-StyleSpeech and StyleSpeech

Meta-StyleSpeech : Multi-Speaker Adaptive Text-to-Speech Generation Dongchan Min, Dong Bok Lee, Eunho Yang, and Sung Ju Hwang This is an official code

min95 168 Dec 28, 2022
Torchyolo - Yolov3 ve Yolov4 modellerin Pytorch uygulamasıdır

TORCHYOLO : Yolo Modellerin Pytorch Uygulaması Yapılacaklar: Yolov3 model.py ve

Kadir Nar 3 Aug 22, 2022
Frequency Spectrum Augmentation Consistency for Domain Adaptive Object Detection

Frequency Spectrum Augmentation Consistency for Domain Adaptive Object Detection Main requirements torch = 1.0 torchvision = 0.2.0 Python 3 Environm

15 Apr 04, 2022
Gender Classification Machine Learning Model using Sk-learn in Python with 97%+ accuracy and deployment

Gender-classification This is a ML model to classify Male and Females using some physical characterstics Data. Python Libraries like Pandas,Numpy and

Aryan raj 11 Oct 16, 2022
Ipython notebook presentations for getting starting with basic programming, statistics and machine learning techniques

Data Science 45-min Intros Every week*, our data science team @Gnip (aka @TwitterBoulder) gets together for about 50 minutes to learn something. While

Scott Hendrickson 1.6k Dec 31, 2022
Peek-a-Boo: What (More) is Disguised in a Randomly Weighted Neural Network, and How to Find It Efficiently

Peek-a-Boo: What (More) is Disguised in a Randomly Weighted Neural Network, and How to Find It Efficiently This repository is the official implementat

VITA 4 Dec 20, 2022