matrix([1,1],[a,1])^^-1,detout;
[ 1 - 1 ]
[ ]
[ - a 1 ]
------------
1 - a
%^^-1;
[ 1 - 1 ]
[ ]
[ - a 1 ] <- 1>
(------------)
1 - a
Contrast
matrix([1,1],[-1,1])^^-1,detout;
[ 1 - 1 ]
[ ]
[ 1 1 ]
----------
2
%^^-1;
[ 1 1 ]
[ ]
[ - 1 1 ]
I thought that the problem is that detout returns a pseudo-simplified (non-canonically simplified) expression. But in fact this happens even with correctly simplified expressions:
declare(A,nonscalar)$
(q*A)^^-1 => (q*A)^^-1
>>> should be A^^-1/q
but
(2*A)^^-1 => A^^-1 / 2
I don't believe this behavior is controlled by a dotxxx setting, but I may be mistaken.
Maxima 5.45.1 SBCL 2.0.0 Windows
Looking at the code (SIMPNCEXPT in src/mdot.lisp), I see that behavior is governed by SIMPNCT-SC-OR-CONSTP in lines 280--281. A constant factor is pulled out if
dotconstrules
is nonnull, and a scalar factor is pulled out ifdotscrules
is nonnull; see SIMPNCT-CONSTANTP and SIMPNCT-ASSUMESCALARP, respectively.The default value of
dotconstrules
istrue
, so literal or declared constants are pulled out. The default value ofdotscrules
isfalse
, so scalars are not pulled out. However, changing to the other value (false
ortrue
) changes the behavior as expected. Also,assumescalar: all
causes undeclared symbols to be treated as scalars, as expected.At this point I think the code is working as expected, and it's just a matter of mentioning
^^
in the documentation fordotconstrules
,dotscrules
, andassumescalar
. Likewise those flags should be mentioned in the documentation for^^
.Thanks for looking in to this. Indeed,
dotscrules:true$ assumescalar:all
takes care of this case. However, according to the documentation ofassumescalar
, an undeclared symbol which is an argument to a commutative operator like*
is assumed scalar, so this should work:Although the doc for
assumescalar
only mentions explicit lists and matrices, not symbols declarednonscalar
as the other argument, the fact that it works in theall
case suggests that it should work in thetrue
case as well.PS I had actually tested all the dotxxx variables... though not
assumescalar
.Last edit: Stavros Macrakis 2022-02-21