# vim: set fileencoding=utf-8 : # Copyright © 2008 Jeff Epler x: return m-1, op op = p def lurg(x): """A log-like function using the 1-2-5 progression.""" lm, lo = lb(x) hi = iepic(lm+1) return lm + math.log(x/lo, hi*1./lo) def iepic(x): m = x/3 n = [1,2,5][x%3] return n * 10.**m def epic(x): """An exponent-like function using the 1-2-5 progression.""" whole = int(math.floor(x)) frac = x - whole lo = iepic(whole) hi = iepic(whole+1) return lo * (hi/lo) ** frac if __name__ == '__main__': worsterr = 0 for i in range(-100, 100): j = i*.1 e = epic(j) l = lurg(e) err = abs(l-j) if err > worsterr: worsterr = err print j, e, l, err, worsterr