Skip to main content

A comprehensive mathematics library... Growing daily with new functions

Project description

🧮 numcore

A comprehensive mathematics library built from scratch by a first-year student. Growing daily with new functions across statistics, number theory, linear algebra, and more.

PyPI version Python

🚀 Installation

pip install numcore

📖 Usage

Statistical Analysis

from numcore import (mean, median, std, analyze_list, covariance, 
                     z_score, coefficient_of_variation)

data = [23, 45, 67, 45, 89, 34, 78, 98, 54, 55]
print(mean(data))      # 58.8
print(std(data))       # 23.82

# Advanced stats
print(z_score(75, data))                    # Standard score
print(coefficient_of_variation(data))       # Relative variability
print(covariance([1,2,3], [2,4,6]))        # Covariance

Means (Arithmetic, Geometric, Harmonic)

from numcore import mean, geometric_mean, harmonic_mean

data = [2, 4, 8]
print(mean(data))             # 4.67 (arithmetic)
print(geometric_mean(data))   # 4.0 (geometric)
print(harmonic_mean(data))    # 3.43 (harmonic)

Number Theory

from numcore import (is_prime, gcd, euler_totient, mobius,
                     legendre_symbol, is_coprime, catalan_number)

print(is_prime(17))          # True
print(euler_totient(9))      # 6
print(mobius(30))            # -1
print(is_coprime(8, 15))     # True
print(catalan_number(5))     # 42

Sequences

from numcore import (fibonacci, arithmetic_seq, geometric_seq,
                     lucas, collatz, harmonic_series)

print(fibonacci(10))            # [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
print(arithmetic_seq(2, 3, 5))  # [2, 5, 8, 11, 14]
print(geometric_seq(2, 3, 4))   # [2, 6, 18, 54]
print(harmonic_series(5))       # 2.283... (1 + 1/2 + 1/3 + 1/4 + 1/5)

Combinatorics & Probability

from numcore import npr, ncr, binomial_coeff

print(npr(5, 3))           # 60 (permutations)
print(ncr(5, 3))           # 10 (combinations)
print(binomial_coeff(5, 2)) # 10 (same as ncr)

Financial Mathematics

from numcore import rate_of_return

print(rate_of_return(110, 100))  # 10.0% gain
print(rate_of_return(90, 100))   # -10.0% loss

✨ Features

Input Functions (2)

  • n_input(n) - Get n integers with validation
  • input_matrix() - Interactive matrix input

Basic Statistics (6)

  • mean(lst) - Arithmetic mean
  • median(lst) - Middle value
  • mode(lst) - Most common value(s)
  • variance(lst, sample) - Variance
  • std(lst, sample) - Standard deviation
  • analyze_list(lst) - Comprehensive analysis

Advanced Statistics (7)

  • geometric_mean(lst) - Geometric mean
  • harmonic_mean(lst) - Harmonic mean
  • covariance(lst1, lst2) - Covariance
  • z_score(x, lst) - Standard score
  • percentile(lst, p) - pth percentile value
  • coefficient_of_variation(lst) - Relative variability (CV)
  • mean_absolute_deviation(lst) - MAD

Number Theory (22)

  • factorial(n), nth_root(num, n)
  • divisors(num), proper_divisors(num), common_divisors(a,b)
  • gcd(a, b), lcm(a, b)
  • is_prime(num), primes(num)
  • prime_divisors(num), prime_factorization(num), prime_factors(num)
  • is_perfect(num), is_armstrong(num), is_amicable(a,b)
  • euler_totient(num) - Euler's φ function
  • mobius(num) - Möbius μ function
  • quadratic_residue(num), quadratic_non_residue(num)
  • legendre_symbol(a, p) - Legendre symbol
  • is_coprime(a, b) - Check if coprime
  • catalan_number(n) - nth Catalan number

Sequences (15)

  • Fibonacci: fibonacci(n), nth_fibonacci(n)
  • Lucas: lucas(n), nth_lucas(n)
  • Arithmetic: arithmetic_seq(a,d,n), nth_arithmetic(a,d,n), arithmetic_sum(a,d,n)
  • Geometric: geometric_seq(a,r,n), nth_geometric(a,r,n), geometric_sum(a,r,n)
  • Harmonic: harmonic_seq(a,d,n), nth_harmonic(a,d,n), harmonic_sum(a,d,n)
  • Special: collatz(n), farey(num), harmonic_series(n)

Combinatorics (3)

  • npr(n, r) - Permutations
  • ncr(n, r) - Combinations
  • binomial_coeff(n, k) - Binomial coefficient

Digit Operations (3)

  • digits(num) - Extract digits as list
  • reverse_number(num) - Reverse digits
  • sum_of_digits(num) - Sum all digits

List Utilities (4)

  • counter(lst) - Count occurrences
  • product(lst) - Multiply all elements
  • power_list(lst, power) - Apply power to each
  • reciprocal_list(lst) - Calculate reciprocals

