# NSum not able to sum Abs[Sin[n]]

Is it a bug?

In[1]:= NSum[Abs[Sin[n]], {n, 1, 24}]
Out[1]= 15.7476
In[2]:= NSum[Abs[Sin[n]], {n, 1, 25}]
NSum::nsnum: Summand (or its derivative) Cos[n] (Abs^\[Prime])[Sin[n]] is not numerical at point n = 16.
Out[2]= NSum[Abs[Sin[n]], {n, 1, 25}]


Version: 11.2.0.0

OS: Windows 10 (64-bit)

• Seems to happen here too... 11.2 on OSX. As a workaround: Total[Abs[Sin[#]] & /@ Range[25]] // N seems to work fine. So bug is in NSum and not in Sin[ ]. – bill s Oct 6 '17 at 23:09
• on 11.1 windows 10 too – Alucard Oct 6 '17 at 23:13
• I don't think this is a bug. NSum uses extrapolation to approximate the result. This approximation requires taking derivatives of the input. Your input does not have a derivative defined over the complex plane, and so Mathematica issues an error message and returns the input unevaluated. – Carl Woll Oct 7 '17 at 0:00
• Same on 10.4 Win10. (N@Sum[...] works fine, though). – aardvark2012 Oct 7 '17 at 3:32

By default NSum uses 15 terms at the beginning before approximating the tail. The approximation tries to take the derivative of Abs which is undefined. You can avoid the issue by using the option NSumTerms

NSum[Abs[Sin[n]], {n, 1, 25}, NSumTerms -> 25]

(* 15.8799 *)


Comparing with

N@Total@Abs@Sin@Range[25]

(* 15.8799 *)

• It's strange that NSum[RealAbs[Sin[n]], {n, 1, 25}] outputs 16.081. – user64494 Oct 7 '17 at 7:06