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.
α
in as\alpha_
? Also, you have not made a pattern for any head in your[r]
portion of the definition ofDerivative
. 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. $\endgroup$FactorialPower[]
is built-in. $\endgroup$