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
A simple interpreted language for creating basic mathematical graphs.

graphr Introduction graphr is a small language written to create basic mathematical graphs. It is an interpreted language written in python and essent

null 2 Dec 26, 2021
Mathematical learnings with Lean, for those of us who wish we knew more of both!

Lean for the Inept Mathematician This repository contains source files for a number of articles or posts aimed at explaining bite-sized mathematical c

Julian Berman 8 Feb 14, 2022
Wikipedia WordCloud App generate Wikipedia word cloud art created using python's streamlit, matplotlib, wikipedia and wordcloud packages

Wikipedia WordCloud App Wikipedia WordCloud App generate Wikipedia word cloud art created using python's streamlit, matplotlib, wikipedia and wordclou

Siva Prakash 5 Jan 2, 2022
These data visualizations were created for my introductory computer science course using Python

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
Sentiment Analysis application created with Python and Dash, hosted at socialsentiment.net

Social Sentiment Dash Application Live-streaming sentiment analysis application created with Python and Dash, hosted at SocialSentiment.net. Dash Tuto

Harrison 456 Dec 25, 2022
Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

AutoViz Automatically Visualize any dataset, any size with a single line of code. AutoViz performs automatic visualization of any dataset with one lin

AutoViz and Auto_ViML 1k Jan 2, 2023
Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

AutoViz Automatically Visualize any dataset, any size with a single line of code. AutoViz performs automatic visualization of any dataset with one lin

AutoViz and Auto_ViML 299 Feb 13, 2021
These data visualizations were created as homework for my CS40 class. I hope you enjoy!

Data Visualizations These data visualizations were created as homework for my CS40 class. I hope you enjoy! Nobel Laureates by their Country of Birth

null 9 Sep 2, 2022
Define fortify and autoplot functions to allow ggplot2 to handle some popular R packages.

ggfortify This package offers fortify and autoplot functions to allow automatic ggplot2 to visualize statistical result of popular R packages. Check o

Sinhrks 504 Dec 23, 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 triangulation, voxel grids, point clouds, signed distance functions, and others. Check out the docs for more info!

Ivy 61 Dec 29, 2022