how to add a series of powers such that f(x) = 1^1.5 + 2^1.5 + 3^1.5... + x^1.5 in a more efficient fashion

64 Views Asked by At

I am working on a programming project where I am working with the equation $$f(x) = 1^{1.5} + 2^{1.5} + 3^{1.5} + \cdots + x^{1.5},$$ which I am calculating using that formula. Unfortunately this has started slowing down my program when working with larger values of $x$. I was wondering if it were possible to simplify this equation in a way such that a computer could solve it in a much faster manner. Thank-you in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

There isn't a nice closed-form expression for your sum in terms of elementary functions, but since you're working in the context of programming presumably you need only an approximate answer. (To give a more complete answer than below it would be useful to know what kind of accuracy you require.)

Computing a series representation for the sum about $n = \infty$ gives $$\sum_{i = 1}^n i^{3 / 2} = \underbrace{\frac{2}{5} n^{5 / 2} + \frac{1}{2} n^{3 / 2} + \frac{1}{8} n^{1 / 2} + \zeta\left(-\frac{3}{2}\right)}_{h(n)} + O\left(n^{-3 /2}\right),$$ and truncating the series after the constant term, $\zeta\left(-\frac{3}{2}\right) = -0.02548520189\ldots$, yields a (comparatively computationally cheap) function $h(n)$ that gives good approximations even for small $n$:

$$\begin{array}{rrrr} n & \sum_{i = 1}^n i^{3 / 2} & h(n) & \epsilon \\ \hline 1 & 1\phantom{.82824675\ldots} & 0.99951479\ldots & \approx 5 \cdot 10^{-4} \\ 2 & 3.82842712\ldots & 3.82824675\ldots & \approx 9 \cdot 10^{-5} \\ 4 & 17.02457955\ldots & 17.02451480\ldots & \approx 2 \cdot 10^{-5} \\ 8 & 84.04953407\ldots & 84.04951109\ldots & \approx 3 \cdot 10^{-6} \\ \end{array} .$$ Here the column labeled $\epsilon$ gives (the absolute value of) the relative error. If you need greater accuracy, you can add to $h(n)$ additional terms from the series. For example, if we include the next term, $\frac{1}{1920} n^{-3/2}$, the relative error for $n = 8$ is $\approx 4 \cdot 10^{-9}$.

Remark The integral inequalities $$\int_0^{n - 1} x^{3 / 2} \,dx \leq \sum_{i = 1}^n i^{3 / 2} \leq \int_1^n x^{3 / 2} \,dx ,$$ together immediately give $$\sum_{i = 1}^n i^{3 / 2} = \frac{2}{5} n^{5 / 2} + O(n^{3 / 2}),$$ that is, the leading term of the series.

0
On

Using generalized harmonic numbers $$S_x=\sum_{n=1}^x n^{\frac 32}=H_x^{\left(-\frac{3}{2}\right)}$$ Using asymptotics

$$S_x=\frac{2 x^{5/2}}{5}\Bigg[ 1+\frac{5}{4 x}+\frac{5}{16 x^2}+\frac{5\zeta \left(-\frac{3}{2}\right)}{2x^{\frac 52}} +\frac{1}{768 x^4}-\frac{5}{43008 x^6}+O\left(\frac{1}{x}\right)\Bigg]$$ Trying with $x=123456789$ the absolute error is $5.75 \times 10^{-50}$ and the relative error is $8.48 \times 10^{-70}$

Edit

If $x$ is really large, a good approximation is $$S_x=\frac {8(x+1)}{5(4x-1)}x^{5/2}$$ whose error is $\frac{5\zeta \left(-\frac{3}{2}\right)}{2x^{\frac 52}}$.

If $x \geq 35$, the absolute relative error is smaller then $0.001$%.