Message Boards Message Boards

0
|
4701 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to use DistributeDefinitions[] when using subscript index expressions?

Posted 3 years ago

Let's prove this statement in V.P. Maslov's book "Operational methods":

enter image description here

We can define the needed entities like this:

P[n_, x_] := Sum[a[k]*x^k, {k, 0, n}] 
P[n_, s_, x_] := Normal[Series[1/P[n, x], {x, 0, s}]]

Now if we distribute the definitions like this:

DistributeDefinitions[Evaluate[Context[]]];

we can prove this theorem for any range of values of n and s (say 10 by 10 to begin with):

ParallelTable[{n, s, 
  Length[CoefficientList[(P[n, x]*P[n, s, x] - 1)/x^(s + 1), x]] == 
   n}, {n, 1, 10}, {s, 1, 10}]

This works, i.e. all entries have True as the 3rd element. However, if we define our Ps like this, which looks much nicer in the frontend, using subscript indices:

Subscript[P, n_][x_] := Sum[Subscript[a, k]*x^k, {k, 0, n}]
Subscript[P, n_, s_][x_] := Normal[Series[1/Subscript[P, n][x], {x, 0, s}]]

Then we get the wrong result, namely some of the entries contain False instead of True:

ParallelTable[{n, s, Length[CoefficientList[(Subscript[P, n][x]*Subscript[P, n, s][x] - 
   1)/x^(s + 1), x]] == n}, {n, 1, 3}, {s, 1, 3}]

CoefficientList::poly :  (-1+Subscript[P, 1][x] Subscript[P, 1,1][x])/x^2 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 2][x] Subscript[P, 2,1][x])/x^2 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 3][x] Subscript[P, 3,1][x])/x^2 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 1][x] Subscript[P, 1,2][x])/x^3 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 2][x] Subscript[P, 2,2][x])/x^3 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 3][x] Subscript[P, 3,2][x])/x^3 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 1][x] Subscript[P, 1,3][x])/x^4 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 2][x] Subscript[P, 2,3][x])/x^4 is not a polynomial.

CoefficientList::poly :  (-1+Subscript[P, 3][x] Subscript[P, 3,3][x])/x^4 is not a polynomial.

General::stop :  Further output of CoefficientList::poly will be suppressed during this calculation.

General::stop :  Further output of CoefficientList::poly will be suppressed during this calculation.

General::stop :  Further output of CoefficientList::poly will be suppressed during this calculation.

{{{1, 1, True}, {1, 2, True}, {1, 3, True}}, {{2, 1, False}, {2, 2, 
   False}, {2, 3, False}}, {{3, 1, False}, {3, 2, False}, {3, 3, 
   False}}}

But the non-parallel version of the same works fine:

Table[{n, s, Length[CoefficientList[(Subscript[P, n][x]*Subscript[P, n, s][x] - 
       1)/x^(s + 1), x]] == n}, {n, 1, 3}, {s, 1, 3}]

{{{1, 1, True}, {1, 2, True}, {1, 3, True}}, {{2, 1, True}, {2, 2, 
   True}, {2, 3, True}}, {{3, 1, True}, {3, 2, True}, {3, 3, True}}}

So, my guess is that with the subscript-index definitions one has to do something else to DistributeDefinitions[] properly? Tested on 11.3, 12.1 and 12.3 -- same problem on all versions.

POSTED BY: Tigran Aivazian
4 Replies

When you use DistributeDefinitions[Evaluate[Context[]]]; it takes all symbols from the current context, probably "Global", and distributes the definitions for those symbols.

But when you define Subscript[P, n_][x_] := ... you are giving a definition to the symbol Subscript which is in the "System" context. What happens if you use this instead?

DistributeDefinitions[Evaluate[Context[]]];
DistributeDefinitions[Subscript];
POSTED BY: Jason Biggs

I tried your suggestion just now and it made no difference whatsoever, i.e. the ParallelTable[] is miscalculating the entries still, in exactly the same way as before.

POSTED BY: Tigran Aivazian
Posted 3 years ago

Tigran

You can try symbolizing the subscripts as described here.

POSTED BY: Rohit Namjoshi

Rohit, Thank you for your suggestion, but the use of Symbolize[] from Notation package seems irrelevant here, as it would turn the subscripted function into an atomic symbol, but the task at hand requires the actual dependency on the subscript index. In any case, I have tried your suggestion and it fails, i.e. Symbolize[Subscript[P,n][x]] returns $Failed, as I would expect it to from the reading of the docs.

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

Group Abstract Group Abstract