quadrivium 1.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.
Files changed (144) hide show
  1. quadrivium-1.1.0/CHANGELOG.md +83 -0
  2. quadrivium-1.1.0/CODE_OF_CONDUCT.md +30 -0
  3. quadrivium-1.1.0/CONTRIBUTING.md +84 -0
  4. quadrivium-1.1.0/LICENSE +21 -0
  5. quadrivium-1.1.0/MANIFEST.in +22 -0
  6. quadrivium-1.1.0/PKG-INFO +247 -0
  7. quadrivium-1.1.0/README.md +203 -0
  8. quadrivium-1.1.0/SECURITY.md +22 -0
  9. quadrivium-1.1.0/SUPPORT.md +19 -0
  10. quadrivium-1.1.0/docs/api/approx.md +78 -0
  11. quadrivium-1.1.0/docs/api/core.md +87 -0
  12. quadrivium-1.1.0/docs/api/diff.md +95 -0
  13. quadrivium-1.1.0/docs/api/index.md +63 -0
  14. quadrivium-1.1.0/docs/api/integrate.md +148 -0
  15. quadrivium-1.1.0/docs/api/interpolate.md +124 -0
  16. quadrivium-1.1.0/docs/api/linalg.md +214 -0
  17. quadrivium-1.1.0/docs/api/ode.md +186 -0
  18. quadrivium-1.1.0/docs/api/optimize.md +241 -0
  19. quadrivium-1.1.0/docs/api/pde.md +184 -0
  20. quadrivium-1.1.0/docs/api/rootfind.md +97 -0
  21. quadrivium-1.1.0/docs/api/special.md +82 -0
  22. quadrivium-1.1.0/docs/api/stochastic.md +149 -0
  23. quadrivium-1.1.0/docs/api/transforms.md +109 -0
  24. quadrivium-1.1.0/docs/changelog.md +86 -0
  25. quadrivium-1.1.0/docs/contributing.md +96 -0
  26. quadrivium-1.1.0/docs/design.md +146 -0
  27. quadrivium-1.1.0/docs/examples.md +77 -0
  28. quadrivium-1.1.0/docs/faq.md +105 -0
  29. quadrivium-1.1.0/docs/getting-started.md +338 -0
  30. quadrivium-1.1.0/docs/guides/approx.md +196 -0
  31. quadrivium-1.1.0/docs/guides/core.md +178 -0
  32. quadrivium-1.1.0/docs/guides/diff.md +237 -0
  33. quadrivium-1.1.0/docs/guides/integrate.md +294 -0
  34. quadrivium-1.1.0/docs/guides/interpolate.md +257 -0
  35. quadrivium-1.1.0/docs/guides/linalg.md +412 -0
  36. quadrivium-1.1.0/docs/guides/ode.md +253 -0
  37. quadrivium-1.1.0/docs/guides/optimize.md +290 -0
  38. quadrivium-1.1.0/docs/guides/pde.md +214 -0
  39. quadrivium-1.1.0/docs/guides/rootfind.md +256 -0
  40. quadrivium-1.1.0/docs/guides/special.md +195 -0
  41. quadrivium-1.1.0/docs/guides/stochastic.md +226 -0
  42. quadrivium-1.1.0/docs/guides/transforms.md +206 -0
  43. quadrivium-1.1.0/docs/index.md +128 -0
  44. quadrivium-1.1.0/docs/installation.md +127 -0
  45. quadrivium-1.1.0/docs/limitations.md +106 -0
  46. quadrivium-1.1.0/docs/release-process.md +174 -0
  47. quadrivium-1.1.0/examples/01_linear_algebra.py +96 -0
  48. quadrivium-1.1.0/examples/02_calculus.py +124 -0
  49. quadrivium-1.1.0/examples/03_differential_equations.py +131 -0
  50. quadrivium-1.1.0/examples/04_optimization.py +166 -0
  51. quadrivium-1.1.0/examples/05_pde_and_transforms.py +214 -0
  52. quadrivium-1.1.0/examples/06_extended_methods.py +210 -0
  53. quadrivium-1.1.0/mkdocs.yml +114 -0
  54. quadrivium-1.1.0/pyproject.toml +76 -0
  55. quadrivium-1.1.0/quadrivium/__init__.py +142 -0
  56. quadrivium-1.1.0/quadrivium/approx/__init__.py +15 -0
  57. quadrivium-1.1.0/quadrivium/approx/fitting.py +419 -0
  58. quadrivium-1.1.0/quadrivium/approx/orthopoly.py +323 -0
  59. quadrivium-1.1.0/quadrivium/core/__init__.py +45 -0
  60. quadrivium-1.1.0/quadrivium/core/exceptions.py +50 -0
  61. quadrivium-1.1.0/quadrivium/core/types.py +246 -0
  62. quadrivium-1.1.0/quadrivium/core/utils.py +297 -0
  63. quadrivium-1.1.0/quadrivium/diff/__init__.py +12 -0
  64. quadrivium-1.1.0/quadrivium/diff/autodiff.py +507 -0
  65. quadrivium-1.1.0/quadrivium/diff/finite.py +274 -0
  66. quadrivium-1.1.0/quadrivium/diff/spectral.py +138 -0
  67. quadrivium-1.1.0/quadrivium/integrate/__init__.py +22 -0
  68. quadrivium-1.1.0/quadrivium/integrate/adaptive.py +175 -0
  69. quadrivium-1.1.0/quadrivium/integrate/gauss.py +370 -0
  70. quadrivium-1.1.0/quadrivium/integrate/monte_carlo.py +261 -0
  71. quadrivium-1.1.0/quadrivium/integrate/multidim.py +275 -0
  72. quadrivium-1.1.0/quadrivium/integrate/newton_cotes.py +197 -0
  73. quadrivium-1.1.0/quadrivium/integrate/romberg.py +86 -0
  74. quadrivium-1.1.0/quadrivium/interpolate/__init__.py +14 -0
  75. quadrivium-1.1.0/quadrivium/interpolate/multivariate.py +287 -0
  76. quadrivium-1.1.0/quadrivium/interpolate/polynomial.py +309 -0
  77. quadrivium-1.1.0/quadrivium/interpolate/rational.py +193 -0
  78. quadrivium-1.1.0/quadrivium/interpolate/spline.py +629 -0
  79. quadrivium-1.1.0/quadrivium/linalg/__init__.py +19 -0
  80. quadrivium-1.1.0/quadrivium/linalg/direct.py +656 -0
  81. quadrivium-1.1.0/quadrivium/linalg/eigen.py +666 -0
  82. quadrivium-1.1.0/quadrivium/linalg/iterative.py +672 -0
  83. quadrivium-1.1.0/quadrivium/linalg/lstsq.py +180 -0
  84. quadrivium-1.1.0/quadrivium/linalg/matfun.py +673 -0
  85. quadrivium-1.1.0/quadrivium/linalg/sparse.py +276 -0
  86. quadrivium-1.1.0/quadrivium/ode/__init__.py +22 -0
  87. quadrivium-1.1.0/quadrivium/ode/advanced.py +518 -0
  88. quadrivium-1.1.0/quadrivium/ode/bvp.py +294 -0
  89. quadrivium-1.1.0/quadrivium/ode/explicit.py +325 -0
  90. quadrivium-1.1.0/quadrivium/ode/exponential.py +210 -0
  91. quadrivium-1.1.0/quadrivium/ode/implicit.py +352 -0
  92. quadrivium-1.1.0/quadrivium/ode/multistep.py +255 -0
  93. quadrivium-1.1.0/quadrivium/ode/symplectic.py +157 -0
  94. quadrivium-1.1.0/quadrivium/optimize/__init__.py +78 -0
  95. quadrivium-1.1.0/quadrivium/optimize/constrained.py +458 -0
  96. quadrivium-1.1.0/quadrivium/optimize/derivative_free.py +272 -0
  97. quadrivium-1.1.0/quadrivium/optimize/global_opt.py +345 -0
  98. quadrivium-1.1.0/quadrivium/optimize/gradient.py +263 -0
  99. quadrivium-1.1.0/quadrivium/optimize/linesearch.py +156 -0
  100. quadrivium-1.1.0/quadrivium/optimize/linprog.py +311 -0
  101. quadrivium-1.1.0/quadrivium/optimize/proximal.py +256 -0
  102. quadrivium-1.1.0/quadrivium/optimize/quasinewton.py +442 -0
  103. quadrivium-1.1.0/quadrivium/optimize/scalar.py +223 -0
  104. quadrivium-1.1.0/quadrivium/optimize/trustregion.py +285 -0
  105. quadrivium-1.1.0/quadrivium/pde/__init__.py +23 -0
  106. quadrivium-1.1.0/quadrivium/pde/elliptic.py +382 -0
  107. quadrivium-1.1.0/quadrivium/pde/fem.py +247 -0
  108. quadrivium-1.1.0/quadrivium/pde/fvm.py +174 -0
  109. quadrivium-1.1.0/quadrivium/pde/highres.py +321 -0
  110. quadrivium-1.1.0/quadrivium/pde/hyperbolic.py +296 -0
  111. quadrivium-1.1.0/quadrivium/pde/multigrid.py +164 -0
  112. quadrivium-1.1.0/quadrivium/pde/parabolic.py +257 -0
  113. quadrivium-1.1.0/quadrivium/pde/spectral.py +168 -0
  114. quadrivium-1.1.0/quadrivium/rootfind/__init__.py +11 -0
  115. quadrivium-1.1.0/quadrivium/rootfind/polynomial.py +335 -0
  116. quadrivium-1.1.0/quadrivium/rootfind/scalar.py +519 -0
  117. quadrivium-1.1.0/quadrivium/rootfind/systems.py +487 -0
  118. quadrivium-1.1.0/quadrivium/special/__init__.py +6 -0
  119. quadrivium-1.1.0/quadrivium/special/functions.py +1292 -0
  120. quadrivium-1.1.0/quadrivium/stochastic/__init__.py +16 -0
  121. quadrivium-1.1.0/quadrivium/stochastic/generators.py +221 -0
  122. quadrivium-1.1.0/quadrivium/stochastic/mcmc.py +294 -0
  123. quadrivium-1.1.0/quadrivium/stochastic/sampling.py +325 -0
  124. quadrivium-1.1.0/quadrivium/stochastic/sde.py +410 -0
  125. quadrivium-1.1.0/quadrivium/stochastic/stats.py +394 -0
  126. quadrivium-1.1.0/quadrivium/transforms/__init__.py +11 -0
  127. quadrivium-1.1.0/quadrivium/transforms/fourier.py +314 -0
  128. quadrivium-1.1.0/quadrivium/transforms/signal.py +346 -0
  129. quadrivium-1.1.0/quadrivium/transforms/wavelet.py +408 -0
  130. quadrivium-1.1.0/quadrivium.egg-info/PKG-INFO +247 -0
  131. quadrivium-1.1.0/quadrivium.egg-info/SOURCES.txt +142 -0
  132. quadrivium-1.1.0/quadrivium.egg-info/dependency_links.txt +1 -0
  133. quadrivium-1.1.0/quadrivium.egg-info/requires.txt +13 -0
  134. quadrivium-1.1.0/quadrivium.egg-info/top_level.txt +1 -0
  135. quadrivium-1.1.0/setup.cfg +4 -0
  136. quadrivium-1.1.0/tests/__init__.py +0 -0
  137. quadrivium-1.1.0/tests/test_calculus.py +362 -0
  138. quadrivium-1.1.0/tests/test_core_linalg.py +277 -0
  139. quadrivium-1.1.0/tests/test_docs.py +96 -0
  140. quadrivium-1.1.0/tests/test_new_modules.py +984 -0
  141. quadrivium-1.1.0/tests/test_ode_pde.py +552 -0
  142. quadrivium-1.1.0/tests/test_optimize_stochastic.py +840 -0
  143. quadrivium-1.1.0/tests/test_rootfind_interp.py +347 -0
  144. quadrivium-1.1.0/tools/gen_docs.py +357 -0
