I was looking into the sum of the digits of $2^x$. When I plotted y = sum of digits of $2^x$, the relationship was very linear (as one should expect) with a correlation coefficient of $0.999587$, when I calculated to $x = 10000$. However, my question concerns the slope of the line of best fit: $1.3556600856084817$. The slope seemed to fluctuate around $1.35$. Is there any reason for this?
Here are the slopes for f(n), representing the slope of y = the sum of digits for n^x: When plotted, it appears to be logarithmic.
- f(2) = 1.3556600856084817
- f(3) = 2.1458633077830696
- f(4) = 2.709191384919649
- f(5) = 3.147413019705652
- f(6) = 3.5012234023042232
- f(7) = 3.8034815099113444
- f(8) = 4.064013020137782
- (9) = 4.293926142384194
- f(11) = 4.68565515673792
- f(12) = 4.856282415979148
- f(13) = 5.0120684909979305
- f(14) = 5.156650757838338
- f(15) = 5.29277691693154
- f(35) = 6.946651885840713
- f(99) = 8.980022856020353
- f(223) = 10.56770121473439
Does anyone have any explanation for the meaning behind these slopes?
Here is some of my sloppy python code if you want to play around with it:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
sum_npx = []
#sum of digits of n^x
def sum_of_digits(integer_list):
total_digit_sum = 0
for number in integer_list:
num_str = str(number)
for char in num_str:
if char.isdigit():
total_digit_sum += int(char)
return total_digit_sum
for _ in range(1, 10000):
sum_npx.append(sum_of_digits([int(i) for i in str(2**_)]))
x = [a for a in range(1, 10000)]
plt.plot(np.unique(x), np.poly1d(np.polyfit(x, sum_npx, 1))(np.unique(x)))
plt.plot(x, sum_npx)
plt.show()
df = {
"Array 1": x,
"Array 2": sum_npx
}
coefficients = np.polyfit(x, sum_npx, 1)
# Extract the slope (coefficient for x, which is the first element)
slope = coefficients[0]
# Print the slope
print("Slope of the line of best fit:", slope)
data = pd.DataFrame(df)
print(data.corr())
Thanks in advance.