I stumbled across an interesting algorithm for finding rational approximations to real numbers: Farey Approximation. I found an implementation in Python and C++, but they did not always give the expected answer. I simplified the code, and I was able to get the values that one would expect.

More from Chris Capobianco