I want to use the Variables[]
function to extract the name of the variable of a function, such that I can use it later, e.g. in a Plot[]
function.
The following Mathematica code provides a minimal working example:
f=x+x^2
Variables[f]
Plot[f,{x,-2,2}]
Plot[f,{Variables[f],-2,2}]
Please note that I am aware there are better ways to define functions, such as f[x_]:=x+x^2
. I also know I could use a Rule[]
applied to f
to define a new dummy variable within the Plot[]
function. That is not the point.
The example I provided is simply a short piece of code to test the way Variables[]
works. My question concerns the function Variables[]
, what it returns and how it can be used.