I need to compute $\sum_{i=1}^n (x_i) ^ a$ for many different values of a where n is large and x is fixed.
I am in an environment where computing exponentials $(x_i) ^ a$ is effectively constant time.
Computing the sum directly takes O(n) time. Are there any alternative options that are faster?
Actually, I just came up with a solution that will probably work in my setting, but might not in others.
In my particular situation, I know $\text{abs}(a \, \log(x_i))$ is quite small.
In that case, I can use the Taylor series with t terms:
$$\sum_{i=1}^n (x_i) ^ a = \sum_{i=1}^n \sum_{j=0}^t \frac{a^j \, \log^{j}(x_i)}{j!} = \sum_{j=0}^t \frac{a^j}{j!} \left(\sum_{i=1}^n \, \log^{j}(x_i) \right)$$
This will have decent convergence if and only if $\text{abs}(a \, \log(x_i))$ is small enough.
You can then precompute $\sum\limits_{i=1}^n \log^{j}(x_i)$ for every $j$ up until $t$.
Can anyone think of any improvements?