MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Variables[] in general expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20048] RE: [mg20024] Variables[] in general expressions
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Sat, 25 Sep 1999 18:46:10 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Ken Rice  wrote:
-----------------------------

Is there any way of extracting a list of variables from a general
expression, not just a polynomial? I want something which will do,
-----------------------------

The code below should work nicely.


In[1]:=
AllVariables[expr_]:=Union[Cases[expr,_Symbol?(Not[NumericQ[#]]&),{1,Infinit
y}]]

In[2]:=
AllVariables[ y+Exp[y+x *y]+Sqrt[y]+Pi/2 ]

Out[2]=
{x,y}


Note, Cases can do much more than this. 
I provide many examples at the web page below.

-----------------------------
Regards,
Ted Ersek

For Mathematica tips, tricks see 
http://www.dot.net.au/~elisha/ersek/Tricks.html


  • Prev by Date: Re: Plot3D Problem with Nonreal Numbers
  • Next by Date: Re: Variables[] in general expressions
  • Previous by thread: Re: Variables[] in general expressions
  • Next by thread: Re: Variables[] in general expressions