1
$\begingroup$

I have a huge expression (spanning 70 pages) involving polynomials and logarithms and polylogarithms. A sample of that looks as below:

(x*(2 + x + 4*x^2 + x^3 + 2*x^4 + 4*z - x*z + 8*x^2*z - x^3*z + 
    4*x^4*z -10*x*z^2 - 2*x^2*z^2 - 10*x^3*z^2 + 6*x^2*z^3)) +  
  6*Log[z]*Log[-x + z] + (12*I)*Log[Z] + 6*Log[Z]^2 + 
  12*PolyLog[2, Y^(-1)] + 6*PolyLog[2,x/((1 + x^2)/x - z)] - 
  6*PolyLog[2, x*((1 + x^2)/x - z)] + 6*PolyLog[2, x/z] - 
  6*PolyLog[2, x*z] + 12*PolyLog[2, Z^(-1)]))/(3*(1 + x)^6))

I have many such kind of patterns involving Polylog; I want to make a list of all such unique patterns that are appearing in the huge expression. I have tried Cases but it is not working. Can anyone help me how to do it?

$\endgroup$
  • 1
    $\begingroup$ Can you show exactly what you've tried? Cases[*yourstuff*, PolyLog[x_, y_] :> {x, y}, ∞] returns something useful, but I'm not sure it's what you're after. $\endgroup$ – aardvark2012 Dec 17 '17 at 4:11
  • $\begingroup$ Cases['expression',PolyLog[a_,b_]] is what i had tried $\endgroup$ – user54256 Dec 17 '17 at 4:36
  • $\begingroup$ Two points. 1) the expression you post above has two unmatched right parentheses at end -- ... + 12*PolyLog[2, Z^(-1)]))/(3*(1 + x)^6). 2) in Mathematica pattern matching works the same for expressions with any head. That means the head List is not treated specially. $\endgroup$ – m_goldberg Dec 17 '17 at 4:40
  • $\begingroup$ Thanks. Sorry I had missed two right parentheses, i had copied it directly from the file... $\endgroup$ – user54256 Dec 17 '17 at 4:47
4
$\begingroup$

Cases is the right choice.

expr = ((((x*(2 + x + 4*x^2 + x^3 + 2*x^4 + 4*z - x*z + 8*x^2*z - x^3*z + 
         4*x^4*z - 10*x*z^2 - 2*x^2*z^2 - 10*x^3*z^2 + 6*x^2*z^3)) + 
     6*Log[z]*Log[-x + z] + (12*I)*Log[Z] + 6*Log[Z]^2 + 
     12*PolyLog[2, Y^(-1)] + 6*PolyLog[2, x/((1 + x^2)/x - z)] - 
     6*PolyLog[2, x*((1 + x^2)/x - z)] + 6*PolyLog[2, x/z] - 
     6*PolyLog[2, x*z] + 12*PolyLog[2, Z^(-1)]))/(3*(1 + x)^6));

Cases[expr, HoldPattern[PolyLog[__]], Infinity] // DeleteDuplicates
$\endgroup$
  • $\begingroup$ Thanks a lot for the help! It is working fine. $\endgroup$ – user54256 Dec 17 '17 at 4:40

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.