How to Convert Any Rational to a Fraction

I am trying to graph ford circles and ford spheres in Desmos. However, it requires getting the denominator of the Farey sequence once fully simplified in fractional form. I cannot find a reliable way to simplify any rational number into a fraction where I can extract the numerators and denominators. Note: I also have to get the simplifying function to work over a list of rational numbers.

I can’t find a function internal to Desmos, but Ezra Oppenheimer made a function to do this a couple years ago discussed here ( Reddit - The heart of the internet )

I just converted it so that n_umerator and d_enominator are now functions that will get you the numerator and denominator, and the graph below shows how those can be applied to a list of numbers.

Fraction Extractor | Desmos

That solution will do it! :slight_smile: Thank you for throwing in the credit, it summoned me by my CL Specialist friends. :partying_face:

2 Likes

I also did something like what you did (it’s part of a larger project), except it is not as efficient and doesn’t always work, but maybe you could give me some suggestions to make it better? (Scroll to the folder “Coordinate Plot Function”, then to Line 105 where you will find my Fraction Finding engine).