Unexpected behavior of Variables

 Unexpected behavior of Variables

I apologize in advance if this is a duplicate. Variables has a strange behavior when it encounters powers:

  w = s1^(n + 2) s2;
  Variables[w]
  (*{s1, s1^n, s2}*)

I’d have expected {s1, s2, n},

On the other hand

 w = s1^2 s2;
 Variables[w]
 (*{s1, s2}*) 

yields what one expects. I wonder if there is a way to get the expected result in the first example.

Let’s block ads! (Why?)

Recent Questions – Mathematica Stack Exchange