1
$\begingroup$

Suppose 

$P(x,y)=\displaystyle\sum^{N}_{i+j=0}\alpha_{ij}x^{i}y^{i} \equiv \alpha_{00}+\alpha_{10}x+\alpha_{01}y+a_{11}xy+\ldots+a_{0N}y^{N}$

is a multivariable polynomial of $N$th degree. I want to express the first and second derivatives of $P(x,y)$ through Mathematica.

My attemps:

Previously, I attempted to study the derivatives of the above polynomial through the following code

poly[vars_List, a_, order_] := Module[{n = Length@vars, idx, z}, idx = Cases[Tuples[Range[0, order], n], x_ /; Plus @@ x <= order]; z = Times @@@ (vars^# & /@ idx); z.((Subscript[a, Row[#]]) & /@ idx)] poly[{x, y}, a, N] (*a is used for coefficient*).

However, it looks like that this code only works when N is equal to some integer number, for example N=2.

Based on the above, is there another way to express the general form of $P(x,y)$ and obtain its first and second derivatives?

Ps:I have read other posts, however, those did not help me.

$\endgroup$

1 Answer 1

3
$\begingroup$

You should have shown your own attempts. Anyway, try this

s = Sum[a[i, j]*x^i*y^j, {i, 0, n}, {j, 0, n}]

Then

D[s, x]

yields

enter image description here

D[s, x, y]

gives you enter image description here

The other second derivatives are, in principle the same, but require a simple additional effort for the simplification:

MapAt[Simplify, D[s, {x, 2}], {1}]

returns

enter image description here

Have fun!

$\endgroup$
2
  • $\begingroup$ Many Thanks, @Alexei Boulbitch! I think you got the "spirit", however, this is not exactly what is asked. Let me explain it better. I want to obtain the first and second derivatives of the following polynomial: $\sum^{N}_{i+j=0}\alpha_{ij}x^{i}y^{i} \equiv \alpha_{00}+\alpha_{10}x+\alpha_{01}y+a_{11}xy+\ldots+a_{0n}y^{n}$. As you may see, the polynomial posses only one summation sign whose index is $i+j$$. I will update my post and include my attempts. Thanks once more for your help. $\endgroup$ May 8 at 12:11
  • $\begingroup$ I do not understand what you mean under "only one summation sign whose index is i+j". Indeed, the polynomial in your comment is written exactly like you will obtain opening the expression that I have given in the answer. $\endgroup$ May 9 at 10:24

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.