# [Maxima] Negligible terms in polynomials

Stefano Ferri ferriste at gmail.com
Sat Jan 10 06:35:07 CST 2009

```Sorry but I have another problem... I'm trying to use your freeof_var
with the function  tou suggested me to make some terms negligible in
polynomials, here is a little example with a matrix:

(%i2) u:matrix([M/I+F/A], [M/I], [F/A])\$
(%i3) freeof_var (ee, [x]) := block ([v : listofvars(ee)],
not apply("or", map (lambda([xx], member(xx,v)), x)))\$
(%i4) setcheck:true\$

here terms are recognized and neglected using freeof:

(%i5)  map (lambda([e], if freeof(A,e) or freeof(I,e) then e else
limit(e, A, inf)), u);
e SET TO [M/I+F/A]
e SET TO [M/I]
e SET TO [F/A]
(%o5) matrix([M/I],[M/I],[F/A])

that is correct. But when I use freeof_var

(%i6) map (lambda([e], if freeof_var(I,e) or freeof_var(A,e) then e else
limit(e, A, inf)), u);
e SET TO [M/I+F/A]
ee SET TO I
x SET TO [[M/I+F/A]]
v SET TO [I]
xx SET TO [M/I+F/A]
e SET TO [M/I]
ee SET TO I
x SET TO [[M/I]]
v SET TO [I]
xx SET TO [M/I]
e SET TO [F/A]
ee SET TO I
x SET TO [[F/A]]
v SET TO [I]
xx SET TO [F/A]
(%o6) matrix([M/I+F/A],[M/I],[F/A])

(%i7) map (lambda([e], if freeof_var(A,e) or freeof_var(I,e)  then e
else limit(e, A, inf)), u);
e SET TO [M/I+F/A]
ee SET TO A
x SET TO [[M/I+F/A]]
v SET TO [A]
xx SET TO [M/I+F/A]
e SET TO [M/I]
ee SET TO A
x SET TO [[M/I]]
v SET TO [A]
xx SET TO [M/I]
e SET TO [F/A]
ee SET TO A
x SET TO [[F/A]]
v SET TO [A]
xx SET TO [F/A]
(%o7) matrix([M/I+F/A],[M/I],[F/A])

these results are wrong, u[1,1] should become M/I. Even when using a
single element of u there are problems:

(%i15) if freeof_var(A,u[1,1]) or freeof_var(I,u[1,1]) then u[1,1] else
limit(u[1,1], A, inf);
ee SET TO A
x SET TO [M/I+F/A]
v SET TO [A]
xx SET TO M/I+F/A
(%o15) M/I+F/A

ee is set only once, and so v...

When freeof_var is contained within an "if" statement, only the first
condition is evaluated.
With setcheck one can notice that in the "if freeof_var(A,e) or
freeof_var(I,e)" only the first condition is considered, to ee is
assigned only I in the %i6 example and only A in the %i7 example, and so
the limit is never evaluated.
Sorry but I don't understand why... Is it an issue related to the
nesting of lambda functions?

Stefano

Alexey Beshenov ha scritto:
> On Friday 09 January 2009 02:21:49 Stefano Ferri wrote:
>
>
>> (%i1) freeof(I[1], I[1]);
>> (%o1) false
>> (%i2) freeof(I[1], I);
>> (%o2) true
>> (%i3) freeof(I, I[1]);
>> (%o3) false
>>
>> %o1 and %o2 are correct, %o3 is wrong. Is it normal this behaviour?
>> Maybe I've made some bad coding, in my program I've used subscript
>> not only for lists and arrays, but also to distinguish the
>> properties of different element of the structure, so in this
>> particular case I, I[1], I[2] are separate entities. I[1] and I[2]
>> don't indicate the first and the second element of I. So the above
>> result %o3 from freeof is correct? But above all, why %o3 is false
>> if %o2 is true?
>>
>
> op(I[1])=I, args(I[1])=[1]. So I[1] contains I, as an operator.
>
> You can try something like
>
> freeof_var (e, [x]) := block ([v : listofvars(e)],
>   not apply("or", map (lambda([xx], member(xx,v)), x))
> )\$
>
> freeof_var (a[1] + b[2] + c[3], a,b,c) => true
> freeof_var (a[1] + b[2] + c[3], a[1],b,c) => false
> freeof (a,b,c, a[1] + b[2] + c[3]) => false
>
>

```