#!/usr/bin/env perl # Preferred Numbers: https://perlmonks.org/?node_id=11103336 my $prev = 1; for my $this ( 2 .. 10 ) { # an x% change can fit between $prev and $this # x% changes, depending on $this # Overlap will start if x% is such that prev * (1+x%) == this * (1-x%) # algebra: # p*(1+x) = t*(1-x) # p + px = t - tx # (p+t)x = t-p # x = (t-p)/(p+t) # x% = 100%*x my $xpct = ($this-$prev) / ($this+$prev) * 100; printf "linear: %.2f .. %.2f => %.2f%%\n", $prev, $this, $xpct; } continue { $prev = $this; } print "\n"; my $prev = 1; for my $i ( 1 .. 10 ) { # now go in 10 logarithmic steps $this = $prev * (10**(1/10)); my $xpct = ($this-$prev) / ($this+$prev) * 100; printf "logarithmic: %.2f .. %.2f => %.2f%%\n", $prev, $this, $xpct; } continue { $prev = $this; } print "\n"; my $prev = 1; for my $i ( 1 .. 10 ) { # now go in 10 logarithmic steps $this = 10**($i/10); my $round_p = int($prev*10+0.5)/10; my $round_t = int($this*10+0.5)/10; my $xpct = ($round_t-$round_p) / ($round_t+$round_p) * 100; printf "rounded logarithmic: %.2f .. %.2f => %.2f%%\n", $round_p, $round_t, $xpct; } continue { $prev = $this; } __END__ linear: 1.00 .. 2.00 => 33.33% linear: 2.00 .. 3.00 => 20.00% linear: 3.00 .. 4.00 => 14.29% linear: 4.00 .. 5.00 => 11.11% linear: 5.00 .. 6.00 => 9.09% linear: 6.00 .. 7.00 => 7.69% linear: 7.00 .. 8.00 => 6.67% linear: 8.00 .. 9.00 => 5.88% linear: 9.00 .. 10.00 => 5.26% logarithmic: 1.00 .. 1.26 => 11.46% logarithmic: 1.26 .. 1.58 => 11.46% logarithmic: 1.58 .. 2.00 => 11.46% logarithmic: 2.00 .. 2.51 => 11.46% logarithmic: 2.51 .. 3.16 => 11.46% logarithmic: 3.16 .. 3.98 => 11.46% logarithmic: 3.98 .. 5.01 => 11.46% logarithmic: 5.01 .. 6.31 => 11.46% logarithmic: 6.31 .. 7.94 => 11.46% logarithmic: 7.94 .. 10.00 => 11.46% rounded logarithmic: 1.00 .. 1.30 => 13.04% rounded logarithmic: 1.30 .. 1.60 => 10.34% rounded logarithmic: 1.60 .. 2.00 => 11.11% rounded logarithmic: 2.00 .. 2.50 => 11.11% rounded logarithmic: 2.50 .. 3.20 => 12.28% rounded logarithmic: 3.20 .. 4.00 => 11.11% rounded logarithmic: 4.00 .. 5.00 => 11.11% rounded logarithmic: 5.00 .. 6.30 => 11.50% rounded logarithmic: 6.30 .. 7.90 => 11.27% rounded logarithmic: 7.90 .. 10.00 => 11.73%