Skip to main content

Advanced Python math library featuring arithmetic, calculus, trigonometry, statistics, and matrix operations built from scratch.

Project description

MathLib

A lightweight Python math utility library providing basic arithmetic, number theory, sequence operations, and mathematical helper functions.

This project is under active development and is not yet stable for production use. The library is planned to grow to 50+ functions before being published on PyPI.


Features

Basic Operations

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Modulus
  • Power
  • Absolute value
  • Rounding (round, ceil, floor)
  • Clamp (value bounding)

Statistics & Utilities

  • Minimum / Maximum
  • Average
  • Percentage calculations
  • Percentage change

Number Theory

  • GCD (Greatest Common Divisor)
  • LCM (Least Common Multiple)
  • Prime check
  • Prime factorization
  • Parity (Even / Odd)

Sequences

  • Fibonacci (number / series)
  • Range-based sum
  • Range-based product

Geometry

  • Distance (2D Euclidean distance)
  • Hypotenuse calculation

Trigonometry (radians)

  • sin, cos, tan, cot (Taylor series approximation)
  • Degree ↔ Radian conversion

Mathematical Functions

  • Factorial
  • Square root
  • Cube root
  • Nth root

Advanced Mathematics

  • Exponential function (exp)
  • Natural logarithm (ln)
  • Logarithm (log)
  • Sigmoid function
  • Numerical derivative (finite difference)
  • Numerical integral (trapezoidal rule)

Installation

Clone the repository:

    git clone https://github.com/andacberkaye/MathLib
    cd MathLib

Import

Import the module

    from Core import transactions as ts

Usage Examples

Basic Operations

    ts.add(1, 2, 3)
    ts.sub(10, 3, 2)
    ts.multi(2, 3, 4)
    ts.division(10, 2)

Advanced Math Functions

    ts.round_number(3.6)
    ts.ceil_number(3.1)
    ts.floor_number(3.9)

    ts.cube_root(27)
    ts.nth_root(16, 4)

    ts.percentage(200, 15)

    ts.sin(0)
    ts.cos(1.5708)
    ts.tan(0.7854)
    ts.cot(0.7854)
    ts.degrees_to_radians(180)
    ts.radians_to_degrees(3.14159)

    ts.hypotenuse(3, 4)

    ts.exp(1)
    ts.ln(2.71828)
    ts.log(8, 2)

    ts.sigmoid(0)

    ts.derivative(lambda x: x**2, 3)
    ts.integral(lambda x: x**2, 0, 1)

    ts.distance_2d(0, 0, 3, 4)
    ts.clamp(150, 0, 100)   

Number Theory

    ts.gcd(60, 36)
    ts.lcm(12, 18)
    ts.prime_factors(84)
    ts.is_prime(13)

Fibonacci

    ts.fibonacci(6, "series")
    ts.fibonacci(6, "number")   

Range Operations

    ts.add_range(1, 5)
    ts.product_range(1, 5)

Square Roots

    ts.sqrt(16)

Basic Operations

    from Core import transactions

Roadmap

  • Expand to 50+ functions
  • Add vector and matrix operations
  • Improve numerical stability (adaptive precision methods)
  • Add unit tests (pytest)
  • Optimize factorial and series computations
  • Add error handling improvements
  • Prepare PyPI release
  • Add documentation site (docs-style)

Notes

  • Division by zero raises errors
  • Some functions require at least one argument
  • Floating point precision may affect results
  • Trigonometric functions use Taylor series approximation
  • Logarithm and exponential functions use numerical approximations
  • Results may slightly differ from Python's math module

Status

Under active development (experimental)

Author

Python math utilities project focused on clean code and modular design.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mathlibtr-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mathlibtr-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file mathlibtr-0.1.0.tar.gz.

File metadata

  • Download URL: mathlibtr-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for mathlibtr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 529d681a834677637ffa82b74e7a49e2249060bbd7241791e4806681b1a6bc5f
MD5 6b6b14aa15d8e20e8f2fd8cb4b523482
BLAKE2b-256 38d632936f4af5a6fda26dee0e6cb21fd1bda78140bce8865b9abff71bd51d49

See more details on using hashes here.

File details

Details for the file mathlibtr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mathlibtr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for mathlibtr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8089f1de4c97618a8b881841f8c663c51a013ca614cb76da955d4f3bbcf6a406
MD5 b037d560fa35ceb50ca887a84b807b57
BLAKE2b-256 112097f7ac3b07274fb8595512d65424959a15df2ece1848c61e8d9713ef26b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page