# Finding patterns in expressions

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?

• 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. – aardvark2012 Dec 17 '17 at 4:11
• Cases['expression',PolyLog[a_,b_]] is what i had tried – user54256 Dec 17 '17 at 4:36
• 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. – m_goldberg Dec 17 '17 at 4:40
• Thanks. Sorry I had missed two right parentheses, i had copied it directly from the file... – user54256 Dec 17 '17 at 4:47

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 +