Basic Matrix Operations (8)

  • create_matrix(rows, cols, fill) - Create matrix
  • matrix_shape(matrix) - Get dimensions
  • matrix_add(mat1, mat2) - Addition
  • matrix_sub(mat1, mat2) - Subtraction
  • scalar_multiply(matrix, scalar) - Scalar multiplication
  • matrix_multiply(mat1, mat2) - Matrix multiplication
  • print_matrix(matrix) - Pretty print

Advanced Matrix Operations (9)

  • matrix_identity(n) - Identity matrix
  • matrix_transpose(matrix) - Transpose
  • matrix_trace(matrix) - Trace
  • determinant(matrix) - Determinant (recursive)
  • matrix_minor(matrix) - Matrix of minors
  • matrix_cofactor(matrix) - Cofactor matrix
  • matrix_power(matrix, n) - Matrix exponentiation
  • is_square(matrix) - Check if square
  • is_orthogonal(matrix) - Check orthogonality

Utility Functions (2)

  • signum(x) - Sign function
  • rate_of_return(current, original) - Financial return %

🎯 Roadmap

  • Statistical analysis (basic & advanced)
  • Number theory suite
  • Sequence generation
  • Matrix operations (basic & advanced)
  • Combinatorics
  • Trigonometry (sin, cos, tan with degrees)
  • Linear algebra (eigenvalues, decomposition)
  • Calculus (derivatives, integrals)
  • Probability distributions
  • Graph theory
  • Optimization algorithms
  • And more... continuously growing!

📊 Current Library

Total Functions: 84

Growing daily with new mathematical capabilities!

💡 Example Use Cases

Portfolio Analysis

from numcore import rate_of_return, mean, std

returns = [5.2, -2.1, 8.3, 3.4, -1.5]
avg_return = mean(returns)
volatility = std(returns)
print(f"Average: {avg_return}%, Volatility: {volatility}%")

Data Science: Z-Scores

from numcore import z_score

exam_scores = [72, 85, 90, 65, 88, 92, 78]
your_score = 88

z = z_score(your_score, exam_scores)
print(f"Your z-score: {z:.2f}")  # How many std devs above/below mean

Catalan Numbers (Binary Trees)

from numcore import catalan_number

# How many different binary trees with n nodes?
for n in range(6):
    print(f"{n} nodes: {catalan_number(n)} trees")
# 0: 1, 1: 1, 2: 2, 3: 5, 4: 14, 5: 42

Covariance (Relationship Between Variables)

from numcore import covariance

hours_studied = [2, 4, 6, 8, 10]
exam_scores = [55, 65, 75, 85, 95]

cov = covariance(hours_studied, exam_scores)
print(f"Covariance: {cov}")  # Positive = both increase together

🛠️ Development

Requirements

  • Python 3.7+
  • No external dependencies!

Organization

Functions are organized by category for easy navigation and use.

📝 License

MIT License - see LICENSE file for details

👨‍💻 Author

Ujwal Mantri

🌟 Support

If you find this helpful:

  • ⭐ Star on GitHub
  • 📦 pip install numcore
  • 📢 Share with others

🎓 Learning Journey

Milestones

  • ✅ Published to PyPI
  • ✅ 84+ functions implemented
  • ✅ Advanced statistics suite
  • ✅ Complete sequence generation
  • ✅ Graduate-level number theory
  • 🎯 Next: Organizing into modules
  • 🔄 Continuously adding new functions

What Makes This Special

  • Built from scratch by first-year student
  • Pure Python (zero dependencies)
  • Comprehensive documentation
  • Real mathematical algorithms
  • Open source learning resource
  • Growing daily!

📚 Function Categories

Category Count Status
Statistics 13 ✅ Comprehensive
Number Theory 22 🔄 Growing
Sequences 15 ✅ Complete
Combinatorics 3 🔄 Growing
Matrix Operations 17 ✅ Complete
List Utilities 4 ✅ Complete
Digit Operations 3 ✅ Complete
Financial Math 1 🔄 Starting
Utilities 2 🔄 Starting
Input/Output 2 ✅ Complete
Total 84+ 🔄 Active Development

Crafted with Python. Powered by curiosity. Open-sourced for learning. ⚡

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

numcore-0.1.10.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

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

numcore-0.1.10-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file numcore-0.1.10.tar.gz.

File metadata

  • Download URL: numcore-0.1.10.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for numcore-0.1.10.tar.gz
Algorithm Hash digest
SHA256 1c29507c58b64037b14563367053a3c4d667234118654ef55c12ed8d70f4ddd2
MD5 6cf5eaae4e583ed1693963d526d9434f
BLAKE2b-256 120b6ccd050da8ee188927cdb5eea6b4989425592cf932b90f8b63ccddb9f443

See more details on using hashes here.

File details

Details for the file numcore-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: numcore-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for numcore-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1c21dd57826dc60ff59a0eec4f2a271c1acdb9061180ce9642d8a988e03d1ea0
MD5 ec07832ee452955944071383baba8ff1
BLAKE2b-256 cbed592a407bd92c7a085ae17f78f062cd8cc9cd4619e7f8fca83d218cea87f8

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