I have a question regarding pattern matching. Can anyone explain the results i get ?

Cases[Table[x^n, {n, 1, 10}], a_^1] 

Which gives the following result.

{x, x^2, x^3, x^4, x^5, x^6, x^7, x^8, x^9, x^10}

I was expecting it to return x only similar to the case of x^2 shown below

Cases[Table[x^n, {n, 1, 10}], a_^2]


Thanks David.


2 Answers 2


a_^1 is converted to a_ before Cases is executed, matching each element of the Table.

Trace[Cases[Table[x^n, {n, 1, 10}], a_^1]]

(The output is a bit long to be presented here.)


Most Likely is because x^n^1 == x^n

x^n == (x^n)^1

a_ can be anything including x^n

If you try for example

Cases[Table[x^n, {n, 1, 10}], Power[x,1]] 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.