4
$\begingroup$

How can I tell mathematica to give me the symbolic derivative of the following sum $$ \frac{\partial^n}{\partial x^n}\sum_{j=0}^N\gamma_jx^j=\sum_{j=n}^N\frac{j!}{(j-n)!} \gamma_jx^{j-n} $$ I only get the left hand side with my simple but wrong code:

G=Sum[Subscript[\[Gamma], i]*(x)^i, {i, 0, N}]
Assuming[n <= N, D[G, {x, n}] 

Quick followup question: How do I get $\gamma_nn!$ for x=0?

EDIT: Thanks to @BobHanlon for his answer! (I fixed the lower bound in the sum) However, I cannot get the rule interact, with say, standard product rule i.e.

Unprotect[D];
D[Sum[expr_, {k_Symbol, kmin_, kmax_}], {x_, n_}] := Sum[D[expr, {x, n}], {k, kmin + n, kmax}];    
Unprotect[D];
D[x*Sum[Subscript[\[Gamma], i]*(x)^i, {i, 0, N}],{x,n}]

what's the issue here? Cheers!

$\endgroup$
8
$\begingroup$
Clear["Global`*"]

rule = D[Sum[expr_, {k_Symbol, kmin_, kmax_}], {x_, n_}] :>
   Sum[D[expr, {x, n}], {k, kmin, kmax}];

Format[γ[j_]] := Subscript[γ, j]

expr = Sum[γ[j] x^j, {j, 0, n}];

(expr2 = D[expr, {x, n}] /. rule) // TraditionalForm

enter image description here

where FactorialPower is used and expr2 equivalent to

TraditionalForm[
 expr3 = ReplacePart[expr2, 1 -> FunctionExpand[expr2[[1]]]] /. 
   Gamma[z_] :> (z - 1)!]

enter image description here

Clear["Global`*"]

EDIT: Regarding your edit, first, do not modify the definition of internal functions. You would most likely have unintended consequences.

The original rule does not work with your second example because your second expression has a different form than the one in the rule. To generalize the rule, modify the rule to

rule2 = D[expr1_ * Sum[expr2_, {k_Symbol, kmin_, kmax_}], {x_Symbol, n_}] :> 
   Sum[D[expr1*expr2, {x, n}], {k, kmin, kmax}];

I have changed N to imax since N has a special meaning in Mathematica.

(expr4 = D[x*Sum[Subscript[γ, i]*x^i, {i, 0, imax}], {x, n}] /. 
    rule2) // TraditionalForm

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much for your answer! Somehow I cannot get this rule to interact with other derivative rules! Where am I going wrong? I will update my question with an example of the issue! $\endgroup$
    – the.polo
    Oct 6 '19 at 10:36

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.