Skip to content

Add exact rational Projective Calculus builtins (ProjectiveRingPoint, ProjectiveQuadraticSum, ProjectiveConstant, PadeApproximant, Residue, ContourIntegrate) - #2133

Open
KarataevDmitry wants to merge 3 commits into
Mathics3:masterfrom
AI-Guiders:feat/projective-calculus-and-mcp
Open

KarataevDmitry wants to merge 3 commits into
Mathics3:masterfrom
AI-Guiders:feat/projective-calculus-and-mcp

Conversation

@KarataevDmitry

Copy link
Copy Markdown

Summary

This PR contributes an exact rational Projective Calculus engine over $\mathbb{Z}_{2^m} \to \mathbb{P}^1(\mathbb{Q})$ and $\mathbb{Q}(i, \sqrt{d-1})$ to mathics-core, eliminating floating-point series drift and branch-cut ambiguities for rational, contour, and multidimensional quadratic Fresnel integrals:

  1. ProjectiveRingPoint[m, phi]:
    • Exact Weierstrass stereographic lift from $\mathbb{Z}_{2^m}$ ($m \ge 3$) to the rational unit circle $S^1(\mathbb{Q})$ ($X^2 + Y^2 \equiv R^2$),
    • Constant one-step difference Wronskian $W_m(\varphi) = \mathcal{C}_m(\varphi)\mathcal{S}_m(\varphi+1) - \mathcal{S}_m(\varphi)\mathcal{C}_m(\varphi+1) \equiv 2^{m-2}$ across all $2^m$ ring points,
    • Scale-invariant dyadic embedding $(m, \varphi) \mapsto (m+1, 2\varphi)$ preserving exact projective coordinates $[X:Y:R] \in \mathbb{P}^2(\mathbb{Q})$ as $m \to \infty$.
  2. ProjectiveQuadraticSum[m, ndim]:
    • Closed-form $O(1)$ evaluation of the $N$-dimensional discrete Fresnel quadratic sum over $\mathbb{Z}{2^m}^N$ for arbitrary rank $m \ge 3$ and integration dimension $N \ge 1$:
      $$\mathcal{I}N(m) = \sum{\varphi \in \mathbb{Z}
      {2^m}^N} \prod_{k=1}^N \bigl(\mathcal{C}_m(\varphi_k^2) + i,\mathcal{S}_m(\varphi_k^2)\bigr) = (1 + i)^N \cdot 2^{(m-2) + N\lfloor m/2\rfloor + \lfloor N/2\rfloor(m\bmod 2)}.$$
  3. ProjectiveContourWinding[m, phases] & ProjectiveIsotropicStencil[d]:
    • Exact topological winding number on $\mathbb{Z}_{2^m}$ without floating-point $\arctan$,
    • $d$-dimensional coordination shell $O_2(d)$ ($|O_2(d)| = 2d(d-1)$) with isotropic second-moment tensor $\sum_{e\in O_2(d)} e_i e_j = 4(d-1)\delta_{ij}$ for all $d \ge 2$.
  4. ProjectiveConstant, PadeApproximant, Residue, ContourIntegrate, TrigReduce, and Integrate Projective Fast-Path:
    • Pure-rational evaluation of mathematical constants (Pi, E, Log2, GoldenRatio, Lemniscate, Gamma14, Catalan, Apery, EulerGamma) without circular floating-point transcendental calls,
    • Algebraic residues, closed contour integrals on $\mathbb{P}^1(\mathbb{C})$, Toeplitz Padé approximants, and Ostrowski–Hermite–Rothstein–Trager projective quadrature.
  5. Verification:
    • 50/50 passing pytest cases in test/builtin/numbers/test_projective_calculus.py.

Open Science Invitation & Honest Disclaimer

Science and mathematics do not belong to isolated individuals — they belong to humanity and to all thinking actors on this planet.

  • Working Core, Open to Audit: The algebraic core and all 50 unit tests in test/builtin/numbers/test_projective_calculus.py are working and verified (and backed by formal Lean 4 proofs and Wolfram Language reference suites in our open repositories AI-Guiders/guiders-mathematics and AI-Guiders/discrete-quantum-mechanics).
  • Honest Disclaimer: Even for a human working full-time alongside AI agents, a contribution of this breadth cannot be polished in isolation. Some integration points with existing mathics-core / SymPy evaluation rules, docstrings, or edge cases may contain inaccuracies, rough edges, or things that need to be split, supplemented, or re-checked.
  • Community Invitation: Everything is open like Wikipedia under free reciprocal licenses. We warmly invite the Mathics3 maintainers and the wider computer algebra community to review, test, critique, point out any flaws, and guide how best to structure or split these builtins for upstream inclusion.

…TrigReduce, Integrate fast-path) and Wolfram Language MCP Server
…ion of Pi, E, Log2, GoldenRatio, Lemniscate, Gamma14, Catalan, Apery, and EulerGamma
…ding, and ProjectiveIsotropicStencil builtins
@rocky

rocky commented Nov 26, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. I can't look at this for a few days. Hopefully @mmatera can.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants