# Modified Derivative Definition Does Not Thread Over Sum

I'm redefining how a derivative of a polynomial is taken. I have polynomials or posynomials where x is to a fractional power, and derivatives are of integer order. But if the order of the derivative is higher than the power on x, I want the derivative to be set to zero. Here is what I have:

deriv[α_][a_ x_^k_][x_] :=
(If[k >= α,
Gamma[k+1]/Gamma[k+1-α] a x^(k-α), 0]
)


The problem is when I try to evaluate a sum of terms, not a single polynomial term. It doesn't thread to all the terms, and it's partially because Mathematica doesn't know what k is. There would be multiple k's in a sum of these polynomial terms.

So, for example, calling

deriv[1.0][5 x^1.2][x]


evaluates to

6 x^0.2,


but calling

deriv[1.0][5 x^1.2 + 3 x^0.8][x]


does not return the derived version.

Thank you for any help on this.

Edit: I've made some progress and used MonomialList command to give a list of monomials in a polynomial, so then the only thing left to do would be to make sure the function accepts lists and is able to thread over them. I attached a Listable attribute to the function but still no luck.

• Have you typed α in as \alpha_? Also, you have not made a pattern for any head in your [r] portion of the definition of Derivative. You should also not start user-defined functions with a capital letter. I would recommend reading the Common Pitfalls Awaiting New Users post as there appear to be a few fundamentals lacking in your code. – Edmund Jul 14 '16 at 23:16
• @Edmund, I'll edit the post. The reason I kept Derivative with capital D is because I'm trying to edit an already existing definition, but I guess I can define a whole new function. Thanks – Buddhapus Jul 14 '16 at 23:21
• BTW, FactorialPower[] is built-in. – J. M.'s torpor Jul 15 '16 at 0:51

Clear[deriv]
deriv[α_][a_ x_^k_][x_] := If[k >= α, Gamma[k + 1]/Gamma[k + 1 - α] a x^(k - α), 0]
deriv[α_][polynomial_Plus][x_] := Plus @@ (deriv[α][#][x] & /@ MonomialList[polynomial])


Now:

deriv[1.0][5 x^1.2 + 3 x^0.8][x]

(* Out: deriv[1.][0][x] *)


You should still add definitions for such special cases as constants etc, but this should help with the issue with polynomial arguments.