Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How may we write Nth polynomials and perform their derivatives?

Posted 3 years ago
Attachments:
5 Replies

You mean you want an expression that is human-readable even when the order is a symbol? Here is an attempt:

poly[vars_List, a_, order_Integer /; order >= 0] :=

 Module[{n = Length@vars, idx, z},
  idx = Select[Tuples[Range[0, order], n], Total[#] <= order &]; 
  Plus @@ 
   Table[Subscript[a, Sequence @@ r] Times @@ (vars^r), {r, idx}]]; 
poly[vars_List /; Length[vars] > 2, a_, order_] :=

 Inactive[Sum][
  Inactive[Times][
   Subscript[a, Subscript["i", 1], \[Ellipsis], 
    Subscript["i", Length[vars]]], vars[[1]]^
   Subscript["i", 1], \[Ellipsis], vars[[-1]]^
   Subscript["i", Length[vars]]], 
  0 <= Inactive[Plus][Subscript["i", 1], \[Ellipsis], 
    Subscript["i", Length[vars]]] <= order]

Try poly[{x, y, z, t}, a, n]

POSTED BY: Gianluca Gorni

Vinícius,

as Rohit proposed those polynomials and their derivatives can be formulated in a very general way, e.g.:

p = Sum[a[i, j - i] x^i y^(j - i), {j, 0, n}, {i, 0, j}]
(* simple check: *)
p /. n -> 4
(* e.g.: first derivative in x, second in y: *)
dp = D[p, {x, 1}, {y, 2}]
dp /. n -> 4

Does that help? Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 3 years ago

Hi Vinícius

One issue is that N is a built-in symbol. Try

ClearAll@n
poly[{x, y}, a, n]

Range[0, n] is unbounded. Is there a reason why you cannot use Sum to generate the polynomial?

POSTED BY: Rohit Namjoshi

Thanks for your comments. Your code is quite interesting.

Hi Mr. Schachner, I hope you are doing well.

Thank you for your insightful comment. Indeed, I have also tried to compute $P(x,y)$ using Sum. However, it did not work nicely in the general case. Nevertheless, your code has clarified all of my doubts.

Thanks once more, and God bless you.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard