Skip to main content

Advanced Vector & Linear Algebra / Numerical Methods Library

Project description

AVLGMath - Advanced Vector & Linear Algebra / Numerical Methods Library

A high-performance Python library for advanced linear algebra, numerical interpolation, numerical integration, matrix operations, and linear system solving. Optimized for numerical computing with NumPy BLAS/LAPACK backends.

Installation

pip install avlgmath

Features

  • Interpolation Methods: Newton Forward/Backward Difference, Lagrangian
  • Numerical Integration: Trapezoidal Rule, Simpson's 1/3 Rule with error estimation
  • Linear Algebra: Matrix operations, eigenvalues, eigenvectors, rank computation
  • Linear System Solving: Jacobi iteration method
  • Vector Analysis: Dependence checking
  • Differential Equations: First-order linear ODE solver
  • Taylor Series: Taylor theorem expansions for 1 and 2 variables

Quick Start

import numpy as np
from avlgmath import *

# Newton Forward Difference Interpolation
X = np.array([0, 1, 2, 3])
Y = np.array([1, 3, 7, 13])
table = nfd(X, Y)
y_interp = nfd_interpolate(X, Y, 1.5)

# Matrix Operations
A = np.array([[1, 2], [3, 4]])
eigenvalues = eigenval(A)

# Jacobi Iteration
A = np.array([[4, -1], [-1, 3]])
b = np.array([7, 5])
result = jacobi_iter(A, b, n=20)

Function Reference

Interpolation Functions

nfd(X, Y)

Newton Forward Difference Table - Creates difference table for equally spaced points

Parameter Type Description
X numpy array x-coordinates (equally spaced)
Y numpy array y-coordinates
Returns numpy array 2D array of differences
X = np.array([0, 1, 2, 3, 4])
Y = np.array([1, 2, 5, 10, 17])
table = nfd(X, Y)

nfd_interpolate(X, Y, x)

Newton Forward Difference Interpolation - Interpolates value at point x

Parameter Type Description
X numpy array x-coordinates (equally spaced)
Y numpy array y-coordinates
x float Point at which to interpolate
Returns float Interpolated value
X = np.array([0, 1, 2, 3])
Y = np.array([1, 2, 5, 10])
y_at_1_5 = nfd_interpolate(X, Y, 1.5)  # ≈ 3.375

nfdfrom_csv(path)

Load Newton forward difference from CSV file

Parameter Type Description
path str Path to CSV file with columns 'x' and 'y'
Returns numpy array Difference table

nbd(X, Y)

Newton Backward Difference Table - Creates difference table from end points

Parameter Type Description
X numpy array x-coordinates (equally spaced)
Y numpy array y-coordinates
Returns numpy array 2D array of differences

nbd_interpolate(X, Y, x)

Newton Backward Difference Interpolation - Interpolates using backward differences

Parameter Type Description
X numpy array x-coordinates (equally spaced)
Y numpy array y-coordinates
x float Point at which to interpolate
Returns float Interpolated value

nbdfrom_csv(path)

Load Newton backward difference from CSV file

Parameter Type Description
path str Path to CSV file with columns 'x' and 'y'
Returns numpy array Difference table

lagrangian(X, Y)

Lagrangian Interpolation - Creates interpolating polynomial through all points

Parameter Type Description
X numpy array x-coordinates (must be distinct)
Y numpy array y-coordinates
Returns dict Contains polynomial object and evaluation function
X = np.array([1, 2, 3])
Y = np.array([2, 3, 5])
result = lagrangian(X, Y)
y_at_1_5 = result['evaluate'](1.5)

Numerical Integration Functions

ploytrap(coefficients, a, b, n=100)

Polynomial Trapezoidal Rule - Integrates polynomial using trapezoidal method

Parameter Type Description
coefficients list/array Polynomial coefficients [c₀, c₁, c₂, ...]
a float Lower limit of integration
b float Upper limit of integration
n int Number of subintervals (default 100)
Returns float Estimated integral value
coeffs = [1, 2, 1]  # 1 + 2x + x²
result = ploytrap(coeffs, a=0, b=3, n=100)

