In mathematics, rational reconstruction is a method that allows one to recover a
rational number
In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ). The set of all ra ...
from its value
modulo a
sufficiently large
In the mathematical areas of number theory and analysis, an infinite sequence or a function is said to eventually have a certain property, if it doesn't have the said property across all its ordered instances, but will after some instances have pa ...
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
.
Problem statement
In the rational reconstruction problem, one is given as input a value
. That is,
is an integer with the property that
. The rational number
is unknown,
and the goal of the problem is to recover it from the given information.
In order for the problem to be solvable, it is necessary to assume that the modulus
is sufficiently large relative to
and
.
Typically, it is assumed that a range for the possible values of
and
is known:
and
for some two
numerical parameters
and
. Whenever
and a solution exists, the solution is unique and can be found efficiently.
Solution
Using a method from
Paul S. Wang
Paul S. Wang is a Chinese-American computer scientist, researcher, author, consultant, and academic. He is Professor Emeritus of Computer Science at Kent State University.
Wang's expertise lies in automation of mathematical computation. He has co ...
, it is possible to recover
from
and
using the
Euclidean algorithm
In mathematics, the Euclidean algorithm,Some widely used textbooks, such as I. N. Herstein's ''Topics in Algebra'' and Serge Lang's ''Algebra'', use the term "Euclidean algorithm" to refer to Euclidean division or Euclid's algorithm, is an ...
, as follows.
[.]
One puts
and
. One then repeats the following steps until the first component of ''w'' becomes
. Put
, put ''z'' = ''v'' − ''qw''. The new ''v'' and ''w'' are then obtained by putting ''v'' = ''w'' and ''w'' = ''z''.
Then with ''w'' such that
, one makes the second component positive by putting ''w'' = −''w'' if
. If