Created
January 16, 2018 10:42
-
-
Save yuwash/26588d6288d24d3f544c38797239c571 to your computer and use it in GitHub Desktop.
Find best fit for Golden Ratio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_best(choice=range(1, 1080)): | |
'''Find best integer fit for the shorter side of Golden Ratio | |
Best fit has a integer-valued longer side with the smallest error to the real Golden Ratio | |
:param choice list(int): choioce of integers | |
>>> get_best() | |
(1.2018646489717657e-06, 305) | |
''' | |
return min((((x*(5**0.5)/2) % 1)/x, x) for x in choice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment