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
Schema validation just got Pythonic

Schema validation just got Pythonic schema is a library for validating Python data structures, such as those obtained from config-files, forms, extern

Vladimir Keleshev 2.7k Jan 06, 2023
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 3.2k Jan 01, 2023
Write python locally, execute SQL in your data warehouse

RasgoQL Write python locally, execute SQL in your data warehouse ≪ Read the Docs · Join Our Slack » RasgoQL is a Python package that enables you to ea

Rasgo 265 Nov 21, 2022
patchwork for matplotlib

patchworklib patchwork for matplotlib test code Preparation of example plots import seaborn as sns import numpy as np import pandas as pd #Bri

Mori Hideto 185 Jan 06, 2023
By default, networkx has problems with drawing self-loops in graphs.

By default, networkx has problems with drawing self-loops in graphs. It makes it hard to draw a graph with self-loops or to make a nicely looking chord diagram. This repository provides some code to

Vladimir Shitov 5 Jan 06, 2022
A Scheil-Gulliver simulation tool using pycalphad.

scheil A Scheil-Gulliver simulation tool using pycalphad. import matplotlib.pyplot as plt from pycalphad import Database, variables as v from scheil i

pycalphad 6 Dec 10, 2021
Simple and lightweight Spotify Overlay written in Python.

Simple Spotify Overlay This is a simple yet powerful Spotify Overlay. About I have been looking for something like this ever since I got Spotify. I th

27 Sep 03, 2022
Small project demonstrating the use of Grafana and InfluxDB for monitoring the speed of an internet connection

Speedtest monitor for Grafana A small project that allows internet speed monitoring using Grafana, InfluxDB 2 and Speedtest. Demo Requirements Docker

Joshua Ghali 3 Aug 06, 2021
Painlessly create beautiful matplotlib plots.

Announcement Thank you to everyone who has used prettyplotlib and made it what it is today! Unfortunately, I no longer have the bandwidth to maintain

Olga Botvinnik 1.6k Jan 06, 2023
Homework 2: Matplotlib and Data Visualization

Homework 2: Matplotlib and Data Visualization Overview These data visualizations were created for my introductory computer science course using Python

Sophia Huang 12 Oct 20, 2022
Some method of processing point cloud

Point-Cloud Some method of processing point cloud inversion the completion pointcloud to incomplete point cloud Some model of encoding point cloud to

Tan 1 Nov 19, 2021
Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python 564 Jan 03, 2023
Blender addon that creates a temporary window of any type from the 3D View.

CreateTempWindow2.8 Blender addon that creates a temporary window of any type from the 3D View. Features Can the following window types: 3D View Graph

3 Nov 27, 2022
This tool is designed to help administrators get an overview of their Active Directory structure.

This tool is designed to help administrators get an overview of their Active Directory structure. In the group view you can see all elements of an AD (OU, USER, GROUPS, COMPUTERS etc.). In the user v

deexno 2 Oct 30, 2022
Gesture controlled media player

Media Player Gesture Control Gesture controller for media player with MediaPipe, VLC and OpenCV. Contents About Setup About A tool for using gestures

Atharva Joshi 2 Dec 22, 2021
This is a small program that prints a user friendly, visual representation, of your current bsp tree

bspcq, q for query A bspc analyzer (utility for bspwm) This is a small program that prints a user friendly, visual representation, of your current bsp

nedia 9 Apr 24, 2022
A custom qq-plot for two sample data comparision

QQ-Plot 2 Sample Just a gist to include the custom code to draw a qq-plot in python when dealing with a "two sample problem". This means when u try to

1 Dec 20, 2021
Frbmclust - Clusterize FRB profiles using hierarchical clustering, plot corresponding parameters distributions

frbmclust Getting Started Clusterize FRB profiles using hierarchical clustering,

3 May 06, 2022
With Holoviews, your data visualizes itself.

HoloViews Stop plotting your data - annotate your data and let it visualize itself. HoloViews is an open-source Python library designed to make data a

HoloViz 2.3k Jan 04, 2023
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

Chandan Singh 16 Sep 15, 2022