Vector View of the Mediant

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Separately adding numerators and denominators of two fractions gives their mediant, also known as the Farey mean. In this Demonstration, fractions are represented as vectors, and the mediant is seen to be the vector sum. The mediant vector is always between the original vectors and is closer to the target slope than at least one of them.


You can drag the endpoint of either of the two vectors to different points in the plane (or click shortcut buttons) to change the vectors and the numerical values above the graph.

Numerators are plotted on the vertical axis and denominators are plotted on the horizontal axis. Therefore the slope of the vector equals the fraction it represents and nearly parallel vectors represent nearly equal fractions. You can select and display various targets (shown by a dotted red line) for comparison to fractions.

Checkboxes and toggle buttons show, hide or adjust target, grid and vector labels.


Contributed by: R. Lewis Caviness and Kenneth E. Caviness (June 2020)
Open content licensed under CC BY-NC-SA



An approximant is defined to be a rational approximation where the numerator is the best choice for the given denominator. Showing the grid gives a helpful visualization of this concept: in each column, the approximant is the dot closest to the target line.

Snapshot 1: the fractions and , together with their mediant, , which is superposed on the target line having slope

Snapshot 2: two fractions whose mediant is 19/7, very close to

Snapshot 3: two fractions, and , both -approximants, whose repeated mediants , also -approximants, can be generated by repeatedly pressing the "" shortcut button

As claimed in the caption, the mediant vector is always between the original vectors and is closer to the target slope than at least one of them. This statement can be significantly generalized, if both fractions are approximants on opposite sides of the target real number. Then their mediant is also an approximant and is closer to the target than one of the original fractions. This allows a sequence of repeated mediants to be generated; for example, keep clicking "" in Snapshot 3 to get:


Proofs of these statements and additional material relating to mediants and repeated mediants can be found in [1].


[1] R. L. Caviness and K. E. Caviness. Making Pi(e) from Scratch, Rapidly and Memorably [Video]. AMATYC Webinar (Sep 27, 2019)

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.