The symbols command extracts all symbols present in an expression A. Symbols consist of functions and variables.
f = sin(x) + cos(y) + z; symbols(f); [sin(x), cos(y), x, y, z]