polytrap_e(coefficients, a, b, n=100)

Trapezoidal Rule Error Estimation

Parameter Type Description
coefficients list/array Polynomial coefficients
a float Lower limit
b float Upper limit
n int Number of subintervals
Returns dict Error bound and max second derivative

polysim(coefficients, a, b, n=100)

Polynomial Simpson's 1/3 Rule - More accurate than trapezoidal

Parameter Type Description
coefficients list/array Polynomial coefficients
a float Lower limit of integration
b float Upper limit of integration
n int Number of subintervals (must be even)
Returns float Estimated integral value

polysim_e(coefficients, a, b, n=100)

Simpson's 1/3 Rule Error Estimation

Parameter Type Description
coefficients list/array Polynomial coefficients
a float Lower limit
b float Upper limit
n int Number of subintervals (must be even)
Returns dict Error bound and max fourth derivative

Matrix Operations

matrixmul(A, B)

Efficient Matrix Multiplication - BLAS-optimized

Parameter Type Description
A numpy array First matrix (m × n)
B numpy array Second matrix (n × p)
Returns numpy array Result matrix (m × p)

diagonalmul(A, diagonal=None)

Diagonal Matrix Multiplication - O(mn) instead of O(mn²)

Parameter Type Description
A numpy array 2D matrix
diagonal array/scalar Diagonal elements (None = extract from A)
Returns dict Result matrix and operation details

rankm(A)

Matrix Rank - Using efficient SVD method

Parameter Type Description
A numpy array Any 2D matrix
Returns int Rank of the matrix

eigenval(A)

Eigenvalues - For square or singular values for rectangular matrices

Parameter Type Description
A numpy array Any 2D matrix
Returns dict Type and values
A = np.array([[1, 2], [3, 4]])
result = eigenval(A)
# {'type': 'eigenvalues', 'values': array([5.372, -0.372])}

eigenvec(A)

Eigenvectors - Unique, normalized eigenvectors or singular vectors

Parameter Type Description
A numpy array Any 2D matrix
Returns dict Eigenvectors with eigenvalues

Linear System Solving

jacobi_iter(A, b, n=10, x0=None, tolerance=1e-6)

Jacobi Iteration - Solves Ax = b using iterative method

Parameter Type Description
A numpy array Coefficient matrix (n × n, square)
b numpy array Constants vector
n int Maximum iterations
x0 array Initial guess (default zero vector)
tolerance float Convergence tolerance
Returns dict Solution, convergence history, residual
A = np.array([[4, -1], [-1, 3]], dtype=float)
b = np.array([7, 5], dtype=float)
result = jacobi_iter(A, b, n=20, tolerance=1e-6)
print(result['solution'])  # [2., 1.]
print(result['converged'])  # True

Vector Analysis

depvec(vectors)

Dependent Vectors - Check linear dependence/independence

Parameter Type Description
vectors numpy array 2D array where each row is a vector
Returns dict Dependent flag (1=dependent, 0=independent)
v = np.array([[1, 0], [0, 1]])
result = depvec(v)
# {'dependent': 0, 'rank': 2, 'explanation': 'Linearly independent'}

Differential Equations

Lde(p_coeffs, q_coeffs, y0=0)

Linear Differential Equation Solver - Solves dy/dx + p(x)y = q(x)

Parameter Type Description
p_coeffs list/array Coefficients of p(x) polynomial
q_coeffs list/array Coefficients of q(x) polynomial
y0 float Initial condition y(0)
Returns dict Particular and general solutions
p_coeffs = [0, 2]  # 0 + 2x
q_coeffs = [0, 1]  # 0 + x
result = Lde(p_coeffs, q_coeffs, y0=1)

Taylor Series Functions

taylor_1var(f_expr, x0, n, x_eval=None)

