4
$\begingroup$

Check this:

NSum[Log[Abs[m]],{m,1,24}]  
(*54.7847*)
NSum[Log[Abs[m]],{m,1,25}]

NSum::nsnum: Summand (or its derivative) (Abs^[Prime])[m]/Abs[m] is not numerical at point m = 16. >>

I know that I can get around this issue by replacing NSum to N@Sum or even drop Abs. Yet I really want to know where is the (Abs^\[Prime])[m] comming from?

I haven't check this on all platforms, but at least this happens to v10.1 (both Windows and Linux)& v10.2(Windows) even in v7(Windows). I must say I'm really shocked by such a stupid bug.

$\endgroup$
8
$\begingroup$

Might it have something to with the option NSumTerms? From the documentation:

NSumTerms is the number of terms to use before extrapolation.

By default NSum uses 15 terms at the beginning before approximating the tail.

Thus trying it with just 16 terms instead of the default removes the error message.

NSum[Log[Abs[m]], {m, 1, 25}, NSumTerms -> 16]
(* 58.0036 *)

(* For verification *)
N@Sum[Log[Abs[m]], {m, 1, 25}]
(* 58.0036 *)
$\endgroup$
  • $\begingroup$ Possible. However, check this NSum[Log[Abs[m]], {m, 1, 100}, NSumTerms -> 16], there are still error message. What I really want to know is why (Abs^\[Prime])[m] show up? $\endgroup$ – luyuwuli Sep 10 '15 at 7:59
  • 1
    $\begingroup$ @luyuwuli so increase NSumTerms to 100 in that example and the error message disappears - where's the problem there? I can only guess that (Abs^\[Prime])[m] shows up because of the extrapolation... $\endgroup$ – dr.blochwave Sep 10 '15 at 8:00
  • 1
    $\begingroup$ +1, tempted to close vote - this is pretty well outlined in docs, though perhaps why some things wonkify the approximation process might be opaque. $\endgroup$ – ciao Sep 10 '15 at 8:04
  • $\begingroup$ I can somehow guess the issue out. The term comes from the consequence that the bulit in algorithm calculates the derivative in order to check the convergence, but it doesn't take into account that sometimes the derivative doesn't exist for non-analytic function. (in this case, Abs) $\endgroup$ – luyuwuli Sep 10 '15 at 8:09
  • 2
    $\begingroup$ @ luyuwuli Not nice of MMA. But try replacing Abs[x] -> Sqrt[x^2] which is completely equivalent for real m. Example: no problems with NSum[Log[Sqrt[m^2]], {m, 1, 100}]. The derivative of Sqrt[x^2] is similarly non-analytic. $\endgroup$ – Dr. Wolfgang Hintze Sep 10 '15 at 14:17

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.