login
Number of decimal places of Pi given by integer approximations of the form a^(1/n).
0

%I #24 Jan 27 2022 21:59:33

%S 0,0,2,2,4,2,3,4,5,5,6,6,6,6,9,9,9,10,10,11,11,13,12,13,13,14,14,14

%N Number of decimal places of Pi given by integer approximations of the form a^(1/n).

%C Approximations are rounded, not truncated; see the example for n=2. Note that this can produce anomalous results; e.g., 0.148 does not match 0.152 to 1-place accuracy, but does match it to 2-place accuracy. - _Franklin T. Adams-Watters_, Mar 29 2014

%F a(n) is the number of decimal_places in (round(Pi^n))^1/n w.r.t. Pi.

%F Note that round(Pi^n) is the sequence A002160 (Nearest integer to Pi^n).

%e a(8)=4 because 9489^(1/8) = 3.1416... is Pi accurate to 4 decimal places.

%e a(2)=0. 10^(1/2) = 3.16... rounded to one place is 3.2, while Pi to one place is 3.1.

%o (Python)

%o from math import pi, floor, ceil

%o def round(x):

%o return math.floor(x + 0.5)

%o def decimal_places(x, y):

%o dp = -1

%o # Compare integer part, shift 1 dp

%o while floor(x + 0.5) == floor(y + 0.5) and x and y:

%o x = (x - floor(x)) * 10

%o y = (y - floor(y)) * 10

%o dp = dp + 1

%o return dp

%o for n in range(1, 30):

%o pi_to_the_n = pow(pi, n)

%o pi_to_the_n_rnd = round(pi_to_the_n)

%o pi_approx = pow(pi_to_the_n_rnd, 1.0 / n)

%o dps = decimal_places(pi_approx, pi)

%o print(dps)

%Y Cf. A002160.

%K nonn,base,more

%O 1,3

%A Stephen McInerney (spmcinerney(AT)hotmail.com), Jul 22 2007