# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Approximately rationalize a set of numbers to give a common denominator

Contributed by:
Daniel Lichtblau

ResourceFunction["SimultaneousRationalize"][{ finds rationals | |

ResourceFunction["SimultaneousRationalize"][{ uses |

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.

Find rational approximations to a set of approximate real values:

In[1]:= |

Out[1]= |

Start with a set of approximate real values:

In[2]:= |

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

In[3]:= |

Out[3]= |

With a larger weight we obtain closer approximations:

In[4]:= |

Out[4]= |

With a sufficiently small weight we find integer approximations:

In[5]:= |

Out[5]= |

SimultaneousRationalize can work with rationals in the input:

In[6]:= |

Out[6]= |

Find rational approximations with a smaller common denominator:

In[7]:= |

Out[7]= |

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[8]:= |

Out[8]= |

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

In[9]:= |

Out[9]= |

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

In[10]:= |

Out[10]= |

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.

In[11]:= |

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

In[12]:= |

Out[12]= |

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[13]:= |

Compute candidate periodicity multiples for Cepheid 2308:

In[14]:= |

Out[14]= |

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[15]:= |

Out[15]= |

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

In[16]:= |

Out[16]= |

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

In[17]:= |

Out[17]= |

Take the average to get our period approximation:

In[18]:= |

Out[18]= |

Fold the light curve by this estimated period:

In[19]:= |

In[20]:= |

Out[20]= |

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.

- NumberTheory`Rationalize` Legacy Standard Add-On Package–Wolfram Library Archive
- Estimating Variable Star Periods from Unevenly Sampled Light Curve Data–Wolfram Notebook Archive
- Cepheid Variable Star Light Curve Analysis–Wolfram Demonstrations Project

- 1.0.0 – 01 May 2020

This work is licensed under a Creative Commons Attribution 4.0 International License