> realpart(nusum(j*x, j, 1, N));
Should be realpart(nusum(exp(%i*j*x),j,1,N).
Note that realpart(exp(%i*a)) = cos(a).
The result is a little messy, but there are various simplifications you
can use to massage it into the form you want: the sequence trigexpand,
trigsimp, factorsum isn't bad; trigrat gives a more impressive result in
one step. Expand'ing the trigrat result gives a nice answer (though it
would be nicer if you could get it to rewrite (2*n+1)/2*x as (n+1/2)*x).