Repository navigation
MathForge v0.9.0 - More mathematics
Pre-releaseMathForge v0.9.0 adds 65 operations, from 103 to 168, and opens five new areas: equations, sets, decimal digits, vectors and plane geometry. Every new operation pairs a producer with its own independent checker, an answer is returned only after the checker accepts it, and every result re-verifies from its JSON. The core remains pure Python with zero runtime dependencies.
New operations
| Area | New operations |
|---|---|
| Number theory | powmod, multiplicative_order, primitive_root, legendre_symbol, jacobi_symbol, sqrt_mod, next_prime, prev_prime, linear_diophantine, quadratic_continued_fraction, convergents, pell_fundamental, moebius, divisor_sigma, integer_nth_root, discrete_log, two_squares |
| Algebra | count_real_roots, complex_roots, interpolate, denest_sqrt, sturm_sequence, cyclotomic_polynomial |
| Equations and sets | solve_abs, solve_sqrt, set_union, set_intersection, set_difference, set_complement, set_symmetric_difference |
| Decimal digits and approximation | digits, rational_approximation |
| Sums and series | sum_polynomial, geometric_sum, geometric_series, polynomial_geometric_series, series_coefficients, residue |
| Integrals | trig_power_antiderivative, trig_power_integral |
| Linear algebra | matrix_power (also Matrix ** k), eigenvectors, definiteness, gram_schmidt, hermite_normal_form, smith_normal_form |
| Vectors and geometry | dot, cross, projection, triple_product, distance, polygon_area, line_intersection, orientation, convex_hull |
| Statistics and counting | correlation, linear_regression, quantile, mode, stationary_distribution, fisher_exact, partitions, derangements, bell, stirling1 |
import mathforge as mf
Q = mf.Rational
x = mf.symbol("x")
F = lambda text: mf.parse_function(text, symbols={"x": x})
assert mf.ntheory.pell_fundamental(61) == (1766319049, 226153980)
assert mf.render_text(mf.equations.solve_abs(F("abs(x - 1) + abs(x + 2)"), F("3"), x)) == "[-2, 1]"
assert mf.render_text(mf.numeric.digits(mf.sqrt(2), 20)) == "1.41421356237309504880..."
assert mf.render_text(mf.integrals.trig_power_integral(F("sin(x)^2"), x, 0, 1)) == "pi/2"
assert mf.linalg.matrix_power(mf.Matrix(((1, 1), (1, 0))), 10) == mf.Matrix(((89, 55), (55, 34)))
assert mf.geometry.polygon_area(mf.Matrix(((0, 0), (4, 0), (0, 3)))) == Q(6)
assert mf.numeric.rational_approximation(mf.sqrt(2), 100) == Q(140, 99)
assert mf.linalg.smith_normal_form(mf.Matrix(((2, 4), (6, 8)))) == (2, 4)
result = mf.operations.eigenvectors(mf.Matrix(((2, 1), (1, 2))))
assert mf.verify(mf.loads(mf.dumps(result))).verifiedWhat's new
- Number theory: modular powers, orders and primitive roots, Legendre and Jacobi symbols, modular square roots, the nearest primes, linear Diophantine equations, periodic continued fractions of quadratic irrationals and Pell's equation, the Möbius and divisor functions, integer roots, discrete logarithms modulo a prime and sums of two squares. Primes are proved, never guessed, with Pocklington certificates above the deterministic Miller–Rabin range.
- Algebra, equations and sets: distinct real roots in an interval, complex roots when every irreducible factor has degree at most two, interpolation, denesting of nested square roots, Sturm sequences and cyclotomic polynomials; equations and inequalities with absolute values or a square root, solved over the reals; union, intersection, difference, complement and symmetric difference of interval sets, decided by a checker-side cell engine.
IntervalSetgains the operators|,&,-,^and~. - Digits and approximation: decimal expansions of exact real numbers truncated to up to 10,000 places without floating point, and the closest rational with a bounded denominator, certified by its Farey neighbours.
- Analysis: closed forms of polynomial and geometric sums, exact power series coefficients up to order 4,096, residues of rational functions at rational points, and integrals of powers of sine and cosine between multiples of pi/12.
- Linear algebra, vectors and geometry: matrix powers (also
Matrix ** k), rational eigenvectors, inertia and definiteness, Gram–Schmidt orthogonalization, Hermite and Smith normal forms with unimodular certificates, dot, cross and triple products, projections, distances, signed polygon areas, line intersections, orientation and convex hulls. - Statistics and counting: correlation and least-squares lines, type-7 quantiles, modes, stationary distributions of Markov chains, Fisher's exact test, partitions, derangements, Bell numbers and Stirling numbers of the first kind.
- MCP for agents: three new area tools,
mathforge.equations,mathforge.geometryandmathforge.numeric, for 40 tools in all. Every result carries ahandle(mf:sha256:…) that the area tools accept in later calls in place of the full document, and every error carries a stablereasonandnext_actionsthat say what to try next. - Foundations: argument kinds for polynomials, interval sets and relations; a scoreboard of 167 natural requests (
tools/check_probes.py), of which 133 now get a verified answer, up from 88, and none a wrong one; andtools/new_family.py, which scaffolds and registers a new operation family. - Fix: the trusted Miller–Rabin test now uses the prime bases 2 to 41, which its stated bound requires. No shipped result was affected, because every caller stayed below
2**61.
Compatibility
Python 3.11–3.14 and the dependency-free core remain. Every v0.8 operation keeps its name, signature and result, the thirty v0.7 MCP tools keep their names and input schemas, and v1–v6 documents keep their bytes and verdicts. The new operations live in their area modules, such as mf.ntheory and mf.linalg, and in mathforge.operations, and their results use JSON v6. MCP result payloads gain handle, and MCP error objects gain reason and next_actions; a client that rejects unknown keys must accept them. Matrix * Matrix still raises InvalidInput, and its message now points to @. The checks of Taylor and power series charge every coefficient operation by its length, so a check with very long coefficients now stops at its work limit instead of running for seconds; it never accepts a claim it used to refuse.
Known limitations
Each operation documents the input sizes that fit the default budget, and larger inputs end as resource_limit_exceeded, never as a wrong value. Complex roots are given only when every irreducible factor has degree at most two; otherwise the result is deferred with a reason. Improper integrals, trigonometric and exponential equations, and digits of pi and e are not yet covered. Handles live in the MCP server process: after a restart a handle answers unknown_handle, and the full document must be sent. integer_gcd and integer_lcm on integers of thousands of bits, and solve_system, keep the costs that v0.8 documented.
Install
MathForge is not published on PyPI. Install the wheel attached below:
python -m pip install https://github.com/U-C4N/MathForge/releases/download/v0.9.0/mathforge-0.9.0-py3-none-any.whlThe wheel and source distribution are built from the v0.9.0 tag; SHA-256 checksums are included. See the README, the v0.9 mathematics guide, the example and the changelog.
Validation includes 2,581 automated tests, executable documentation, typing and layering checks, a differential comparison with SymPy 1.14, and isolated wheel and sdist installations. CI passed on Linux and Windows with Python 3.11–3.14, with distribution checks also passing on macOS/Python 3.14.