Skip to content

Instantly share code, notes, and snippets.

@cararemixed
Created January 23, 2016 05:06
Show Gist options
  • Save cararemixed/d4afe4bb5bb69b46631b to your computer and use it in GitHub Desktop.
Save cararemixed/d4afe4bb5bb69b46631b to your computer and use it in GitHub Desktop.
18.828427654877792 = 113176610252/6010943257
18.828427654877792 = 11644626562/618459851
18.828427654877792 = 1206388604803/64072721680
18.828427654877792 = 1351199027/71763774
18.828427654877792 = 1444300989908416/76708529059475
18.828427654877792 = 14697597531/780606740
18.828427654877792 = 1525114896090/81000650933
18.828427654877792 = 155558666430211/8261904248277
18.828427654877792 = 16070294714071/853512306425
18.828427654877792 = 17750568500/942753629
18.828427654877792 = 181693170597/9649938589
18.828427654877792 = 1918456341/101891479
18.828427654877792 = 20236282155/1074772813
18.828427654877792 = 20803539469/1104900518
18.828427654877792 = 216684399/11508364
18.828427654877792 = 23856510438/1267047407
18.828427654877792 = 2485713655/132019184
18.828427654877792 = 250209730942/13288933921
18.828427654877792 = 250774046109834/13318905365147
18.828427654877792 = 25471193821553/1352805145944
18.828427654877792 = 26342224093/1399066591
18.828427654877792 = 2731503500893/145073372613
18.828427654877792 = 3052970969/162146889
18.828427654877792 = 318726291287/16927929253
18.828427654877792 = 32448166031/1723360369
18.828427654877792 = 345989425789457/18375906482017
18.828427654877792 = 34872092929035/1852097985463
18.828427654877792 = 3937892105696/209146094293
18.828427654877792 = 44660049907/2371947925
18.828427654877792 = 50198734531/2666113998
18.828427654877792 = 5538684624/294166073
18.828427654877792 = 568936022229/30216863174
18.828427654877792 = 596763471899291/31694811847164
18.828427654877792 = 60343286750588/3204903131407
18.828427654877792 = 6669395606589/354219466906
18.828427654877792 = 67949303031/3608867627
18.828427654877792 = 68516560345/3638995332
18.828427654877792 = 783941713/41636069
18.828427654877792 = 847537518009125/45013717212311
18.828427654877792 = 85699871531/4551621256
18.828427654877792 = 8591655593/456312962
18.828427654877792 = 887662313516/47144792427
18.828427654877792 = 9400899107482/499292839519
18.828427654877792 = 95215379679623/5057001116870
@zhangwilling
Copy link

zhangwilling commented Sep 18, 2022

Hi, this topic is interesting, and i support your Farey Series opinion.

But if i want to sort Farey Series in SQL ( order by it ), there is no way.

And i also try to use tree path (LR) to represent the Farey Series, but DB column length is limited ( varchar or other ) , such as large number 1/1000000000, it's path is LLLLLLLLLLLLLLLLLLLLL.....(many L)

so this solution can only be used in application layer ( Service Layer ), and all records must be queried to order, cannot use convinience and performance of order by in DataBase System.

Finally, i give it up.

@cararemixed
Copy link
Author

@zhangwilling This isn't a Farey Sequence but a walk down a Stern-Brocot tree. There are important differences in the ordering you might encounter with a Farey Sequence. As far as recording a path, you have a few options for compression. One is to store two large integers which represent co-prime terms of that fraction. Another is to store the continued fraction representation of the fraction (closely related to the path and easily derived from it) but you'll have variable length limits there. Finally you can compress the path sequence using bit packing for L and R's and compress that bit string using one of many techniques (probably the most space efficient but it depends how clever you want to be).

Personally, I'd start by storing two integers (64bit would be more than enough for most applications) if you want arbitrary indexing. Keep in mind the path down the middle of the tree approaches the golden ratio which is the slowest converging term possible in the tree which means the two integers will grow at the fastest rate leading to large numbers (see also the continued fraction representation as being repeated 1's which adds the least possible information at each iteration). So if this pattern is expected to be common where you weave left and right often, you'll want to employ other encodings, maybe in addition to this but you'll end up with large terms if you walk something like LRLRLRLRLRLRLRLR...

@zhangwilling
Copy link

Finally you can compress the path sequence using bit packing for L and R's and compress that bit string using one of many techniques (probably the most space efficient but it depends how clever you want to be).

haha, i explored but not found a solution to scene of my application, but i would going on .

LexoRank is interesting, maybe i would get some inspiration from it,and it is also anther way to topic, but reblance (update many items) would still occurs in some cases.

Anyway , thank for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment