Function Repository Resource:

# SimultaneousRationalize

Approximately rationalize a set of numbers to give a common denominator

Contributed by: Daniel Lichtblau
 ResourceFunction["SimultaneousRationalize"][{v1,v2,…}] finds rationals r1,r2,… approximating v1,v2,… such that the ri share a small common denominator. ResourceFunction["SimultaneousRationalize"][{v1,v2,…},weight] uses weight to influence the size of the resulting denominator.

## Details and Options

ResourceFunction["SimultaneousRationalize"] uses lattice reduction to obtain a common denominator.
Larger values of weight tend to give closer approximations, albeit with larger denominators.
The default value for weight is 20.
ResourceFunction["SimultaneousRationalize"] can take a set of rationals as input and produce an approximating set with a smaller common denominator.
ResourceFunction["SimultaneousRationalize"] is similar to the legacy package function NumberTheory`Rationalize`AffineRationalize.

## Examples

### Basic Examples (1)

Find rational approximations to a set of approximate real values:

 In:= Out= ### Scope (7)

 In:= Use the weight argument to find rational approximations with a small common denominator:

 In:= Out= With a larger weight we obtain closer approximations:

 In:= Out= With a sufficiently small weight we find integer approximations:

 In:= Out= SimultaneousRationalize can work with rationals in the input:

 In:= Out= Find rational approximations with a smaller common denominator:

 In:= Out= The values in question are approximately commensurate, i.e. all are multiples of a common value. In this case the smallest element in the list:

 In:= Out= ### Possible Issues (2)

Values that are small in magnitude compared to unity will often be approximated by zero:

 In:= Out= Use a weight commensurate with the reciprocal of the smallest value to force the approximation to be nonzero:

 In:= Out= ### Neat Examples (9)

Simultaneous rationalization can be used on light curve data to estimate the period of a variable star. We will take for our example Kepler project data for the Cepheid star 2308. The reference period at the OGLE web site is given as 5.7373087 days. Data and more can also be found at the Wolfram Demonstration "CepheidVariableStarLightCurve" by Jeffrey Bryant. This example is also found in the resource function IrregularPeriodogram.

Import the data from OGLE:

 In:= Separate into observation times and light intensities, and subtract the average from the set of values:

 In:= Out= We extract candidate period multiples as follows. The idea is that "common" time differences for approximately equal values correspond to times that are separated by a multiple of the basic period. (1) Compute an ϵ for proximity (a small fraction of the range of values). (2) Find all time differences between pairs that have their respective values within this ϵ. (3) Separate time differences into bins according to whether they are in proximity. This step uses an input threshold for proximity, with default of 0.1. (4) Cull out those time differences that do not appear often. This step uses an input minimum for bin sizes, with default of 15. (5) Take means of each retained bin. These are the candidate approximations for multiples of periodicities.

Utility function to find candidate periodicity multiples:

 In:= Compute candidate periodicity multiples for Cepheid 2308:

 In:= Out= Remove the smallest value since it is too small to be a period and is most likely an artifact of the average sampling time gap:

 In:= Out= Use simultaneous Diophantine approximation to find integer ratios that approximate the period multiple ratios:

 In:= Out= Divide the approximated period multiples by the approximated multipliers (the initial multiplier is assumed to be unity):

 In:= Out= Take the average to get our period approximation:

 In:= Out= Fold the light curve by this estimated period:

 In:= In:= Out= The "fuzz" points are due to the estimate being off in the second decimal place, but still one can clearly discern the main wave pattern.

## Version History

• 1.0.0 – 01 May 2020