RationalReconstruction
The small fraction whose image in is — the inverse of reading as .
RationalReconstruction(a, m)the with and , when there is oneSageMath
rational_reconstruction(a, m)RationalReconstruction(a, m, N, D)with explicit bounds , , and over a list of residuesTyped signatures
| Type | Package | Applies |
|---|---|---|
(integer, integer) -> rational | compute-engine | always |
(integer, integer, integer?, integer?) -> rational | number-theoryreplaces compute-engine | always |
Details
- Every residue is the image of infinitely many fractions, but at most one with — so under the default balanced bounds the answer, when it exists, is unique.
- Wang's algorithm: the extended Euclidean algorithm on , stopped at the first remainder ; the remainder and its cofactor are and .
- Not a Wolfram built-in; the name follows SageMath's
rational_reconstruction(Maple:iratrecon). - Unevaluated when no fraction within the bounds maps to . Threads over lists.
Examples
Applications #
multi-modular arithmetic: glue two images with ChineseRemainder, and the product modulus is large enough
live ↗InOut
About
| Examples | 8 |
|---|---|
| Checked against | SageMath 3 agree3 error |
| Crosswalk | SageMath |
Implementation
mapped
sagepackages/oracle/src/mappings.ts See also: PowerModList, ChineseRemainder, Rationalize, ContinuedFraction