Group Abstract Group Abstract

Message Boards Message Boards

NSum returns wrong result for infinite sum

POSTED BY: Ralph Trenkler
6 Replies

Here we know the exact answer in advance. What if we didn't know? I admit my ignorance in this field.

POSTED BY: Gianluca Gorni

Sometimes you have to do a little analysis on simpler forms compared to the full expression and make a guess. But come to find out none of this was necessary; see Gianluca Gorni's reply.

The following gives acceptable approximations. You just have to learn to be a Mathematica whisperer.

POSTED BY: Gianluca Gorni

Ralph,

I would hesitate using the terms "wrong", "bug", etc. in the title of a post.

From the documentation on NSum:

NSum gives a numerical approximation to the sum

And in fact the result here is not "wrong", it rather is a less good approximation. But this approximation can be improved by various options, e.g.:

two[n_] := 
 NSum[(16 - 32 k - 
   4 (-1)^k (4 k - 3) (16 k^2 - 1))/((2 k - 1) (4 k - 3) (16 k^2 - 
     1)), {k, 1., n},
Method -> "AlternatingSigns", NSumTerms -> 100, WorkingPrecision -> 30]

two[Infinity]
(*    Out:  2.00000889   *)

Does that help? Regards -- Henrik

POSTED BY: Henrik Schachner

You are right, the result is wrong. No need for Python, though:

Sum[(16 - 32 k - 
  4 (-1)^k (4 k - 3) (16 k^2 - 1))/((2 k - 1) (4 k - 3) (16 k^2 - 
    1)), {k, Infinity}]
% // FullSimplify
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard