How to approach the value of a part of the harmonic series easily

81 Views Asked by At

I currently am working on creating a computer program for cryptography, and right now I need to "teach" the computer how to find $\ln(x)$. It does not have to be very accurate, it only needs an approximate value.

Keeping that in mind, I thought I maybe could use the Riemann-sums as a way to approach the value (I know that the Euler-MacLaurin formula would be more accurate, but also harder to compute, so I figured this would be the easiest way).

I simply take the derivative of $\ln{(x)}$ becoming $\dfrac{1}{x}$. Now, if I want to know $\ln(a)$ all I need to calculate is $$\ln(a) = \sum_{k=1}^{\frac{a - 1}{dx}}\left(\frac{1}{k \cdot dx + 1} \cdot dx\right) + \ln(1)$$ Well, $\ln(1)$ is easy (it's $0$), and usually I take $dx=\dfrac{1}{100}$, which is not very accurate, but very easy to calculate. What I noticed is that $$\sum_{k=1}^{\frac{a - 1}{dx}}\left(\frac{1}{k \cdot dx + 1} \cdot dx\right)= \sum_{k=1}^{\frac{a - 1}{dx}}\left(\frac{1}{k + \frac{1}{dx}}\right)$$ making it a part of the harmonic series. E.g., let's take $dx=100$, then $$\sum_{k=1}^{\frac{a - 1}{dx}}\left(\frac{1}{k + \frac{1}{dx}}\right) = \frac{1}{1 + 100} + \frac{1}{2 + 100} + \frac{1}{3 + 100} + ... + \frac{1}{100a}$$ Can anyone think of a way to approach this value? It'd be really great if it could be pulled off with only using integers and avoiding $\ln(x)$, but since it's a math question now, and my curiosity is expanding every second, any answer would be great.