Subject: Factoring matrix expressions, even trivial ones?
From: Stavros Macrakis
Date: Fri, 3 May 2013 10:41:09 -0400
For your trivial case, you could always do something like this:
/* Returns a list [ const, m/const ], where const is the GCD of the
vector/matrix entries. */
matrix_constant(m) :=
block([const, flat, inflag:true],
if mapatom(m)
then [1,m]
elseif member(op(m),["[",op(matrix())])
then
(flat: if op(m)="[" then m else apply('append,args(m)),
const: xreduce('gcd,flat,1),
[const, m/const] )
else [1,m])$
This gets its basic behavior from GCD, so there may be some surprising
cases:
matrix_constant([a/3,a/2]) => [a/6,[2,3]]
matrix_constant([a,a/x]) => [a/x,[x,1]]
You can define your own variant of GCD if necessary.
-s
On Fri, May 3, 2013 at 9:30 AM, Henry Baker <hbaker1 at pipeline.com> wrote:
> Is there any way for Maxima to factor 'a' back out of a*M, as below?
>
> Maxima 5.28.0-2 http://maxima.sourceforge.net
> using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) M:transpose([x,y]);
> [ x ]
> (%o1) [ ]
> [ y ]
> (%i2) a*M;
> [ a x ]
> (%o2) [ ]
> [ a y ]
> (%i3) %,factor;
> [ a x ]
> (%o3) [ ]
> [ a y ]
> (%i4) ????
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>