Message Boards Message Boards

How to make Sum work with the error Sum::vexdep with dependencies

I am working on a paclet for very-well poised basic hypergeometric functions.

I have a function ReplacePlusMinus.

ReplacePlusMinus//ClearAll
ReplacePlusMinus::usage="ReplacePlusMinus[list] replaces cases of p,-p in a  list with plus or minus p."
ReplacePlusMinus[l_?(Function[{x},ListQ[x],{}])]:=SequenceReplace[l, {x_, -x_} :> PlusMinus[x]]
ReplacePlusMinus[args___]:=
Null/;CheckArguments[ReplacePlusMinus[args],1];

I have an error that I'm not sure how to resolve. The ** is NonCommutativeMultiply.

Cases[W87[a, b, c, d, e, f, q, z] == Sum[(b**c**z/Sqrt[a**q])^n**((QPh[{a**q}, q, 2*n]*Sum[((b**c**d**z/a**q)^m**QPh[ReplacePlusMinus[{a**q^(1 + 2*n)}], q, 2*m]/QPh[ReplacePlusMinus[{a^2**q^(1 + 2*n)/b**c**d}], q, 2*m])**W65[a**q^(2*(m + n)), b**c**d/a**q, e**q^(m + n), f**q^(m + n), q, z], ReplacePlusMinus[{m, 0, Infinity}]])/QPh[{a^(3/2)**Sqrt[q]/b**c}, q, 2*n]), {n, 0, Infinity}], {Sum[summand:_ | _[___], ReplacePlusMinus[{variable_, lowerbound_, upperbound_}]] :> Sum[summand, {variable, lowerbound, upperbound}]}]

QPh is the Q Pochhammer symbol and W87 is a very well poised hypergeometric function.

I need some help resolving this error.

Sum::vexdep: The variable ReplacePlusMinus[{m,0,\[Infinity]}] has dependencies in the current session that cause it to evaluate to {m,0,\[Infinity]}, which cannot be used as a variable.

I think Sum effectively uses Block.

I think this might be the issue based on this quote: "Block therefore affects the evaluation stack, not just the literal occurrences of a symbol inside the code of its body. Its effects are much less local than those of lexical scoping constructs, which makes it much harder to debug programs which use Block extensively." Source:https://mathematica.stackexchange.com/questions/559/what-are-the-use-cases-for-different-scoping-constructs I think the solution might be to use Module instead.

My goal is to take

Hold[Sum[((b**c**d**z/a**q)^m**QPh[ReplacePlusMinus[{a**q^(1 + 2*n)}], q, 2*m]/QPh[ReplacePlusMinus[{a^2**q^(1 + 2*n)/b**c**d}], q, 2*m])**W65[a**q^(2*(m + n)), b**c**d/a**q, e**q^(m + n), f**q^(m + n), q, z], ReplacePlusMinus[{m, 0, Infinity}]]]

as input and return the expression with ReplacePlusMinus evaluated.

Are there any good ideas to make the function work?

ReplacePlusMinus will transform {m,n,p,-p,r} into {m,n,PlusMinus[p],r}.

I am trying to use Trace to figure out something that works.

I got it working.

For equation 3,

Activate[
 AddPlusMinus[
  PolynomializeFractionPower[
   VeryWellPoisedHypergeometricToNumerator[
    RearrangeExpression[
     W87[a, b, c, d, e, f, q, z] == 
      Sum[QPh[{Sqrt[q] a^(3/2)/(b c), Sqrt[q a]/b, Sqrt[q a]/c, 
           q a/(b c), d, e, f}, q, n]/
         QPh[{q, Sqrt[q a], q a/b, q a/c, q a/d, q a/e, q a/f}, q, 
          n] QPh[{q a}, q, 2 n]/
         QPh[{Sqrt[q] a^(3/2)/(b c)}, q, 2 n] (b c z/Sqrt[q a])^n Sum[
         QPh[{(a^2 q^(1 + 2 n))/(b c d), (a q^(1 + n))/(b c), 
             Sqrt[a q]/d, (q^n (a q)^(3/2))/(b c d), e q^n, f q^n}, q,
             m]/QPh[{q, 
             q^n Sqrt[
               a q], (q^(2 n) (a q)^(3/2))/(b c), (a q^(1 + n))/
              d, (a q^(1 + n))/e, (a q^(1 + n))/f}, q, 
            m] QPh[{a q^(1 + 2 n)}, q, 2 m]/
           QPh[{(a^2 q^(1 + 2 n))/(b c d)}, q, 2 m] ((b c d z)/(a q))^
           m W65[a q^(2 (m + n)), (b c d)/(a q), e q^(m + n), 
           f q^(m + n), q, z], {m, 0, Infinity}], {n, 0, Infinity}]

     ]]]], Sum]

returns

