Re: Generalization of Variables ?
- To: mathgroup at smc.vnet.net
- Subject: [mg109242] Re: Generalization of Variables ?
- From: Yves Klett <yves.klett at googlemail.com>
- Date: Mon, 19 Apr 2010 02:48:11 -0400 (EDT)
- References: <hqc14l$g2v$1@smc.vnet.net>
Hi Jack,
your pasted code seems incomplete. On short notice, perhaps something like
vars[expr_] :=
Union[Cases[expr, s_Symbol /; Not[NumericQ[s]], Infinity]]
vars[Sin[x] + Exp[x^2 + b + Cos[t]] + \[Pi]]
{b, t, x}
might help as well. This one also eliminates symbols that have a
numerical counterpart.
Regards,
Yves
Am 17.04.2010 12:05, schrieb Jack L Goldberg 1:
> Hi Folks,
>
> The built-in command "Variables" does not give the (naively expected)
> answer when it is called with functions such as x + Sin[x]. This
> behavior is mentioned in the description of "Variables".
> I have constructed a generalization of "Variables" which works as
> expected - I think? I would appreciated a critique of this code which
> addresses these issues:
>
> a) Is there a situation in which it fails?
>
> b) If the code works, can it be improved.
>
> Question b) is asked because I am not fully acquainted with all of
> Mathematica's commands.
>
> Here is the code.
>
> variables[f_]:= Flatten[
> Union[
> Cases[
> Map[N,Level[f,{-1},z_Symbol]]/.True->{}
> ]
>
> I have tried "variables" on functions coded in the obvious manner, say,
> Sin[x]+Exp[x^2], Sin[x+y]-z^2, etc. and a few esoteric examples.
>
> Jack
>