Taylor Series Expansion - Single Variable

Computes the Taylor polynomial of degree n for a function around point x₀.

Parameter Type Description
f_expr str or sympy expr Function expression (e.g., "sin(x)", "exp(x)")
x0 float Center point for Taylor expansion
n int Degree of Taylor polynomial
x_eval float Optional point to evaluate Taylor approximation
Returns dict Symbolic series, value, error, terms
# Taylor expansion of sin(x) around x=0
result = taylor_1var("sin(x)", 0, 5)
print(result['series'])  # x**5/120 - x**3/6 + x

# Evaluate at x=0.1
result = taylor_1var("sin(x)", 0, 5, x_eval=0.1)
print(f"Approximation: {result['value']}")
print(f"Actual value: {result['actual_value']}")
print(f"Error: {result['error']}")

# Exponential function
result = taylor_1var("exp(x)", 0, 4, x_eval=0.5)

taylor_2var(f_expr, x0, y0, n, x_eval=None, y_eval=None)

Taylor Series Expansion - Two Variables

Computes the Taylor polynomial of degree n for a two-variable function around point (x₀, y₀).

Parameter Type Description
f_expr str or sympy expr Function of x,y (e.g., "x2 + y2", "sin(x)*cos(y)")
x0 float Center point x-coordinate
y0 float Center point y-coordinate
n int Degree of Taylor polynomial
x_eval float Optional x-coordinate for evaluation
y_eval float Optional y-coordinate for evaluation
Returns dict Symbolic series, partial derivatives, value, error
# Taylor expansion of x² + y² + xy around (0,0)
result = taylor_2var("x**2 + y**2 + x*y", 0, 0, 2)
print(result['series'])  # x**2 + x*y + y**2

# With evaluation
result = taylor_2var("x**2 + y**2 + x*y", 0, 0, 2, x_eval=0.1, y_eval=0.1)
print(f"Taylor value: {result['value']}")  # 0.03
print(f"Partial derivatives: {result['partial_derivatives']}")

# Two-variable trigonometric function
result = taylor_2var("sin(x)*cos(y)", 0, 0, 3, x_eval=0.2, y_eval=0.2)
print(f"Error: {result['error']}")

Requirements

numpy>=1.20
pandas>=1.3
scipy>=1.7
sympy>=1.9

Performance Notes

  • All functions use NumPy with BLAS/LAPACK backends
  • Matrix operations: O(n³) for multiplication
  • Interpolation: O(n) per evaluation
  • Jacobi iteration: O(n²) per iteration
  • Simpson's rule: ~100x more accurate than trapezoidal

Error Handling

Comprehensive validation included:

  • Dimension checks
  • Singular matrix detection
  • Invalid parameter ranges
  • Convergence monitoring

License

MIT License - Free to use and modify

Contact & Support

For issues, contributions, and feedback, please submit to the repository.

Citation

@software{avlgmath2026,
  title = {AVLGMath: Advanced Linear Algebra and Numerical Methods Library},
  year = {2026}
}

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

avlgmath-1.0.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

avlgmath-1.0.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file avlgmath-1.0.0.tar.gz.

File metadata

  • Download URL: avlgmath-1.0.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for avlgmath-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5daafca4c5e1c465006afcd327e934a4e2e7a9dccb06572bb8e7b0fcead9c5ec
MD5 7b742e11f8f43822863866c56a04203d
BLAKE2b-256 353b3c0d07b4ad5382079dfda3e74c5ad50bb9995731e8cc4d906d474d961d87

See more details on using hashes here.

File details

Details for the file avlgmath-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: avlgmath-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for avlgmath-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc7f9dff77ca2136bbdfca418b7b9fdba4252e90da2bcc951b507332fa64aa3
MD5 ce4d9a95b32161b92266f2aceaa772a0
BLAKE2b-256 68ecffefb5b6c23387c02665f6177fe1a00aaec2c1ec49ed5b4c0f50a1611ed2

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