Re: Free variables in an expression
- To: mathgroup at smc.vnet.net
- Subject: [mg54796] Re: Free variables in an expression
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Wed, 2 Mar 2005 01:26:42 -0500 (EST)
- References: <d0142d$oon$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Sascha Kratky wrote: > Is there a Mathematica built-in function that gives a list of free > (unbound) variables in an arbitrary expression? > > Thanks, > Sascha > Union[Cases[a+b+x y a,_Symbol,\[Infinity]]] {a,b,x,y} Note that although the expression a+b+x y a contains some other symbols, such as Plus (look at the FullForm representation), they don't get included because they are present in heads. You might need to exclude such 'variables' as Pi, though. Of course, you can build the above into a function definition so you don't need to type it all every time you need it. David Bailey dbaileyconsultancy.co.uk