Here we have the initial sum T1[m,n], then I removed the one term (k) and completed the exact sum and the remainder sum called T2[m,n]. T1[m,n] and T2[m,n] should be identical. The test in the table the first few values are different. What is wrong here. I am using Mathematica 12.2.


Expand the sum over k and we get

(1/2) Ceiling[m/2]+(1/2)Ceiling[m/2]^2+(1/2)Ceiling[(1/2)+Sqrt[n]\-(1/2)Ceiling[(1/2)+Sqrt[n]]^2

Rewrite the T1[m,n] function as T2[m,n] where

T2[m,n]:=(1/2) Ceiling[m/2]+(1/2)Ceiling[m/2]^2+(1/2)Ceiling[(1/2)+Sqrt[n]]-(1/2)Ceiling[(1/2)+Sqrt[n]]^2-Sum[Ceiling[(1/2)+(1/2)Sqrt[(2k-1)^2-4n]]),{k,Ceiling[(1/2)+Sqrt[n]],Ceiling[m/2]}];

Now for a table of the two sums and take their difference which should be zero

So setting m = H-10, and n = H, we iterate over H as {H,11,100}. Showing the first few entries we have

enter image description here

So how can these two sums be different in the initial few values? If I use a different shift in the m I get similar results, the first few values are not matched then all values afterwards are correct.

  • $\begingroup$ You are using Sum() ; Notational error or C&P error? $\endgroup$
    – Roland F
    Jul 12, 2023 at 7:22
  • 1
    $\begingroup$ There are several errors and/or missing braces in the given definitions for T1 and T2. Please update in a copy&paste-able format $\endgroup$
    – rowsi
    Jul 12, 2023 at 7:26

1 Answer 1


The problem lines in that the sum over k consists of two limits that are functions of m and n, respectively. In some cases the upper sum is smaller that the lower sum. When using the results with out this adjustment the error will occur for the first few values of m until the limits are satisfied. The remaining sum with the ceiling function is not evaluated exactly so this is automatically taken care of in its evaluation. So the correct solution will be

T2[m,n]:=((1/2) Ceiling[m/2]+(1/2)Ceiling[m/2]^2+(1/2)Ceiling[(1/2)+Sqrt[n]]-(1/2)Ceiling[(1/2)+Sqrt[n]]^2)KroneckerDelta[True, Ceiling[(m)/2] >= Ceiling[-1/2 + Sqrt[n]]]-Sum[Ceiling[(1/2)+(1/2)Sqrt[(2k-1)^2-4n]]),{k,Ceiling[(1/2)+Sqrt[n]],Ceiling[m/2]}];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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