Function Repository Resource:

# Mediant

Compute the mediant of a list of non-negative rationals

Contributed by: William Gosper (with additional contributions by the Wolfram Function Repository Team)
 ResourceFunction["Mediant"][{r1,r2,…}] gives the sum of the numerators of the ri divided by the sum of their denominators.

## Details

ResourceFunction["Mediant"] will only evaluate if the input is a list of non-negative rational numbers (this includes integers).
The mediant of a list of positive rationals will always be between the smallest and the largest in the list.

## Examples

### Basic Examples (1)

Take the mediant of a pair of fractions:

 In[1]:=
 Out[1]=

### Properties and Relations (2)

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]=

### Possible Issues (1)

Mediant will not work with numbers that are not explicitly non-negative integers or rationals:

 In[8]:=
 Out[8]=

## Version History

• 1.1.0 – 24 August 2021
• 1.0.0 – 03 April 2020