3
$\begingroup$

When I declare the function $f$ as follows:

f[n_] := Sum[x/Sum[Sqrt[y], {y, 1, x}], {x, 1, n}]/n

the input

Limit[f[n],n -> Infinity]

does not yield an answer, in fact the evaluation is terminated after a few seconds. If I now write

Limit[f[x], x -> Infinity]

I get an answer of $0$. Why is that, according to the manual entry of "Sum" we have

The iteration variable i is treated as local, effectively using Block.

If it matters, I use the version 9.0.

$\endgroup$
0
3
$\begingroup$

Beware of held attributes. Sum uses Block but also has HoldAll, which means that nothing is evaluated until the variable gets a value inside it - if any at all. Limit does not have held attributes.

If after defining f you evaluate f[n] (assuming n doesn't have a value in your environment) you get a

$$\frac{\sum _{x=1}^n \frac{x}{H_x^{\left(-\frac{1}{2}\right)}}}{n}$$

whereas f[x] (again, assuming x is free) gives you

$$\frac{\sum _{x=1}^x \frac{x}{H_x^{\left(-\frac{1}{2}\right)}}}{x}$$

So, note now the different summation limits and how what used to be a free variable is now colliding with the bounds. That shows what Limit actually gets and the answer, I hope.

$\endgroup$
2
  • $\begingroup$ I understand, it still feels weird that they implemented it that way. In my opinion taking a limit of some function should not depend on how you name the variable which is considered for the limit. $\endgroup$
    – Listing
    Jan 6 '14 at 17:08
  • 1
    $\begingroup$ When it comes to manipulating expressions, one needs to be aware of whether a built-in has or not hold behaviour as that affects how it works. And some expression handling built-ins don't have that (notably Integrate and D), allowing you to generate a expression before handing that over to the built-in, but others do. That's the way it is. $\endgroup$
    – carlosayam
    Jan 6 '14 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.