On Nov 20, Barton Willis wrote:
> An example might help me understand.
-------------------------------------------------------------
Thanks for the improved code.
The ultimate objective is to symbolically evaluate things like
comm (3*s1*a^^2 + 4*s2*b^^3 , (s3*a^^4)/5 - 6*s4*c^^5),
with (s1,s2,s3) being declared scalars, and
a^^2 = a . a, for example, and
with the final result in terms of comm (a, b) = -comm (b, a),
comm (a, c) and comm (b, c), letting the user then
replace the basic commutators with whatever the algebra
dictates.
The use of multiadditive gets the linear in each arg property
of the commutator.
In addition to the antisymmetric property of comm, we need
to obey the basic product rules:
comm (a . b ,c) --> a . comm(b, c) + comm (a, c) . b
comm (a, b . c) --> b . comm (a, c) + comm (a, b) . c
in which the dot "." is being used for noncommutative
multiplication, since (a, b, c) here are symbols which
represent operators, matrices, etc., and hence we need
to preserve the correct ordering of (a,b,c) in the
final result.
Ted
=========================
----- Original Message -----
From: Barton Willis
To: Edwin Woollett
Cc: maxima mailing list
Sent: Saturday, November 20, 2010 4:42 AM
Subject: Re: [Maxima] matchdeclare and tellsimpafter
-----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=
=============================