I pointed out that the symbolic differentiation result, for symbols j and k, is correct. You objected to that. I only replied showing that, indeed, the result is correct. That closes the question.
Next you pointed out that the symbolic differentiation result is fragile. That concept is debatable. I do agree though, with a previous comment by you, that the most common situation is j, k nonnegint; so if choosing a way to express the result using GAMMA functions, do that for the most common case. The symbolic differentiation code is already doing that. But not in one branch of a subroutine, and the problem posted hits that branch. Although the result is correct, it can be better. It is something to adjust.
But then you come up with applying blindly the manipulation I used for the default output, after (you) using the opposite assumptions. With due respect, @vv, I don't see your point. You realize that if the result contains GAMMA as in this example, under direct evaluation it will either work with j negint, or for j posint, and not with both at the same time.
Add to that my opinion, that returning piecewise functions all around is not a convenient idea. Instead, I prefer presenting results with a convenient default and leave to the user to use assumptions for the other cases. Also relevant: understand that having Sums, and especially in the higher-order symbolic differentiation case, the results may require additional algebraic manipulations when evaluating the symbols involved at some values; typically, cases where correctness would require using limits or removing apparent singularities.
Returning to your example assuming j::nonegint, k::nonegint (above this reply), the manipulation after ex1 is as follows:
ex2 := simplify(eval(ex1, [j=2,k = 4, Sum = add]), GAMMA);
So, the result by the symbolic differentiation code is also correct when assuming j::nonegint, k::nonegint.
Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft