Menu

#3944 (q*M)^^-1 doesn't expand out

None
open
nobody
5
2022-02-21
2022-02-20
No
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

Discussion

  • Robert Dodier

    Robert Dodier - 2022-02-21

    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 if dotscrules is nonnull; see SIMPNCT-CONSTANTP and SIMPNCT-ASSUMESCALARP, respectively.

    The default value of dotconstrules is true, so literal or declared constants are pulled out. The default value of dotscrules is false, so scalars are not pulled out. However, changing to the other value (false or true) 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 for dotconstrules, dotscrules, and assumescalar. Likewise those flags should be mentioned in the documentation for ^^.

     
  • Robert Dodier

    Robert Dodier - 2022-02-21
    • labels: --> noncommutative exponent, documentation
     
  • Stavros Macrakis

    Thanks for looking in to this. Indeed, dotscrules:true$ assumescalar:all takes care of this case. However, according to the documentation of assumescalar, an undeclared symbol which is an argument to a commutative operator like * is assumed scalar, so this should work:

    declare(A,nonscalar)$
    dotscrules:true$
    (q*A)^^-1  =>  (A*q)^^-1   <<< ???
    

    Although the doc for assumescalar only mentions explicit lists and matrices, not symbols declared nonscalar as the other argument, the fact that it works in the all case suggests that it should work in the true case as well.

    PS I had actually tested all the dotxxx variables... though not assumescalar.

     

    Last edit: Stavros Macrakis 2022-02-21

Log in to post a comment.