The command
Variables[poly]
gives me a list of all variables that appear in the expression poly
, which involved sums, products, and rational powers. Sadly, it doesn't work for more complicated expressions, such as trigonometric functions. I was wondering if there is another command that can handle expressions such as $\sin(x)+\cos(y)$.
Answer
ClearAll[x, y, z, d, h, p, m, f, g, a, w];
expr = Sin[x] + Cos[y] + z^3 + Exp[d] + h + 3 h^2 + 4 h^3 +
Integrate[Exp[p], p] +
D[Sin[m]^Exp[f], m]*Series[Sin[g], {g, 0, 3}] +
2 (E^a BesselK[0, 2 Sqrt[E^a]]) C[2]/D[Gamma[w], {w, 2}];
Cases[Variables[Level[expr, -1]], x_ /; AtomQ[x] :> x]
(* {a, d, f, g, h, m, p, w, x, y, z} *)
Comments
Post a Comment