Re: Variables[] in general expressions
- To: "mathgroup at smc.vnet.net \"MathGroup\"" <mathgroup at smc.vnet.net>
- Subject: [mg20049] Re: [mg20024] Variables[] in general expressions
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 25 Sep 1999 18:46:11 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Ken,
I think this will work:
AllVariables[expr_] :=
Union[Cases[Level[expr, { -1}], x_Symbol /; NumericQ[x]]]
AllVariables[E^x + y]
{x,y}
AllVariables[2.*z*Sin[5*E^(I*Pi*y) + 6*x^2] +
f[I*x, Pi*y, 5*w]]
{w, x, y, z}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
>Hi there,
>
>Is there any way of extracting a list of variables from a general
>expression, not just a polynomial? I want something which will do,
>e.g.
>
>In AllVariables[y + Exp[x]]
>Out {y,x}
>
>Apologies if I'm just being dim.
>
>Ken Rice
>_____________________________________________________
>Kenneth Rice
>Churchill College
>Cambridge
>CB3 0DS, UK
>E-mail: kmr1004 at cam.ac.uk
>
>
>