-----maxima-bounces at math.utexas.edu wrote: -----
>This?is?a?great?utility.?Is?there?documentation for?simplifying.lisp?
Yes, the user documentation is in the source file (share/contrib/simplifying.lisp).
>I?would?also?like?to?factor?out?declared?scalars, as?I?try?to?do?below.
Extended and possibly less broken:
(%i1) load(simplifying)$
(%i13) scalar_part(e) :=
if mapatom(e) or constantp(e) then (
if scalarp(e) = true then [e,1] else [1,e])
else if ?mtimesp(e) then (
rreduce(lambda([s,w], map("*",s,w)), map('scalar_part, args(e))))
else [1,e]$
(%i17) simp_comm(a,b) := block([ac, bc, prederror : false],
if is(equal(a,b)) = true or is(equal(a,1)) = true or is(equal(b,1)) = true then 0
else (
[ac,a] : scalar_part(a),
[bc,b] : scalar_part(b),
if ordergreatp(a,b) then (
[a,b] : [b,a],
ac : - ac),
a : ac * bc * simpfuncall('comm,a,b),
if is(equal(ac,1))=true and is(equal(bc,1))=true then a else expand(a,0,0)))$
(%i4) simplifying('comm,'simp_comm)$
(%i5) load(multiadditive)$
(%i6) declare(comm,multiadditive)$
Examples:
(%i29) comm(%pi*a, sqrt(5) * (a+b));
(%o29) sqrt(5)*%pi*comm(a,b)
(%i30) comm(comm(a-b,b),comm(4*a,b));
(%o30) 0
(%i31) declare([s1,s2,s3,s4],scalar)$
(%i32) comm(s1*a,b);
(%o32) s1*comm(a,b)
(%i33) comm(2*a+b,c);
(%o33) comm(b,c)+2*comm(a,c)
(%i34) comm(2*a+b/3,c);
(%o34) 3*comm(b,c)+2*comm(a,c)
>Finally?I?need?to?add?rules?(or?else...)?to?get?products?of
>faux-matrix?objects?to?expand?correctly?after?pulling?out
>numbers?and?scalars?and?expanding?with?the?linear?in
>each?arg?property?supplied?by?multiadditive.
An example might help me understand.
--Barton