1
$\begingroup$

I'm trying to set an attribute that's valid for a generic sum, where n and f are arbitrary.

de[A_ + B_] := de[A] + de[B]
de@Sum[f[i], {i, n}]

Is this possible?

Simplified example:

de[f_[i_], k_] := If[k <= i, f[i], 0]
de[A_ + B_, k_] := de[A, k] + de[B, k]
Simplify[de[Sum[f[i], {i, 1, n}], k], {n \[Element] Integers, k < n}]

should output Sum[f[i],{i,k,n}]

$\endgroup$
2
$\begingroup$

TagSetDelayed is probably the best way to go here:

de[A_ + B_] := de[A] + de[B];
de /: de[Sum[q_, α_]] := Sum[de[q], α];

de@Sum[f[i], {i, n}]
(* Sum[de[f[i]], {i, n}] *)
$\endgroup$
  • 1
    $\begingroup$ Nice! Also, for the example one can use Unprotect[Sum] Sum[de[f[i], k_], {i, 1, [Alpha]_}] := Sum[de[f[i], k], {i, k, [Alpha]}] Though be careful when unprotecting stuff in general not to get some random bugs $\endgroup$ – Pedro Portugal Aug 22 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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