1
$\begingroup$

I have a list of polynomials in x1,x2,x3,y,z,t. I want to differentiate each list element (polynomial) recursively with respect to all xi until they vanish in the polynomial. For example, if I have the polynomial

p = x1 x3^2 y t + x2 y^2 + x1^3 z t + x1 x2 y z + x1^2 x2 y t

then I differentiate with respect to x1,x1,x2 and get 2*y*t. Alternatively, I could differentiate with respect to x3, x3, x1 and get the same result. So the final expression does not contain xi. Any idea how to do that is appreciated.

$\endgroup$
5
  • $\begingroup$ Variables and CoefficientRules might be helpful. $\endgroup$ Feb 13, 2019 at 10:55
  • $\begingroup$ Thanks. Sorry, still unclear how I can manage the above. $\endgroup$
    – Bran
    Feb 13, 2019 at 11:11
  • $\begingroup$ I didn't revert anything. Why isn't it a polynomial? $\endgroup$
    – Bran
    Feb 13, 2019 at 11:19
  • $\begingroup$ OK. I have now used the * notation for multiplication. $\endgroup$
    – Bran
    Feb 13, 2019 at 11:22
  • $\begingroup$ Ah, okay, that it was because we submitted the edits almost at the same time. $\endgroup$ Feb 13, 2019 at 11:27

1 Answer 1

2
$\begingroup$

We may employ CoefficientRules to obtain the coefficients of the polynomial with respect to x1, x2, x3.

p = x1 x3^2 y t + x2 y^2 + x1^3 z t + x1 x2 y z + x1^2 x2 y t;
r = CoefficientRules[p, {x1, x2, x3}]

{{3, 0, 0} -> t z, {2, 1, 0} -> t y, {1, 1, 0} -> y z, {1, 0, 2} -> t y, {0, 1, 0} -> y^2}

For example, {2, 1, 0} -> t y means that the coefficient of x1^2 x2^1 x3^0 is t y. We only have to correct for the factors that arise due to differentiation. This can be done as follows:

r[[All, 2]] *= Times @@@ (r[[All, 1]]!);
r

{{2, 1, 0} -> 2 t y, {1, 1, 0} -> y z, {1, 0, 2} -> 2 t y, {0, 1, 0} -> y^2, {0, 0, 0} -> t x^3 z}

$\endgroup$
11
  • $\begingroup$ Thanks. So the differentiation result will be the sum of those coefficients? Also, I am getting the error "Part 2 does not exist" for the second command. $\endgroup$
    – Bran
    Feb 13, 2019 at 12:46
  • $\begingroup$ " So the differentiation result will be the sum of those coefficients?" Nope. Each of the values in the final list is a result of a separate differentiation. $\endgroup$ Feb 13, 2019 at 12:49
  • $\begingroup$ But I need the polynomial differentiated with respect all xi and have the result as a polynomial without xi as in my example. $\endgroup$
    – Bran
    Feb 13, 2019 at 12:55
  • $\begingroup$ That's what the code above provides. There are no xi left. $\endgroup$ Feb 13, 2019 at 12:56
  • $\begingroup$ OK, but I'm getting an error: Part 2 does not exist $\endgroup$
    – Bran
    Feb 13, 2019 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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