maxima programming questions



On 4/29/10, Camm Maguire <camm at maguirefamily.org> wrote:

> Now say I want to simplify all monomials in l,lb to result in 1, -1,
> l^m or lb^m, n>m>0.  In other words, l^(n+m) -> lb^(n-m).

Maybe you can use tellsimpafter instead of tellrat?

(%i1) display2d : false;

(%o1) false
(%i2) matchdeclare (mm, "<="(n));

(%o2) done
(%i3) tellsimpafter (l^mm, lb^(n - mod(mm, n)));

(%o3) [?\^rule1,?simpexpt]
(%i4) n : 4;

(%o4) 4
(%i5) l^9;

(%o5) lb^3
(%i6) l^2;

(%o6) l^2
(%i7) l^11;

(%o7) lb
(%i8) p : l^5 + l^4 + l^3 + l + 1;

(%o8) lb^4+lb^3+l^3+l+1
(%i9) p^2;

(%o9) (lb^4+lb^3+l^3+l+1)^2
(%i10) expand (%);

(%o10) lb^8+2*lb^7+lb^6+2*l^3*lb^4+2*l*lb^4+4*lb^4+2*l^3*lb^3+2*l*lb^3+2*lb^3
           +lb^2+2*l^3+l^2+2*l+1


tellsimpafter could also handle powers of lb, and probably also
products of l and lb.

Hope this helps,

Robert Dodier