inexpression(x,g) ?



-----maxima-bounces at math.utexas.edu wrote: -----

>I want to get a yes/no answer to the question:
>
>does the expression g depend explicitly on a variable x.
>
>Is there some built in function for this?
>
>My only approach so far is
>
>elementp( string(x), setify( charlist( string(g) ) ) )

I don't think this function will do what you want it to do; example:

(%i1) inexpression(g,x) := elementp( string(x), setify( charlist( string(g)
) ) )$

Is 'i' in the expression sin(x)? Yikes! inexpression say that it is:

(%i2) inexpression(sin(x),i);
(%o2) true

Let's try using freeof; something like:
(%i3) inexpression(g,x) := not(freeof(x,g))$

(%i4) inexpression(sin(x),i);
(%o4) false

(%i5) inexpression(sin(x),x);
(%o5) true

freeof might not do everything the way you prefer:

(%i8) inexpression(sum(1/k^42,k,1,inf),inf);
(%o8) true

(%i9) inexpression(sum(1/k^42,k,1,inf),k);
(%o9) false

(%i10) inexpression(sum(1/k^42,k,1,inf),1);
(%o10) true

(%i11) inexpression(sum(1/k^42,k,1,inf),42);
(%o11) false

Barton