@@ -0,0 +1,83 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html):
7
+ a patch release fixes behaviour without changing the API, a minor release adds
8
+ methods or optional arguments, and a major release is required for anything
9
+ that could break an existing call.
10
+
11
+ ## [Unreleased]
12
+
13
+ Nothing yet.
14
+
15
+ ## [1.1.0] - 2026-09-01
16
+
17
+ The first release published to PyPI, under a new name. The library itself — 836
18
+ public functions and classes across 13 subpackages, depending only on NumPy —
19
+ was complete before this release; what is new here is the name, the packaging,
20
+ the documentation site, and two fixes found while writing that documentation.
21
+
22
+ ### Changed
23
+
24
+ - **The project is now Quadrivium**, developed until now as `numethods`. The
25
+ quadrivium was the medieval curriculum of the four mathematical arts —
26
+ arithmetic, geometry, music, astronomy — and it abbreviates to *quad*. Three
27
+ things changed with it, all before any public release, so no installed code
28
+ is affected:
29
+ - the distribution is `quadrivium` (`pip install quadrivium`),
30
+ - the import is `import quadrivium` (`import quadrivium as qd` throughout the
31
+ documentation, since `quad` is also the general-purpose integrator),
32
+ - the base exception is `QuadriviumError`, and the rest of the hierarchy is
33
+ unchanged.
34
+
35
+ ### Added
36
+
37
+ - **Published to PyPI** as `quadrivium`: `pip install quadrivium`. The
38
+ distribution is a pure-Python `py3-none-any` wheel, so no compiler and no
39
+ platform-specific build is involved.
40
+ - **Documentation site** at <https://ssmmkk123.github.io/quadrivium/>: a
41
+ getting-started guide covering the conventions shared by every routine, one
42
+ narrative guide per subpackage on choosing between methods that solve the
43
+ same problem, a complete API reference generated from the package itself, and
44
+ pages on design, known limitations, and the release process. Every example on
45
+ every page is a doctest executed by the test suite.
46
+ - **`docs` and `dev` extras** (`pip install "quadrivium[dev]"`) for building the
47
+ documentation and cutting a release.
48
+ - **Project metadata** for PyPI: homepage, documentation, changelog and issue
49
+ URLs, an expanded classifier and keyword set, and a single source of truth
50
+ for the version, read from `quadrivium.__version__` at build time.
51
+ - **Release automation**: a tagged push builds the distributions, checks them
52
+ with `twine`, publishes to PyPI through OIDC Trusted Publishing with no
53
+ stored credentials, and attaches the artifacts and their build attestations
54
+ to a GitHub Release.
55
+ - Tests covering the two fixes below, and tests that keep the documentation
56
+ from drifting: every documentation example is executed, and the generated API
57
+ reference is compared against the installed package.
58
+
59
+ ### Fixed
60
+
61
+ - **`illinois` and `pegasus` now converge superlinearly, as they are meant to.**
62
+ The retained endpoint's function value was being damped on *every* iteration
63
+ rather than only when the same endpoint was kept twice running. That damped
64
+ the good regula-falsi steps too, and both methods degenerated to linear
65
+ convergence with ratio 1/2 — no better than bisection — while Pegasus's
66
+ scaling collapsed onto Illinois's halving, making the two functions return
67
+ identical results. On `x³ − 2x − 5` over `[1, 3]` to `1e-12`, both now take 8
68
+ iterations rather than 41. Roots returned are unchanged; only the number of
69
+ iterations needed to reach them is.
70
+ - **`rng=` now accepts an integer seed everywhere it is documented to.**
71
+ `randomized_range_finder`, `randomized_svd`, `randomized_eigh`,
72
+ `nystrom_approximation`, `subspace_iteration`, `lobpcg`, and every SDE
73
+ routine (`brownian_path`, `euler_maruyama`, `milstein`, `gillespie_ssa`,
74
+ `tau_leaping` and the rest) passed the argument straight to a generator
75
+ method, so a seed raised `AttributeError` while `None` and a `Generator`
76
+ worked. They now normalise through `np.random.default_rng`, matching the rest
77
+ of the library.
78
+
79
+ Earlier versions were developed in the repository and never published to a
80
+ package index, so this is the first version installable with `pip`.
81
+
82
+ [Unreleased]: https://github.com/ssmmkk123/quadrivium/compare/v1.1.0...HEAD
83
+ [1.1.0]: https://github.com/ssmmkk123/quadrivium/releases/tag/v1.1.0
@@ -0,0 +1,30 @@
1
+ # Code of Conduct
2
+
3
+ ## Our commitment
4
+
5
+ We are committed to making participation in Quadrivium a respectful,
6
+ harassment-free experience for everyone, regardless of background, identity,
7
+ experience level, or viewpoint.
8
+
9
+ ## Expected behavior
10
+
11
+ - Be respectful, constructive, and considerate.
12
+ - Focus criticism on ideas and code rather than people.
13
+ - Welcome questions and differing levels of experience.
14
+ - Accept responsibility, apologize when appropriate, and learn from mistakes.
15
+
16
+ Harassment, discrimination, threats, sexualized attention, personal attacks,
17
+ doxing, and sustained disruptive behavior are not acceptable.
18
+
19
+ ## Scope and enforcement
20
+
21
+ This policy applies in project spaces and when representing the project in
22
+ public. Maintainers may edit or remove inappropriate contributions and may
23
+ temporarily or permanently restrict participation when necessary.
24
+
25
+ Report a conduct concern privately to a maintainer using the contact options
26
+ on their GitHub profile. Do not disclose sensitive details in a public issue.
27
+ All reports will be reviewed as promptly and confidentially as practical.
28
+
29
+ This policy is informed by the
30
+ [Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
@@ -0,0 +1,84 @@
1
+ # Contributing to Quadrivium
2
+
3
+ Thank you for helping improve quadrivium. Contributions may be bug fixes,
4
+ documentation improvements, new tests, performance work, or carefully scoped
5
+ numerical methods.
6
+
7
+ ## Before you start
8
+
9
+ - Search the existing issues and pull requests before opening a duplicate.
10
+ - Open an issue before making a large API change or adding a substantial new
11
+ algorithm so its scope and validation strategy can be discussed first.
12
+ - Keep each pull request focused on one coherent change.
13
+
14
+ ## Development setup
15
+
16
+ Fork and clone the repository, then create an isolated environment:
17
+
18
+ ```bash
19
+ python3 -m venv .venv
20
+ source .venv/bin/activate
21
+ python -m pip install --upgrade pip
22
+ python -m pip install -e ".[test]"
23
+ ```
24
+
25
+ On Windows PowerShell, activate the environment with
26
+ `.venv\Scripts\Activate.ps1`.
27
+
28
+ Run the complete test suite before submitting a pull request:
29
+
30
+ ```bash
31
+ python -m unittest discover -s tests
32
+ ```
33
+
34
+ That is 370 tests -- 341 covering the numerics, the rest checking that the
35
+ documentation still matches the code -- and takes about half a minute.
36
+
37
+ You can run a single module while developing:
38
+
39
+ ```bash
40
+ python -m unittest tests.test_calculus
41
+ ```
42
+
43
+ ## Numerical changes
44
+
45
+ Numerical algorithms need evidence beyond a single expected value. Where
46
+ applicable, add tests for properties such as convergence order, exactness,
47
+ conservation, stability, structural identities, or agreement with an
48
+ independent analytic solution. Include difficult boundary cases and document
49
+ the method's known limitations.
50
+
51
+ Avoid delegating the core algorithm to a high-level implementation in another
52
+ library. NumPy may be used for array operations and low-level primitives, but
53
+ the method itself should remain visible in the source.
54
+
55
+ ## Code and documentation
56
+
57
+ - Match the surrounding style and use four spaces for Python indentation.
58
+ - Add or update docstrings for public APIs.
59
+ - Keep public behavior backward compatible unless the change has been agreed
60
+ upon in an issue.
61
+ - Update the README, the guides in `docs/`, or the examples when user-facing
62
+ behavior changes.
63
+ - Add a regression test for every bug fix when practical.
64
+
65
+ The documentation is checked by the test suite, so two commands matter after
66
+ any change to the public API or to `docs/`:
67
+
68
+ ```bash
69
+ python tools/gen_docs.py # regenerate docs/api/*.md and docs/changelog.md
70
+ mkdocs build --strict # no broken links, anchors, or missing pages
71
+ ```
72
+
73
+ Examples in the documentation are written as doctests and executed by
74
+ `tests/test_docs.py`. Because doctest compares printed output exactly, convert
75
+ NumPy scalars with `float()`, `int()`, or `bool()` before displaying them, and
76
+ round to fewer digits than the method actually delivers. Install the tools with
77
+ `pip install -e ".[dev]"`.
78
+
79
+ ## Pull requests
80
+
81
+ In the pull request description, explain the problem, the approach, and how
82
+ you validated the result. CI must pass on every supported Python version.
83
+ By contributing, you agree that your work will be licensed under the project's
84
+ MIT License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Quadrivium contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # The sdist is meant to be a self-contained copy of the project: the package,
2
+ # its full test suite, the runnable examples, and the documentation sources, so
3
+ # a downstream packager can build and validate the release without a checkout.
4
+
5
+ include CHANGELOG.md
6
+ include CODE_OF_CONDUCT.md
7
+ include CONTRIBUTING.md
8
+ include SECURITY.md
9
+ include SUPPORT.md
10
+ include mkdocs.yml
11
+
12
+ recursive-include tests *.py
13
+ recursive-include examples *.py
14
+ recursive-include docs *.md
15
+ recursive-include tools *.py
16
+
17
+ # Never ship build, cache, or editor droppings.
18
+ global-exclude *.py[cod]
19
+ global-exclude .DS_Store
20
+ prune .github
21
+ prune .pytest_cache
22
+ prune **/__pycache__
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: quadrivium
3
+ Version: 1.1.0
4
+ Summary: A comprehensive from-scratch library of numerical methods for scientific computing
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/ssmmkk123/quadrivium
7
+ Project-URL: Documentation, https://ssmmkk123.github.io/quadrivium/
8
+ Project-URL: Repository, https://github.com/ssmmkk123/quadrivium
9
+ Project-URL: Changelog, https://github.com/ssmmkk123/quadrivium/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/ssmmkk123/quadrivium/issues
11
+ Keywords: numerical-methods,scientific-computing,mathematics,linear-algebra,optimization,differential-equations,quadrature,interpolation,fft,wavelets,monte-carlo,special-functions
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Education
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Programming Language :: Python :: 3 :: Only
26
+ Classifier: Topic :: Education
27
+ Classifier: Topic :: Scientific/Engineering
28
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
29
+ Classifier: Topic :: Scientific/Engineering :: Physics
30
+ Requires-Python: >=3.9
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: numpy>=1.20
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest>=7.0; extra == "test"
36
+ Provides-Extra: docs
37
+ Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
38
+ Requires-Dist: mkdocs-material<10,>=9.5; extra == "docs"
39
+ Provides-Extra: dev
40
+ Requires-Dist: quadrivium[docs,test]; extra == "dev"
41
+ Requires-Dist: build>=1.2; extra == "dev"
42
+ Requires-Dist: twine>=5.0; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # Quadrivium
46
+
47
+ [![PyPI](https://img.shields.io/pypi/v/quadrivium.svg)](https://pypi.org/project/quadrivium/)
48
+ [![Python versions](https://img.shields.io/pypi/pyversions/quadrivium.svg)](https://pypi.org/project/quadrivium/)
49
+ [![CI](https://github.com/ssmmkk123/quadrivium/actions/workflows/ci.yml/badge.svg)](https://github.com/ssmmkk123/quadrivium/actions/workflows/ci.yml)
50
+ [![Documentation](https://img.shields.io/badge/docs-github.io-blue.svg)](https://ssmmkk123.github.io/quadrivium/)
51
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
52
+
53
+ A comprehensive, from-scratch library of the numerical methods used in
54
+ scientific computing. Every algorithm is written out explicitly — LU
55
+ factorization loops over its pivots, the FFT does its own bit reversal, the
56
+ Hungarian algorithm walks its own augmenting paths — so the method itself is
57
+ readable rather than hidden behind a compiled call.
58
+
59
+ **836 public functions and classes across 13 subpackages. 370 tests, all passing.
60
+ Depends only on NumPy.**
61
+
62
+ *The quadrivium was the medieval curriculum of the four mathematical arts —
63
+ arithmetic, geometry, music, astronomy — the complete education in number.
64
+ It abbreviates to **quad**.*
65
+
66
+ 📖 **[Documentation](https://ssmmkk123.github.io/quadrivium/)** ·
67
+ [Getting started](https://ssmmkk123.github.io/quadrivium/getting-started/) ·
68
+ [Guides](https://ssmmkk123.github.io/quadrivium/guides/linalg/) ·
69
+ [API reference](https://ssmmkk123.github.io/quadrivium/api/) ·
70
+ [Changelog](CHANGELOG.md)
71
+
72
+ ## Installation
73
+
74
+ ```bash
75
+ pip install quadrivium
76
+ ```
77
+
78
+ Python 3.9 or newer, NumPy 1.20 or newer, and nothing else. The distribution is
79
+ a pure-Python wheel, so there is no compiler and no platform-specific build
80
+ involved.
81
+
82
+ For an editable development installation with the test and documentation
83
+ dependencies:
84
+
85
+ ```bash
86
+ python3 -m venv .venv
87
+ source .venv/bin/activate
88
+ python -m pip install -e ".[dev]"
89
+ python -m unittest discover -s tests
90
+ ```
91
+
92
+ ## Quick start
93
+
94
+ The documentation imports the package as `qd` rather than `quad`, so that the
95
+ library's own general-purpose integrator stays legible as `qd.quad(...)`.
96
+
97
+ ```python
98
+ import numpy as np
99
+ import quadrivium as qd
100
+
101
+ qd.brent(lambda x: x**3 - 2*x - 5, 1, 3).root # 2.0945514815423265
102
+ qd.quad(lambda x: np.exp(-x*x), -np.inf, np.inf) # sqrt(pi), to 5e-15
103
+ qd.solve_ivp(lambda t, y: -2*y, (0, 1), [1.0]).y[-1, 0]
104
+ qd.minimize(rosenbrock, [-1.2, 1.0], method="bfgs")
105
+
106
+ qd.milstein(drift, diffusion, (0, 1), [1.0]) # SDEs, strong order 1
107
+ qd.wavedec(signal, "db4", level=5) # wavelets
108
+ qd.sylvester(A, B, C) # A X + X B = C in O(n^3)
109
+ qd.gragg_bulirsch_stoer(f, (0, 10), y0) # extrapolation
110
+ qd.newton_krylov(F, x0, precond=M) # Jacobian-free Newton
111
+ qd.aaa(f, points) # rational approximation
112
+ ```
113
+
114
+ Results come back as small records — `RootResult`, `QuadratureResult`,
115
+ `ODESolution`, `OptimizeResult`, `EigenResult`, `PDESolution`, `IterationResult` —
116
+ carrying the answer together with iteration counts, residual histories,
117
+ convergence flags and a message explaining what happened:
118
+
119
+ ```pycon
120
+ >>> import quadrivium as qd
121
+ >>> result = qd.brent(lambda x: x**3 - 2*x - 5, 1, 3)
122
+ >>> round(result.root, 12), result.converged, result.method
123
+ (2.094551481542, True, 'brent')
124
+
125
+ ```
126
+
127
+ Stochastic routines take `rng=` — an integer seed or a `numpy.random.Generator` —
128
+ so every run is reproducible.
129
+
130
+ ## What is included
131
+
132
+ | Area | Methods |
133
+ |---|---|
134
+ | **`linalg`** | Gaussian elimination (4 pivoting strategies), LU/PLU/complete-pivot, Doolittle, Crout, Cholesky, LDL', QR (Gram-Schmidt, modified GS, Householder, Givens), Hessenberg, bidiagonalization, Thomas, banded and block-tridiagonal solvers, Sherman-Morrison, Woodbury · power/inverse/shifted/Rayleigh iteration, deflation, QR algorithm (plain, shifted, Francis double-shift), Jacobi eigenvalue, Lanczos, Arnoldi, Sturm bisection, SVD (one-sided Jacobi, Golub-Kahan), polar, Schur, Gershgorin, matrix exponential and functions · Jacobi, Gauss-Seidel, SOR, SSOR, Richardson, Chebyshev, steepest descent, CG, PCG, MINRES, GMRES(m), BiCG, BiCGSTAB, CGS, CGNR, LSQR, ILU(0), incomplete Cholesky, SSOR preconditioning · normal equations, QR/SVD least squares, pseudoinverse, ridge, Tikhonov, TSVD, total least squares, NNLS, equality-constrained LS · COO/CSR/CSC/DIA sparse formats, reverse Cuthill-McKee · **matrix functions**: `sqrtm` (scaled Denman-Beavers), `logm` (inverse scaling and squaring), matrix sign · **matrix equations**: Sylvester and Lyapunov by Bartels-Stewart, discrete Lyapunov by doubling, Riccati by Newton-Kleinman · Hager 1-norm condition estimation · **randomized**: range finder, randomized SVD/eigh, Nyström, interpolative and CUR decompositions · subspace iteration, LOBPCG, symmetric-definite generalized eigenproblem, QZ |
135
+ | **`rootfind`** | Bisection, false position, Illinois, Pegasus, Ridders, Brent, ITP, secant, Newton (damped, multiplicity-corrected), Halley, Chebyshev, Steffensen, Muller, inverse quadratic, fixed point, Aitken · Newton and damped Newton for systems, Broyden good/bad, Wolfe-Bittner secant, nonlinear Gauss-Seidel, continuation/homotopy, dogleg · Horner, synthetic division, deflation, Durand-Kerner, Aberth-Ehrlich, Bairstow, Laguerre, companion matrix, Sturm sequences, root bounds · **Anderson acceleration** of fixed-point iterations, **Jacobian-free Newton-Krylov** with restarted matrix-free GMRES and optional preconditioning |
136
+ | **`interpolate`** | Lagrange, Newton divided differences, forward/backward differences, Neville, barycentric, Hermite, Chebyshev, Vandermonde · linear/quadratic/cubic splines (natural, clamped, not-a-knot, periodic), Hermite, PCHIP, Akima, B-splines, Catmull-Rom, cardinal, tension, smoothing splines · Thiele continued fractions, Bulirsch-Stoer, Floater-Hormann, trigonometric, band-limited resampling · bilinear, bicubic, tensor-product, N-D regular grid, Shepard/IDW, RBF (7 kernels), kriging, barycentric triangles · **Bézier** curves (de Casteljau, exact derivative curves, subdivision), rational Bézier, **NURBS** with de Boor evaluation |
137
+ | **`approx`** | Legendre, Chebyshev T/U, Hermite (both conventions), Laguerre, Jacobi, Gegenbauer; Golub-Welsch nodes; Gauss-Legendre/Chebyshev/Hermite/Laguerre/Jacobi/Lobatto/Radau · polynomial, weighted, Chebyshev-basis and Legendre-basis fitting, exponential/power/logarithmic/rational fits, Padé approximants, Remez exchange (minimax), Fourier series and trigonometric fitting · **AAA** near-best rational approximation in barycentric form, Chebyshev economization |
138
+ | **`diff`** | Forward/backward/central differences to 4th order, five-point stencils, **Fornberg** arbitrary-order weights, differentiation matrices on non-uniform grids, Richardson extrapolation, complex-step, Savitzky-Golay · **automatic differentiation**: forward-mode `Dual`, reverse-mode `Variable` tape, `HyperDual` for exact Hessians · Fourier and Chebyshev spectral differentiation, Clenshaw evaluation |
139
+ | **`integrate`** | Riemann, midpoint, trapezoid, Simpson 1/3 and 3/8, Boole, arbitrary-degree Newton-Cotes, Romberg, Euler-Maclaurin · adaptive Simpson/trapezoid/Gauss-Kronrod, `quad` with infinite-limit transformations · Gauss-Legendre/Chebyshev/Hermite/Laguerre/Jacobi/Lobatto/Radau/Kronrod, Clenshaw-Curtis, Fejér, **tanh-sinh** (with an endpoint-offset form for full precision on singularities) · Monte Carlo, stratified, importance, control variates, antithetic, quasi-MC (Halton/Sobol/LHS), VEGAS, hit-or-miss · double/triple integrals with variable bounds, tensor-product cubature, triangle and tetrahedron rules, polar and spherical · **Filon** quadrature for oscillatory integrands, **Cauchy principal values** and Hadamard finite parts, **Smolyak sparse grids** |
140
+ | **`ode`** | Euler, Heun, midpoint, Ralston, RK3, RK4, RK-3/8, arbitrary Butcher tableaux; embedded adaptive RKF45, Cash-Karp, Dormand-Prince, Bogacki-Shampine with PI step control and dense output · backward Euler, trapezoidal, implicit midpoint, θ-method, Gauss-Legendre IRK, Radau IIA, Lobatto IIIC, SDIRK, ESDIRK, TR-BDF2, BDF1-6, Rosenbrock · Adams-Bashforth 1-6, Adams-Moulton 1-5, predictor-corrector, Nyström, Milne-Simpson, variable-step Adams · symplectic Euler, leapfrog, velocity/position Verlet, Ruth3, Forest-Ruth, Yoshida4, PEFRL · exponential Euler, ETD-RK2/RK4, exponential Rosenbrock, Magnus, Krylov `expm` action · shooting, multiple shooting, linear shooting, finite-difference BVP, collocation, Galerkin, Sturm-Liouville · **Gragg-Bulirsch-Stoer** extrapolation with adaptive order, modified midpoint, Richardson extrapolation of any fixed-step method · **event location** on the dense output, with direction filtering and terminal events · **Runge-Kutta-Nyström** and Störmer-Cowell for second-order systems · **index-1 DAEs** by BDF, singular mass matrices, **delay equations** by the method of steps · stiffness detection |
141
+ | **`pde`** | Heat FTCS/BTCS/Crank-Nicolson/θ, 2-D ADI, method of lines, reaction-diffusion, advection-diffusion · wave (explicit and implicit), upwind, Lax-Friedrichs, Lax-Wendroff, Beam-Warming, MacCormack, leapfrog, TVD with 7 flux limiters, Godunov for Burgers · Poisson/Laplace/Helmholtz (5-point and 4th-order 9-point Mehrstellen), Jacobi/Gauss-Seidel/SOR/CG iterations, FFT fast solver, Neumann problems · **multigrid** V-cycle, W-cycle, full multigrid · 1-D P1/P2 and 2-D triangular finite elements · finite volume with Rusanov/HLL/exact Riemann fluxes and MUSCL reconstruction · Fourier and Chebyshev spectral solvers, Kuramoto-Sivashinsky · **WENO3/WENO5** reconstruction with **SSP-RK2/RK3** time stepping · incompressible **Navier-Stokes** by Chorin projection, vorticity-streamfunction pseudo-spectral solver, lid-driven cavity |
142
+ | **`optimize`** | Golden section, Fibonacci, ternary, parabolic, Brent, 1-D Newton · Armijo, Goldstein, Wolfe, strong Wolfe (interpolating zoom), exact line search · gradient descent, momentum, Nesterov, AdaGrad, RMSProp, Adam, nonlinear CG (FR/PR/HS), Barzilai-Borwein · Newton, modified Newton, BFGS, DFP, SR1, Broyden class, L-BFGS · trust region with Cauchy/dogleg/Steihaug-CG subproblems, Gauss-Newton, Levenberg-Marquardt, `curve_fit` · Nelder-Mead, Powell, Hooke-Jeeves, compass/pattern search, coordinate descent · simulated annealing, particle swarm, differential evolution, genetic algorithm, basin hopping, **CMA-ES**, dual annealing · penalty, log-barrier, augmented Lagrangian, projected gradient, SQP, active-set QP, KKT residuals · ISTA, FISTA, ADMM, Douglas-Rachford, LASSO, ridge, elastic net · simplex (two-phase, Big-M, Bland's rule), primal-dual interior point, Hungarian assignment · **truncated Newton (Newton-CG)** with forcing sequences and negative-curvature handling, **L-BFGS-B** with bound constraints |
143
+ | **`transforms`** | Direct DFT, radix-2 Cooley-Tukey, Bluestein chirp-z, mixed-radix, real FFT, 2-D FFT, DCT-I/II/III/IV, DST-I/II, Hartley · convolution (direct and FFT), correlation, autocorrelation, Wiener deconvolution, periodogram, Welch, spectrogram, Hilbert transform, resampling, low-pass filtering, **18 window functions** (Kaiser, flat-top, Blackman-Harris, Nuttall, Bohman, Parzen, …) in symmetric and periodic forms · **wavelets**: DWT/IDWT for 11 orthogonal families (Haar, Daubechies, Symlet, Coiflet), multi-level, 2-D, stationary (shift-invariant) transform, universal-threshold denoising, continuous wavelet transform with Morlet and Ricker, Goertzel |
144
+ | **`stochastic`** | LCG, Park-Miller, xorshift, **MT19937**, middle-square, van der Corput, Halton, Sobol, Latin hypercube, dual-lattice spectral test · inverse transform, Box-Muller, Marsaglia polar, rejection, **adaptive rejection (Gilks-Wild)**, ratio of uniforms, Walker alias table, multivariate normal · Metropolis-Hastings, random-walk Metropolis, Gibbs, **HMC**, NUTS-lite, slice sampling, parallel tempering, ESS, autocorrelation time, Gelman-Rubin · descriptive statistics, Welford, linear/polynomial/logistic regression, PCA, KDE, bootstrap, jackknife, permutation tests, t/χ²/KS/ANOVA · **SDE solvers**: Euler-Maruyama, Milstein (explicit and drift-implicit), stochastic Heun and Runge-Kutta, order-1.5 additive-noise Taylor, tamed Euler · Brownian paths and bridges, exact GBM/Ornstein-Uhlenbeck samplers, CIR with full truncation · **Gillespie SSA** and tau-leaping for reaction networks |
145
+ | **`special`** | Gamma, log-gamma, digamma, **polygamma**, beta, incomplete gamma and beta, erf/erfc/erfinv, **erfcx**, **Dawson**, **Fresnel** integrals, Bessel J/Y/I/K to arbitrary integer order, **spherical Bessel**, Airy, complete elliptic integrals, exponential integrals E_n, sine/cosine integrals, **Riemann zeta on the whole real line** (Euler-Maclaurin, Borwein, functional equation), **Lambert W** (both real branches), **confluent and Gauss hypergeometric**, **associated Legendre and spherical harmonics**, Struve H0 |
146
+
147
+ ## Documentation
148
+
149
+ The [documentation site](https://ssmmkk123.github.io/quadrivium/) carries the
150
+ material this README only summarizes:
151
+
152
+ - **[Getting started](https://ssmmkk123.github.io/quadrivium/getting-started/)** —
153
+ the conventions every routine shares: calling patterns, the seven result
154
+ records, tolerances, how failure is reported, reproducible randomness, and an
155
+ honest account of performance.
156
+ - **[Guides](https://ssmmkk123.github.io/quadrivium/guides/linalg/)** — one per
157
+ subpackage, each opening with a table that maps a situation to a method, then
158
+ working through the choice with runnable examples.
159
+ - **[API reference](https://ssmmkk123.github.io/quadrivium/api/)** — all 836
160
+ public names with real signatures, generated from the package itself.
161
+ - **[Design and validation](https://ssmmkk123.github.io/quadrivium/design/)** and
162
+ **[known limitations](https://ssmmkk123.github.io/quadrivium/limitations/)**.
163
+
164
+ Every example on those pages is a doctest executed by the test suite, and the
165
+ API reference is regenerated and compared against the package, so neither can
166
+ drift from the code.
167
+
168
+ ## Design
169
+
170
+ **Every claim is tested against something independent** — an analytic solution,
171
+ an exact identity, a convergence rate, or a reference implementation. The suite
172
+ checks properties, not just values:
173
+
174
+ - convergence *orders* (RK4 improves 16× per halving, Boole 64×, BDF6 64×)
175
+ - exactness where theory demands it (Gauss rules to degree 2n−1, P1 finite
176
+ elements nodally exact in 1-D, spectral methods to machine precision)
177
+ - structural identities (Bessel Wronskians, Parseval, symplectic energy drift,
178
+ mass conservation, partition of unity, KKT conditions)
179
+ - known failure modes: FTCS blows up above r = 1/2, Lax-Wendroff oscillates at
180
+ a discontinuity while TVD limiters do not, RANDU's triples are caught lying
181
+ on 15 planes, explicit RK4 goes unstable on a stiff problem where Radau IIA
182
+ does not.
183
+ - published benchmarks: the lid-driven cavity reproduces Ghia, Ghia & Shin
184
+ (1982) to within 1% at Re = 100; randomized SVD attains the Eckart-Young
185
+ optimum to four digits; Gillespie's algorithm reproduces the exact binomial
186
+ law of a death process (χ² = 16.5 on 18 bins).
187
+
188
+ Some checks pin a method down by a property no table of constants could:
189
+ Daubechies-N wavelets must annihilate polynomials of degree below N, and do;
190
+ the Neumann Poisson solver must be second order, and is only because its
191
+ boundary uses ghost points; every flux limiter must lie in Sweby's TVD region,
192
+ and they do — two of them did not until the sign was fixed.
193
+
194
+ **Failures are reported, not hidden.** A diverging iteration returns
195
+ `converged=False` with an explanation rather than raising on overflow; a line
196
+ search that stalls at floating-point precision says so; FTCS refuses an
197
+ unstable step size and tells you how many steps you need.
198
+
199
+ **Numerical care is explicit.** Where the naive formula is wrong the code says
200
+ why: Welford's algorithm instead of `E[x²]−E[x]²`; the augmented-matrix φ
201
+ functions instead of a cancelling Taylor series (φ₁(−40) comes out exact where
202
+ the series returns −1.7 × 10⁷); overflow-free `sech` weights in tanh-sinh;
203
+ Bland's rule on degenerate simplex pivots; a positive-definiteness check before
204
+ dogleg trusts a Newton step; Kummer's transformation applied to *every* negative
205
+ argument of ₁F₁, because the alternating series loses 2|z| nepers before it
206
+ loses none; Rybicki's method for Dawson's function, where both obvious routes
207
+ overflow; the projection method's FFT inverting the symbol of the exact
208
+ difference operators it is paired with, so `div u` comes out at 10⁻¹⁶ rather
209
+ than 10⁻⁵.
210
+
211
+ **Where a limitation is real, it is documented rather than papered over.** The
212
+ Cauchy-point trust region genuinely converges only linearly; stochastic Heun
213
+ converges to the Stratonovich solution and so does *not* converge to the Itô
214
+ one; Störmer-Cowell's familiar three-step coefficients are third order despite
215
+ being widely quoted as fourth; unpreconditioned Newton-Krylov needs more Krylov
216
+ steps as a PDE mesh is refined — which is why `precond=` exists, and why it
217
+ takes n = 1000 Bratu from 102,101 residual evaluations to 21. The full list is
218
+ in [known limitations](https://ssmmkk123.github.io/quadrivium/limitations/).
219
+
220
+ ## Examples
221
+
222
+ ```bash
223
+ python examples/01_linear_algebra.py # factorizations, eigenvalues, Krylov
224
+ python examples/02_calculus.py # differentiation and quadrature
225
+ python examples/03_differential_equations.py
226
+ python examples/04_optimization.py
227
+ python examples/05_pde_and_transforms.py
228
+ python examples/06_extended_methods.py # SDEs, wavelets, matrix equations, WENO
229
+ ```
230
+
231
+ Each script prints the numbers that justify what it demonstrates — convergence
232
+ ratios, residual norms, iteration counts — rather than plotting anything.
233
+
234
+ ## Contributing
235
+
236
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for the
237
+ development workflow and the validation a numerical change needs: a
238
+ convergence order, an exactness result, a conservation law, or an identity —
239
+ not a value the code itself produced. Please report security issues according
240
+ to [SECURITY.md](SECURITY.md).
241
+
242
+ Maintainers cutting a release should follow
243
+ [the release process](https://ssmmkk123.github.io/quadrivium/release-process/).
244
+
245
+ ## License
246
+
247
+ Quadrivium is available under the [MIT License](LICENSE).