Replacment for FREEOF



if nfreeof(e,L) is the same as
    apply(freeof, append (L, [e]))

but more efficient, maybe you are
worrying prematurely about speed.

The rat form check is maybe more significant,
but it would be prudent to somehow try to profile
your code to see if freeof is taking lots of time.

Checking the varlist and then the body of an MRAT
as you say is what you have to do. It's a different
kind of search, looking at successive car's until
you hit one of the generated vars like G28, or go
past the last of them that contains $X etc.

Unnecessarily disrepping a rat form could be
expensive if you do it very many times and solely
to do a freeof test. One way of fixing this though
is to remember if an expression is freeof something
so the next check is fast.

RJF



dan.stanger@ieee.org wrote:
> Richard Fateman <fateman@cs.berkeley.edu> wrote:
> 
>>Subject: Re: [Maxima] Replacment for FREEOF
>>
>>1. freeof is the way it is so it can be used in pattern matching
>>as in  declare(a,freeof(x)).   I suppose you could change the
>>conventions for calls to predicates for pattern matching, but
>>unless you do so, you better leave freeof in there.
> 
> This is a good point.
> 
>>2. Deprecating functions in maxima seems to be essentially
>>impossible.  All one can do is leave out a feature from
>>your version of the documentation, I think.
> 
> OK, no deprecation.
> 
>>3. Checking a rat form to see if it  depends on a variable
>>is complicated.  An expression could be a rational polynomial
>>in x, y, sin(x).  But it might happen to have simplified
>>so that it is 0*x+0*sin(x)+0*y+45.
> 
> Using this example, rat(0*x+0*sin(x)+0*y+45,x,y,sin(x));
> is ((MRAT SIMP ($X $Y ((%SIN SIMP) $X)) (G28 G27 G26)) 45 . 1).
> so $X is g28.
> also in this example.
> rat(2*x) is ((MRAT SIMP ($X) (G28 G27 G26)) (G28 1 2) . 1)
> For cre expressions I could first check the head of the expression,
> to see if the variable list contains $X in the first place, if it does
> then I could look at the rest of the expression to see if it contains G28.
> 
>>4. I'm not sure what your intent is (0r if you've said
>>it right). Do you intend to look "syntactically" in the
>>expression tree to see if there is an occurrence of x
>>and say it is there?
> 
> I need a function that takes a list of variables and a expression
> and works like freeof.  However, looking at the freeof code,
> it reverses the argument list, converts all the elements to general form,
> and then loops over the 2nd thru last arguments.
> For me to call freeof the arguments
> require me to create a list, add the expression to the end, and
> apply freeof.
> I can think of a few improvments other than the argument list:
> Convert the arguments one at a time, work with both rat and not rat
> expressions.
> 
>>Maybe you could use another word different from nfree, like
>>independent  or syntacticallyfree  or ??
> 
> Does freeof implement independent or syntacticallyfree? 
> What name would you suggest?
> 
>>RJF
>>
>>
>>Dan Stanger wrote:
>>
>>>I am going to write a replacement for freeof.
>>>For reference following is the original definition:
>>>Function: FREEOF (x1, x2, ..., exp)
>>>    yields TRUE if the xi do not occur in exp and FALSE otherwise. The
>>>xi are atoms or they may be subscripted names,
>>>    functions (e.g. SIN(X) ), or operators enclosed in "s. If 'var' is a
>>>"dummy variable" of 'exp', then FREEOF(var,exp); will
>>>    return TRUE. "Dummy variables" are mathematical things like the
>>>index of a sum or product, the limit variable, and the
>>>    definite integration variable. Example: FREEOF(I,'SUM(F(I),I,0,N));
>>>returns TRUE. Do EXAMPLE(FREEOF); for more
>>>    examples.
>>>
>>>My replacement NFREEOF is defined as follows:
>>>NFREEOF(exp, x1,x2...) or NFREEOF(exp,list).
>>>Currently, FREEOF converts each of its arguments to general form.
>>>For now, I am going to check if the xi or the elements of the list are
>>>in rat form and convert them then,
>>>a improvment will be to to the check without the conversion.
>>>I would also like to deprecate FREEOF.
>>>Comments?
>>>Dan Stanger
>>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima