0

I have a sequence of numbers, described by start number, end number and a step.

E.g., if start = 4, end = 10, step = 2, the sequence will be: [4, 6, 8, 10]. The average of 1 divided by each number in the sequence will be: $$ (\frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \frac{1}{10}) \div 4 ≈ 0.1604 $$

Is it possible to calculate an average of inverses using only start, end, and step (4, 10, 2 in this example)? What is the formula? f(start, end, step) = ?

1 Answers1

0

I do not believe that this is possible. Even in the case where the step size is 1, we cannot, in general, write down the sum. That is to say, there is no general formula for $$\sum_{n=a}^b \frac{1}{n}.$$

This is explained in more detail in the top answer to the question here.

peabody
  • 550
  • 1
    is it possible to approximate this function? – user15284236 Jun 20 '22 at 16:23
  • 1
    Yes. The $n$-th harmonic number $H_n = \sum_{k=1}^n \frac{1}{k} \approx \ln(n) + \gamma$ where $\gamma$ is the Euler-Mascheroni constant $\gamma \approx 0.5772156649$. So, the sum given above could be expressed as $H_b - H_a \approx \ln(b) - \ln(a)$. Note that this is for step size one, and for larger step sizes, you will need to do some careful addition and subtraction of series. – peabody Jun 20 '22 at 16:28
  • The answer can be found with the link given by user15284236. – Christophe Leuridan Jun 20 '22 at 16:30