> I need a function that takes a list of variables and a expression
> and works like freeof. However, looking at the freeof code,
Dan,
You bring up three issues with the current Freeof:
1) Semantics: It does not understand the concept of bound variables.
2) Efficiency: It could be faster on CREs and other cases.
3) Lisp interface: it is inconvenient to call from Lisp.
------------ Semantics ---------
I think it is definitely worth thinking about a "semantic freeof". One
subtlety which you may or may not want to consider is Maxima's notion of
dependency (cf. Depends command). In the following example, the
expression "y" is syntactically free of x, but still depends on it
semantically:
(C5) depends(y,x);
(D5) [y(x)]
(C6) diff(y,x);
(D6) 'DIFF(y,x,1)
So what should be the result of NFreeOf(y,x)?
While you're at it, you might also want to clean up At, which covers
only the very simplest case of semantic substition:
at(integrate(f(x),x),x=3) => 'at('integrate(f(x),x),x=3)
Correct, because result of integrate is a function of x
at('limit(x,x,inf),x=3) => 'at('limit(x,x,inf),x=3)
Incorrect, because result of limit is not a function of x.
Correct answer is 'limit(x,x,inf)
at(lambda([i],i),i=3) => lambda([3],3) !!!
at (f(x):=x, x=9) => f(9) := 9 !!!
----------- Efficiency ------------
Efficiency is good, but shouldn't be sacrificed to correctness.
Moreover, it often turns out that efficiency doesn't matter. So I would
urge you to first get it right, then MAYBE later improve the efficiency,
IF it turns out to matter.
Indeed, many parts of Maxima lose efficiency by using Specdisrep before
doing anything else, but at least that gives the right answer. There
are many cases where Specdisrep is NOT being called, but should be:
[ 640332 ] Need to specdisrep more systematically
https://sourceforge.net/tracker/index.php?func=detail&aid=640332&group_i
d=4933&atid=104933
[ 643259 ] orderlessp([rat(x)], [rat(x)])
https://sourceforge.net/tracker/index.php?func=detail&aid=643259&group_i
d=4933&atid=104933
[ 649669 ] is(equal([x],[rat(x)])) => FATAL ERROR
https://sourceforge.net/tracker/index.php?func=detail&aid=649669&group_i
d=4933&atid=104933
-------------- Lisp interface ------------
Again, there are lots of places in Maxima which do not have pretty Lisp
interfaces, and yes at some point they should be cleaned up. But for
now, why not just define a front-end function which reformats things?
The efficiency overhead of a handful of cons's is really negligeable.
-s