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...
Functions for easily making publication-quality figures with matplotlib.
Functions for easily making publication-quality figures with matplotlib.

Data-viz utils 📈 Functions for data visualization in matplotlib 📚 API Can be installed using pip install dvu and then imported with import dvu. You

Declarative statistical visualization library for Python
Declarative statistical visualization library for Python

Altair http://altair-viz.github.io Altair is a declarative statistical visualization library for Python. With Altair, you can spend more time understa

Cartopy - a cartographic python library with matplotlib support
Cartopy - a cartographic python library with matplotlib support

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation easy. Table of contents Overview Get in touch License an

a plottling library for python, based on D3

Hello August 2013 Hello! Maybe you're looking for a nice Python interface to build interactive, javascript based plots that look as nice as all those

A Python Library for Self Organizing Map (SOM)

SOMPY A Python Library for Self Organizing Map (SOM) As much as possible, the structure of SOM is similar to somtoolbox in Matlab. It has the followin

Multi-class confusion matrix library in Python
Multi-class confusion matrix library in Python

Table of contents Overview Installation Usage Document Try PyCM in Your Browser Issues & Bug Reports Todo Outputs Dependencies Contribution References

NorthPitch is a python soccer plotting library that sits on top of Matplotlib
NorthPitch is a python soccer plotting library that sits on top of Matplotlib

NorthPitch is a python soccer plotting library that sits on top of Matplotlib.

The interactive graphing library for Python (includes Plotly Express) :sparkles:
The interactive graphing library for Python (includes Plotly Express) :sparkles:

plotly.py Latest Release User forum PyPI Downloads License Data Science Workspaces Our recommended IDE for Plotly’s Python graphing library is Dash En

🎨 Python Echarts Plotting Library
🎨 Python Echarts Plotting Library

pyecharts Python ❤️ ECharts = pyecharts English README 📣 简介 Apache ECharts (incubating) 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达

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
DataVisualization - The evolution of my arduino and python journey. New level of competence achieved

DataVisualization - The evolution of my arduino and python journey. New level of competence achieved

1 Jan 03, 2022
Piglet-shaders - PoC of custom shaders for Piglet

Piglet custom shader PoC This is a PoC for compiling Piglet fragment shaders usi

6 Mar 10, 2022
Tandem Mass Spectrum Prediction with Graph Transformers

MassFormer This is the original implementation of MassFormer, a graph transformer for small molecule MS/MS prediction. Check out the preprint on arxiv

Röst Lab 13 Oct 27, 2022
ecoglib: visualization and statistics for high density microecog signals

ecoglib: visualization and statistics for high density microecog signals This library contains high-level analysis tools for "topos" and "chronos" asp

1 Nov 17, 2021
Python package for the analysis and visualisation of finite-difference fields.

discretisedfield Marijan Beg1,2, Martin Lang2, Samuel Holt3, Ryan A. Pepper4, Hans Fangohr2,5,6 1 Department of Earth Science and Engineering, Imperia

ubermag 12 Dec 14, 2022
A minimal Python package that produces slice plots through h5m DAGMC geometry files

A minimal Python package that produces slice plots through h5m DAGMC geometry files Installation pip install dagmc_geometry_slice_plotter Python API U

Fusion Energy 4 Dec 02, 2022
3D Vision functions with end-to-end support for deep learning developers, written in Ivy.

Ivy vision focuses predominantly on 3D vision, with functions for camera geometry, image projections, co-ordinate frame transformations, forward warping, inverse warping, optical flow, depth triangul

Ivy 61 Dec 29, 2022
A Python toolbox for gaining geometric insights into high-dimensional data

"To deal with hyper-planes in a 14 dimensional space, visualize a 3D space and say 'fourteen' very loudly. Everyone does it." - Geoff Hinton Overview

Contextual Dynamics Laboratory 1.8k Dec 29, 2022
HM02: Visualizing Interesting Datasets

HM02: Visualizing Interesting Datasets This is a homework assignment for CSCI 40 class at Claremont McKenna College. Go to the project page to learn m

Qiaoling Chen 11 Oct 26, 2021
Function Plotter: a simple application with GUI to plot mathematical functions

Function-Plotter Function Plotter is a simple application with GUI to plot mathe

Mohamed Nabawe 4 Jan 03, 2022
Extensible, parallel implementations of t-SNE

openTSNE openTSNE is a modular Python implementation of t-Distributed Stochasitc Neighbor Embedding (t-SNE) [1], a popular dimensionality-reduction al

Pavlin Poličar 1.1k Jan 03, 2023
Open-source demos hosted on Dash Gallery

Dash Sample Apps This repository hosts the code for over 100 open-source Dash apps written in Python or R. They can serve as a starting point for your

Plotly 2.7k Jan 07, 2023
Create SVG drawings from vector geodata files (SHP, geojson, etc).

SVGIS Create SVG drawings from vector geodata files (SHP, geojson, etc). SVGIS is great for: creating small multiples, combining lots of datasets in a

Neil Freeman 78 Dec 09, 2022
A Jupyter - Three.js bridge

pythreejs A Python / ThreeJS bridge utilizing the Jupyter widget infrastructure. Getting Started Installation Using pip: pip install pythreejs And the

Jupyter Widgets 844 Dec 27, 2022
Customizing Visual Styles in Plotly

Customizing Visual Styles in Plotly Code for a workshop originally developed for an Unconference session during the Outlier Conference hosted by Data

Data Design Dimension 9 Aug 03, 2022
Tools for exploratory data analysis in Python

Dora Exploratory data analysis toolkit for Python. Contents Summary Setup Usage Reading Data & Configuration Cleaning Feature Selection & Extraction V

Nathan Epstein 599 Dec 25, 2022
erdantic is a simple tool for drawing entity relationship diagrams (ERDs) for Python data model classes

erdantic is a simple tool for drawing entity relationship diagrams (ERDs) for Python data model classes. Diagrams are rendered using the venerable Graphviz library.

DrivenData 129 Jan 04, 2023
A visualization tool made in Pygame for various pathfinding algorithms.

Pathfinding-Visualizer 🚀 A visualization tool made in Pygame for various pathfinding algorithms. Pathfinding is closely related to the shortest path

Aysha sana 7 Jul 09, 2022
Eulera Dashboard is an easy and intuitive way to get a quick feel of what’s happening on the world’s market.

an easy and intuitive way to get a quick feel of what’s happening on the world’s market ! Eulera dashboard is a tool allows you to monitor historical

Salah Eddine LABIAD 4 Nov 25, 2022
Data Visualizations for the #30DayChartChallenge

The #30DayChartChallenge This repository contains all the charts made for the #30DayChartChallenge during the month of April. This project aims to exp

Isaac Arroyo 7 Sep 20, 2022