W87[a, b, c, d, e, f, q, z] == Sum[(b**c**z/Sqrt[a**q])^n**((QPh[{a**q}, q, 2*n]*QPh[{a^(3/2)**Sqrt[q]/b**c, Sqrt[a**q]/b, Sqrt[a**q]/c, a**q/b**c, d, e, f}, q, n]*Sum[((b**c**d**z/a**q)^m**QPh[{a**q^(1 + 2*n)}, q, 2*m]**QPh[{a^2**q^(1 + 2*n)/b**c**d, a**q^(1 + n)/b**c, Sqrt[a**q]/d, q^n**(a**q)^(3/2)/b**c**d, e**q^n, f**q^n}, q, m]/QPh[{a^2**q^(1 + 2*n)/b**c**d}, q, 2*m]**QPh[{q, q^n**Sqrt[a**q], q^(2*n)**(a**q)^(3/2)/b**c, a**q^(1 + n)/d, a**q^(1 + n)/e, a**q^(1 + n)/f}, q, m])**W65[a**q^(2*(m + n)), b**c**d/a**q, e**q^(m + n), f**q^(m + n), q, z], {m, 0, Infinity}])/QPh[{a^(3/2)**Sqrt[q]/b**c}, q, 2*n]**QPh[{q, Sqrt[a**q], a**q/b, a**q/c, a**q/d, a**q/e, a**q/f}, q, n]), {n, 0, Infinity}]

For equation 5,

Activate[
 AddPlusMinus[
  PolynomializeFractionPower[
   VeryWellPoisedHypergeometricToNumerator[
    RearrangeExpression[
     W1211[a, b, c, d, e, f, g, h, i, j, q, z] == 
      QHypergeometricPFQ[{a, q Sqrt[a], -q Sqrt[a], b, c, d, e, f, g, 
        h, i, j}, {Sqrt[a], -Sqrt[a], q a/b, q a/c, q a/d, q a/e, 
        q a/f, q a/g, q a/h, q a/i, q a/j}, q, z]

     ]]]], Sum] 

returns

W1211[a, b, c, d, e, f, g, h, i, j, q, z] == 
 QHypergeometricPFQ[{a, \[PlusMinus]Sqrt[a] ** q, b, c, d, e, f, g, h,
    i, j}, {\[PlusMinus]Sqrt[a], a ** q/b, a ** q/c, a ** q/d, a ** q/
   e, a ** q/f, a ** q/g, a ** q/h, a ** q/i, a ** q/j}, q, z]

I will attach the text file with the equations. I am working on translating them into LaTeX.

Attachments:
POSTED BY: Peter Burbery
7 Replies

I wonder if you have tried the following:

In[53]:= ReplacePlusMinus[{1, -1}]
ReplacePlusMinus[{-a, a}]
ReplacePlusMinus[{-1 + Sqrt[2], 1 - Sqrt[2]}]

Out[53]= {1, -1}

Out[54]= {-a, a}

Out[55]= {-1 + Sqrt[2], 1 - Sqrt[2]}
POSTED BY: Gianluca Gorni

I want the code to be as robust as possible. There's a lot of helpful functions for this like GraphQ, IntegerQ, RealValuedNumericQ and RealValuedNumberQ coming in 13.3, PolynomialQ, etc.

POSTED BY: Peter Burbery

Ok, _?IntegerQ and _Integer are not totally equivalent, but they show their difference only in fringe cases such as Integer[3]. But are you really afraid that your code will meet such constructs?

POSTED BY: Gianluca Gorni

Yes I know, I can't really think of an example where List isn't accepted. The point stands, though.

POSTED BY: Peter Burbery

Your pattern test accepts List[Red]:

In[36]:= MatchQ[List[Red], l_?(Function[{x}, ListQ[x], {}])]

Out[36]= True
POSTED BY: Gianluca Gorni

If I use _List, the function will match something that I don't want it to match such as List[Red]. Maybe that's not a good example. Instead of using _Integer, for example, I use IntegerQ. Or instead of using _Graph I use GraphQ. _Integer would match Integer[Red] but IntegerQ[Integer[Red]]] would return False. _Graph would match Graph[Red] but GraphQ[Graph[Red]] would return False, which is what I want. PatternTest with the shorthand form ? has high precedence. I am using the three argument form of function so I can an attribute such as HoldAll like Function[{x},x^2,{HoldAll}] if need be. I think there's an example of this in the documentation.

POSTED BY: Peter Burbery

I am trying to understand your function ReplacePlusMinus. First question: what is the purpose of the complicated pattern test l_?(Function[{x}, ListQ[x], {}])? Why not this simpler form:

myReplacePlusMinus[l_List] := 
 SequenceReplace[l, {x_, -x_} :> PlusMinus[x]]

Have you tried ReplacePlusMinus in these examples?

ReplacePlusMinus[{1, -1}]
ReplacePlusMinus[{-a, a}]

Are you ok with the output?

POSTED BY: Gianluca Gorni
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