MathGroup Archive 2010

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

Search the Archive

Re: Generalization of Variables ?

On Apr 17, 7:05 am, Jack L Goldberg 1 <jackg... at> wrote:
> 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[
>                                     M=
>                                     =
> 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

variables[expr_] :=
   expr, _Symbol?(! NumericQ[#] &), -1]]

Or maybe, if you have lots of more duplicates than Pi, E, and numeric

variables[expr_] :=
   Cases[expr, _Symbol, -1]], _?(! NumericQ[#] &)]

  • Prev by Date: Re: cant free ram..
  • Next by Date: Re: Why is InputField changing format of input formula?
  • Previous by thread: Re: Generalization of Variables ?
  • Next by thread: Piecewise once more