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
FedTorch is an open-source Python package for distributed and federated training of machine learning models using PyTorch distributed API

FedTorch is a generic repository for benchmarking different federated and distributed learning algorithms using PyTorch Distributed API.

Machine Learning and Optimization Lab @PennState 136 Dec 23, 2022
UV matrix decompostion using movielens dataset

UV-matrix-decompostion-with-kfold UV matrix decompostion using movielens dataset upload the 'ratings.dat' file install the following python libraries

2 Oct 18, 2022
The repo contains the code of the ACL2020 paper `Dice Loss for Data-imbalanced NLP Tasks`

Dice Loss for NLP Tasks This repository contains code for Dice Loss for Data-imbalanced NLP Tasks at ACL2020. Setup Install Package Dependencies The c

223 Dec 17, 2022
Tutorial for the PERFECTING FACTORY 5.0 WITH EDGE-POWERED AI workshop

Workshop Advantech Jetson Nano This tutorial has been designed for the PERFECTING FACTORY 5.0 WITH EDGE-POWERED AI workshop in collaboration with Adva

Edge Impulse 18 Nov 22, 2022
NeuPy is a Tensorflow based python library for prototyping and building neural networks

NeuPy v0.8.2 NeuPy is a python library for prototyping and building neural networks. NeuPy uses Tensorflow as a computational backend for deep learnin

Yurii Shevchuk 729 Jan 03, 2023
Open-CyKG: An Open Cyber Threat Intelligence Knowledge Graph

Open-CyKG: An Open Cyber Threat Intelligence Knowledge Graph Model Description Open-CyKG is a framework that is constructed using an attenti

Injy Sarhan 34 Jan 05, 2023
Code for our method RePRI for Few-Shot Segmentation. Paper at http://arxiv.org/abs/2012.06166

Region Proportion Regularized Inference (RePRI) for Few-Shot Segmentation In this repo, we provide the code for our paper : "Few-Shot Segmentation Wit

Malik Boudiaf 138 Dec 12, 2022
Motion planning algorithms commonly used on autonomous vehicles. (path planning + path tracking)

Overview This repository implemented some common motion planners used on autonomous vehicles, including Hybrid A* Planner Frenet Optimal Trajectory Hi

Huiming Zhou 1k Jan 09, 2023
RP-GAN: Stable GAN Training with Random Projections

RP-GAN: Stable GAN Training with Random Projections This repository contains a reference implementation of the algorithm described in the paper: Behna

Ayan Chakrabarti 20 Sep 18, 2021
FOSS Digital Asset Distribution Platform built on Frappe.

Digistore FOSS Digital Assets Marketplace. Distribute digital assets, like a pro. Video Demo Here Features Create, attach and list digital assets (PDF

Mohammad Hussain Nagaria 30 Dec 08, 2022
Controlling the MicriSpotAI robot from scratch

Abstract: The SpotMicroAI project is designed to be a low cost, easily built quadruped robot. The design is roughly based off of Boston Dynamics quadr

Florian Wilk 405 Jan 05, 2023
Car Price Predictor App used to predict the price of the car based on certain input parameters created using python's scikit-learn, fastapi, numpy and joblib packages.

Pricefy Car Price Predictor App used to predict the price of the car based on certain input parameters created using python's scikit-learn, fastapi, n

Siva Prakash 1 May 10, 2022
An implementation of Fastformer: Additive Attention Can Be All You Need in TensorFlow

Fast Transformer This repo implements Fastformer: Additive Attention Can Be All You Need by Wu et al. in TensorFlow. Fast Transformer is a Transformer

Rishit Dagli 139 Dec 28, 2022
Code and Experiments for ACL-IJCNLP 2021 Paper Mind Your Outliers! Investigating the Negative Impact of Outliers on Active Learning for Visual Question Answering.

Code and Experiments for ACL-IJCNLP 2021 Paper Mind Your Outliers! Investigating the Negative Impact of Outliers on Active Learning for Visual Question Answering.

Sidd Karamcheti 50 Nov 16, 2022
code associated with ACL 2021 DExperts paper

DExperts Hi! This repository contains code for the paper DExperts: Decoding-Time Controlled Text Generation with Experts and Anti-Experts to appear at

Alisa Liu 68 Dec 15, 2022
RealFormer-Pytorch Implementation of RealFormer using pytorch

RealFormer-Pytorch Implementation of RealFormer using pytorch. Includes comparison with classical Transformer on image classification task (ViT) wrt C

Simo Ryu 90 Dec 08, 2022
Supplementary code for the AISTATS 2021 paper "Matern Gaussian Processes on Graphs".

Matern Gaussian Processes on Graphs This repo provides an extension for gpflow with Matérn kernels, inducing variables and trainable models implemente

41 Dec 17, 2022
Retinal Vessel Segmentation with Pixel-wise Adaptive Filters (ISBI 2022)

Retinal Vessel Segmentation with Pixel-wise Adaptive Filters (ISBI 2022) Introdu

anonymous 14 Oct 27, 2022
Simple and Distributed Machine Learning

Synapse Machine Learning SynapseML (previously MMLSpark) is an open source library to simplify the creation of scalable machine learning pipelines. Sy

Microsoft 3.9k Dec 30, 2022
Evolutionary Population Curriculum for Scaling Multi-Agent Reinforcement Learning

Evolutionary Population Curriculum for Scaling Multi-Agent Reinforcement Learning This is the code for implementing the MADDPG algorithm presented in

97 Dec 21, 2022