Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the mediant of a list of non-negative rationals
ResourceFunction["Mediant"][{r1,r2,…}] gives the sum of the numerators of the ri divided by the sum of their denominators. |
Take the mediant of a pair of fractions:
In[1]:= | ![]() |
Out[1]= | ![]() |
Create a list of pseudorandom positive rationals:
In[2]:= | ![]() |
Out[2]= | ![]() |
Take the mediant:
In[3]:= | ![]() |
Out[3]= | ![]() |
Check that the mediant lies between the smallest and largest:
In[4]:= | ![]() |
Out[4]= | ![]() |
In a Farey sequence, the kth element is the mediant of the (k-1)th and (k+1)th elements:
In[5]:= | ![]() |
Out[5]= | ![]() |
In[6]:= | ![]() |
Out[6]= | ![]() |
The value of the Minkowski question mark function at the mediant can be expressed in terms of the values at the Farey neighbors:
In[7]:= | ![]() |
Out[7]= | ![]() |
Mediant will not work with numbers that are not explicitly non-negative integers or rationals:
In[8]:= | ![]() |
Out[8]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License