# Sum of log squared terms?

1. Aug 10, 2012

### yogo

Hi all,

I have a summation series which goes like this,

S = [log(1)]^2 + [log(2)]^2 + [log(3)]^2 + ....... + [log(n)]^2

Since each term is square of the logarithm of a value, I think there are no general tricks which can be used to solve this.

But is there any way to approximate the value of this summation?

The problem I am facing here is that n is very very large and it is not possible (time-wise and memory-wise) for my program to evaluate every term. So I was hoping for some approximate solution in terms of 'n'.

Thanks,
yogo

2. Aug 10, 2012

### micromass

Well, we know that since $f(x)=(log(x))^2$ is increasing (if x>1)

$$\int_2^{n+1} \log(x-1)^2dx \leq \sum_{n=1}^n \log(n)^2 \leq \int_1^{n+1} \log(x)^2 dx$$

So, if you calculate the integral, then you got a sweet upper and lower bound for the sum.

3. Aug 11, 2012

### coolul007

can't this be a manipulated into a product of n? log(2)+log(3) = log((2)(3)), I'm uncertain what to do with the squared.

4. Aug 11, 2012

### micromass

Not really. But the integral

$$\int \log(x)^2dx$$

has a nice elementary solution. Just integrate by parts twice.

5. Aug 11, 2012

### Mute

In a similar vein, there is also the Euler-Maclaurin formula for asymptotic expansions of sums.

$$\sum_{k=a}^{k=n} f(k) \sim \int_a^n dx~f(x) + \frac{f(a)+f(n)}{2} + \mbox{corrections}.$$

(The full form of the expansion is given on the wikipedia page I linked to). This looks like it would be useful in this case.

6. Aug 11, 2012

### yogo

Thanks for your help guys. Appreciate it.

@micromass: I am not so good at Math. I was wondering how tight these bounds are?

Thanks,
yogo

7. Aug 15, 2012

### chingel

You would have to calculate the integral to find out. Or you can let an online calculator do it. To find the tightness of the bonds, calculate the difference between the integrals, or in other words the integral from n to n+1.

http://www.wolframalpha.com/widgets/view.jsp?id=8ab70731b1553f17c11a3bbc87e0b605

Using Wolfram Alpha the integral from 10 to 11 for example is ~5.5, so if you take the average of them you get a maximal error of ~2.75, actual error would probably be much less, since the function doesn't jump too much, and is rather straight for intervals of width 1. Lower bound is ~25, and using Wolfram Alpha to calculate the sum directly gives ~27.65. If you want more accuracy, you could calculate a few terms of the sum directly, and then get the upper and lower bounds for the rest, for the upper bound it is the sum from 1 to m-1 plus the integral from m to n+1, and for the lower bound the sum from 1 to m-1 plus the integral from m-1 to n. The difference of the upper and lower bounds now turns out to be the integral from n to n+1 minus the integral from m-1 to m, which is better than just the integral from n to n+1.

So for example if you want the sum of the first 1000 terms and you know the first 100 terms exactly, you could do something like this. Sum of first 100 terms is 1408.33. Lower bound is 1408.33+34501.8=35910.13, higher bound is 1408.33+34528.3=35936.63, average is 35923.38. Letting Wolfram Alpha calculate the sum itself, it gets the answer 35923.4, I don't know how it calculates the sum itself and how much it rounded that answer, but at least it shows that taking the average of the bounds is not too bad. So now you have an approximation of the sum of the first 1000 terms, you can now use that to calculate the sum of the first 10000 terms etc.

8. Aug 16, 2012

### chingel

I also tried the Euler-Maclaurin formula. Adding only first two terms from the sum with the Bernoulli numbers in it, it got the sum of the first 1000 terms of log(x)^2 accurate to within 0.0015, so it seems a lot better than just taking the average of integral bounds, especially if you would include more of the correction terms. You could probably get very accurate with more correction terms.

9. Aug 16, 2012

### yogo

@chingel, @mute: Thanks for all the help. I am using Euler-Maclaurin formula now, seems to work really well for me. I actually have an upcoming deadline, and now I am good! :)

Thanks all.