Re: What variables are in a function and displaying surds
- To: mathgroup at smc.vnet.net
- Subject: [mg31133] Re: What variables are in a function and displaying surds
- From: Albert Retey <albert.retey at visualanalysis.com>
- Date: Fri, 12 Oct 2001 03:36:52 -0400 (EDT)
- Organization: Visual Analysis AG
- References: <9q2l3v$p4f$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
> Is there a way in Mathematica to generate a list of variables in an
> expression like Variable[]. For example if I passed the expression
> Sin[x+y]+ z/p - t the list {x,y,z,p,t} would be generated.
>
This is probably not bullet-proof, but should do the job (if any of the
x,y,z,p,t is set to e.g. a number it won't work anymore...):
Mathematica 4.1 for Linux
Copyright 1988-2000 Wolfram Research, Inc.
-- Motif graphics initialized --
In[1]:= expr = Sin[x + y] + z/p - t;
In[2]:= Union[Cases[expr, _Symbol, Infinity]]
Out[2]= {p, t, x, y, z}
In[3]:= x=8;
In[4]:= Union[Cases[expr, _Symbol, Infinity]]
Out[4]= {p, t, y, z}
In[5]:= Quit[]
expr = Sin[x+y]+ z/p - t
Union[Cases[expr, _Symbol, Infinity]]
Albert