pysolverkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: pysolverkit
3
+ Version: 0.1.0
4
+ Summary: A Python library of numerical methods for root finding, interpolation, integration, ODEs, and linear systems
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+
8
+ # PySolverKit
9
+
10
+ [![Tests](https://github.com/mrigankpawagi/PySolverKit/actions/workflows/tests.yml/badge.svg)](https://github.com/mrigankpawagi/PySolverKit/actions/workflows/tests.yml)
11
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
12
+
13
+ A compact Python library that brings classical numerical methods to life — root finding, interpolation, differentiation, integration, ODE solvers, linear systems, and 2D FEM for Poisson problems.
14
+
15
+ ## Features
16
+
17
+ - **Function arithmetic** — add, subtract, multiply, and compose built-in function types (`Polynomial`, `Sin`, `Cos`, `Tan`, `Exponent`, `Log`) with plain Python operators
18
+ - **Root finding** — bisection, Newton-Raphson, secant, Regula Falsi, and modified Newton methods
19
+ - **Interpolation** — Lagrange and Newton divided-difference forms (forward/backward difference tables included)
20
+ - **Differentiation** — forward, backward, and central finite-difference schemes; set an exact derivative for Newton-type solvers
21
+ - **Integration** — rectangular, midpoint, trapezoidal, Simpson's, and Gauss-Legendre quadrature
22
+ - **ODE solvers** — Euler, Runge-Kutta (orders 1–4), Taylor series, trapezoidal, Adams-Bashforth/Moulton, and predictor-corrector methods for first-order IVPs; shooting and finite-difference methods for second-order BVPs
23
+ - **Linear algebra** — `Vector` and `Matrix` with arithmetic operations, and `LinearSystem` with Gaussian elimination and Gauss-Jacobi/Seidel iterative solvers
24
+ - **2D FEM** — `FEM2D` for Poisson equations on rectangular domains with Dirichlet boundary conditions
25
+
26
+ ## Quick start
27
+
28
+ ```python
29
+ import math
30
+ from pysolverkit import Polynomial, Sin, RootFindingMethod, IntegrationMethod
31
+
32
+ # Root finding
33
+ f = Polynomial(-6, 14, -7, 1) # x³ − 7x² + 14x − 6
34
+ root = f.root(RootFindingMethod.BISECTION, a=0, b=1, TOLERANCE=1e-6)
35
+
36
+ # Integration
37
+ g = Sin(Polynomial(0, 1)) # sin(x)
38
+ area = g.integrate(0, math.pi, method=IntegrationMethod.SIMPSON, n=100)
39
+ ```
40
+
41
+ ## Documentation
42
+
43
+ Full API reference, detailed usage examples, and a method selector reference are in **[`docs/README.md`](docs/README.md)**.
44
+
45
+ ## Running tests
46
+
47
+ ```bash
48
+ python3 -m unittest discover -s tests -v
49
+ ```
50
+
51
+ ## Contributing
52
+
53
+ Contributions are welcome! To get started:
54
+
55
+ 1. Fork the repository and create a feature branch.
56
+ 2. Add or update tests in `tests/tests.py` for any new behaviour.
57
+ 3. Ensure all tests pass: `python3 -m unittest discover -s tests -v`
58
+ 4. Open a pull request with a clear description of the change.
@@ -0,0 +1,51 @@
1
+ # PySolverKit
2
+
3
+ [![Tests](https://github.com/mrigankpawagi/PySolverKit/actions/workflows/tests.yml/badge.svg)](https://github.com/mrigankpawagi/PySolverKit/actions/workflows/tests.yml)
4
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
5
+
6
+ A compact Python library that brings classical numerical methods to life — root finding, interpolation, differentiation, integration, ODE solvers, linear systems, and 2D FEM for Poisson problems.
7
+
8
+ ## Features
9
+
10
+ - **Function arithmetic** — add, subtract, multiply, and compose built-in function types (`Polynomial`, `Sin`, `Cos`, `Tan`, `Exponent`, `Log`) with plain Python operators
11
+ - **Root finding** — bisection, Newton-Raphson, secant, Regula Falsi, and modified Newton methods
12
+ - **Interpolation** — Lagrange and Newton divided-difference forms (forward/backward difference tables included)
13
+ - **Differentiation** — forward, backward, and central finite-difference schemes; set an exact derivative for Newton-type solvers
14
+ - **Integration** — rectangular, midpoint, trapezoidal, Simpson's, and Gauss-Legendre quadrature
15
+ - **ODE solvers** — Euler, Runge-Kutta (orders 1–4), Taylor series, trapezoidal, Adams-Bashforth/Moulton, and predictor-corrector methods for first-order IVPs; shooting and finite-difference methods for second-order BVPs
16
+ - **Linear algebra** — `Vector` and `Matrix` with arithmetic operations, and `LinearSystem` with Gaussian elimination and Gauss-Jacobi/Seidel iterative solvers
17
+ - **2D FEM** — `FEM2D` for Poisson equations on rectangular domains with Dirichlet boundary conditions
18
+
19
+ ## Quick start
20
+
21
+ ```python
22
+ import math
23
+ from pysolverkit import Polynomial, Sin, RootFindingMethod, IntegrationMethod
24
+
25
+ # Root finding
26
+ f = Polynomial(-6, 14, -7, 1) # x³ − 7x² + 14x − 6
27
+ root = f.root(RootFindingMethod.BISECTION, a=0, b=1, TOLERANCE=1e-6)
28
+
29
+ # Integration
30
+ g = Sin(Polynomial(0, 1)) # sin(x)
31
+ area = g.integrate(0, math.pi, method=IntegrationMethod.SIMPSON, n=100)
32
+ ```
33
+
34
+ ## Documentation
35
+
36
+ Full API reference, detailed usage examples, and a method selector reference are in **[`docs/README.md`](docs/README.md)**.
37
+
38
+ ## Running tests
39
+
40
+ ```bash
41
+ python3 -m unittest discover -s tests -v
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ Contributions are welcome! To get started:
47
+
48
+ 1. Fork the repository and create a feature branch.
49
+ 2. Add or update tests in `tests/tests.py` for any new behaviour.
50
+ 3. Ensure all tests pass: `python3 -m unittest discover -s tests -v`
51
+ 4. Open a pull request with a clear description of the change.
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pysolverkit"
7
+ version = "0.1.0"
8
+ description = "A Python library of numerical methods for root finding, interpolation, integration, ODEs, and linear systems"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
@@ -0,0 +1,70 @@
1
+ from .functions import (
2
+ Function,
3
+ Polynomial,
4
+ Exponent,
5
+ Sin,
6
+ Cos,
7
+ Tan,
8
+ Log,
9
+ MultiVariableFunction,
10
+ BivariateFunction,
11
+ FEM2D,
12
+ )
13
+ from .linalg import Vector, Matrix, LinearSystem
14
+ from .ode import (
15
+ OrdinaryDifferentialEquation,
16
+ LinearODE,
17
+ FirstOrderLinearODE,
18
+ SecondOrderLinearODE_BVP,
19
+ SecondOrderODE_IVP,
20
+ SecondOrderODE_BVP,
21
+ )
22
+ from .util import Util
23
+ from .enums import (
24
+ DifferentiationMethod,
25
+ IntegrationMethod,
26
+ RootFindingMethod,
27
+ InterpolationMethod,
28
+ InterpolationForm,
29
+ ODEMethod,
30
+ BVPMethod,
31
+ NonlinearBVPMethod,
32
+ LinearSolverMethod,
33
+ )
34
+
35
+ __all__ = [
36
+ # Functions
37
+ "Function",
38
+ "Polynomial",
39
+ "Exponent",
40
+ "Sin",
41
+ "Cos",
42
+ "Tan",
43
+ "Log",
44
+ "MultiVariableFunction",
45
+ "BivariateFunction",
46
+ "FEM2D",
47
+ # Linear algebra
48
+ "Vector",
49
+ "Matrix",
50
+ "LinearSystem",
51
+ # ODEs
52
+ "OrdinaryDifferentialEquation",
53
+ "LinearODE",
54
+ "FirstOrderLinearODE",
55
+ "SecondOrderLinearODE_BVP",
56
+ "SecondOrderODE_IVP",
57
+ "SecondOrderODE_BVP",
58
+ # Utilities
59
+ "Util",
60
+ # Enums
61
+ "DifferentiationMethod",
62
+ "IntegrationMethod",
63
+ "RootFindingMethod",
64
+ "InterpolationMethod",
65
+ "InterpolationForm",
66
+ "ODEMethod",
67
+ "BVPMethod",
68
+ "NonlinearBVPMethod",
69
+ "LinearSolverMethod",
70
+ ]
@@ -0,0 +1,91 @@
1
+ from enum import Enum
2
+
3
+
4
+ class DifferentiationMethod(Enum):
5
+ """Numerical differentiation method."""
6
+
7
+ FORWARD = "forward"
8
+ BACKWARD = "backward"
9
+ CENTRAL = "central"
10
+
11
+
12
+ class IntegrationMethod(Enum):
13
+ """Numerical integration (quadrature) method."""
14
+
15
+ RECTANGULAR = "rectangular"
16
+ MIDPOINT = "midpoint"
17
+ TRAPEZOIDAL = "trapezoidal"
18
+ SIMPSON = "simpson"
19
+ GAUSS = "gauss"
20
+
21
+
22
+ class RootFindingMethod(Enum):
23
+ """Root-finding method for scalar equations."""
24
+
25
+ BISECTION = "bisection"
26
+ NEWTON = "newton"
27
+ MODIFIED_NEWTON = "modified_newton"
28
+ SECANT = "secant"
29
+ REGULA_FALSI = "regula_falsi"
30
+
31
+
32
+ class InterpolationMethod(Enum):
33
+ """Polynomial interpolation method."""
34
+
35
+ LAGRANGE = "lagrange"
36
+ NEWTON = "newton"
37
+
38
+
39
+ class InterpolationForm(Enum):
40
+ """Form of Newton interpolating polynomial."""
41
+
42
+ STANDARD = "standard"
43
+ FORWARD_DIFF = "forward_diff"
44
+ BACKWARD_DIFF = "backward_diff"
45
+
46
+
47
+ class ODEMethod(Enum):
48
+ """Numerical solver for first-order ODE initial value problems."""
49
+
50
+ EULER = "euler"
51
+ RUNGE_KUTTA = "runge-kutta"
52
+ TAYLOR = "taylor"
53
+ TRAPEZOIDAL = "trapezoidal"
54
+ ADAMS_BASHFORTH = "adam-bashforth"
55
+ ADAMS_MOULTON = "adam-moulton"
56
+ PREDICTOR_CORRECTOR = "predictor-corrector"
57
+
58
+
59
+ class BVPMethod(Enum):
60
+ """Solver for second-order linear boundary value problems."""
61
+
62
+ SHOOTING = "shooting"
63
+ FINITE_DIFFERENCE = "finite_difference"
64
+
65
+
66
+ class NonlinearBVPMethod(Enum):
67
+ """Solver for second-order nonlinear boundary value problems."""
68
+
69
+ SHOOTING_NEWTON = "shooting_newton"
70
+ FINITE_DIFFERENCE = "finite_difference"
71
+
72
+
73
+ class LinearSolverMethod(Enum):
74
+ """Solver for systems of linear equations."""
75
+
76
+ GAUSS_ELIMINATION = "gauss_elimination"
77
+ GAUSS_JACOBI = "gauss_jacobi"
78
+ GAUSS_SEIDEL = "gauss_seidel"
79
+
80
+
81
+ __all__ = [
82
+ "DifferentiationMethod",
83
+ "IntegrationMethod",
84
+ "RootFindingMethod",
85
+ "InterpolationMethod",
86
+ "InterpolationForm",
87
+ "ODEMethod",
88
+ "BVPMethod",
89
+ "NonlinearBVPMethod",
90
+ "LinearSolverMethod",
91
+ ]
@@ -0,0 +1,17 @@
1
+ from .base import Function
2
+ from .elementary import Polynomial, Exponent, Sin, Cos, Tan, Log
3
+ from .multivariate import MultiVariableFunction, BivariateFunction
4
+ from .fem2d import FEM2D
5
+
6
+ __all__ = [
7
+ "Function",
8
+ "Polynomial",
9
+ "Exponent",
10
+ "Sin",
11
+ "Cos",
12
+ "Tan",
13
+ "Log",
14
+ "MultiVariableFunction",
15
+ "BivariateFunction",
16
+ "FEM2D",
17
+ ]