Skip to main content
2 of 4
added 12 characters in body; edited tags; edited title
rm -rf
  • 89.3k
  • 21
  • 297
  • 480

Extracting variables from an expression

I'm looking for a way to extract a list of variables from an expression, for example with an input like:

Leff= (mc dm^2 + mc/12*(h^2 + 3 R^2) + ma da^2 + ma/12 La^2)/(mc dm + ma da)

I want this output:

{mc, dm, ma, da, La, h, R}.

The built-in Mathematica function Variables can do this but doesn't work with more complex expressions containing trascendental functions. Any help would be very appreciated.

John
  • 700
  • 8
  • 13