Note that Sum
has the attribute HoldAll
, while Integrate
does not. This means that the definition of RegSum
has Infinity
and not what Infinity
evaluates to. The evaluation of Infinity
:
Infinity //FullForm
DirectedInfinity[1]
Your definition:
DownValues[RegSum] //FullForm
List[RuleDelayed[HoldPattern[RegSum[Sum[Pattern[e,Blank[]],List[Pattern[t,Blank[]],0,Infinity]]]],5]]
Note the presence of Infinity
.
When Sum
evaluates and realizes that it does not converge, it returns a Sum
expression where Infinity
has been replaced with DirectedInfinity[1]
:
Sum[Exp[3 x], {x, 0, Infinity}] //FullForm
Sum::div: Sum does not converge.
Sum[Power[E,Times[3,x]],List[x,0,DirectedInfinity[1]]]
This means that your definition, which is expecting Infinity
doesn't fire because the upper limit is instead DirectedInfinity[1]
.
A possible workaround is to use:
RegSum[Sum[e_,{t_,0,DirectedInfinity[1]}]]:=5