Search code examples
maple

Assume that a matrix is idempotent in maple


I'm trying to use the following code in maple to simplify this expression.

simplify((Q+P)*a_1+P*a_2-((Q+P)*b_1+P*b_2)*(d_2*Q/d_1+P)/d_2)

However, I want to assume that Q+P=I, which is the identity and further, I want to assume that PP=P and QQ=Q, meaning that P and Q are idempotent.

I know I should use the assume statement somehow, but I'm not sure how it exactly works.

Also, maple doesn't seem to know that I'm using matrices.

Thanks.


Solution

  • So, are Q and P supposed to represent Matrices, and all the other names represent scalars?

    ee:=(Q+P)*a_1+P*a_2-((Q+P)*b_1+P*b_2)*(d_2*Q/d_1+P)/d_2:
    U:=simplify(subs(Q=Id-P,ee),{P^2=P,Id^2=Id,Id*P=P}):
    collect(expand(U),[P,Id]);
    
                  /      b_1   b_1   b_2\     /      b_1\
                  |a_2 - --- + --- - ---| P + |a_1 - ---| Id
                  \      d_2   d_1   d_2/     \      d_1/
    

    I was about to mention being careful about products such as Q*P since you've used the commuting multiplication * instead of the noncommutative . for multiplication. But perhaps it follows from your conditions that Q.P is the zero Matrix since Q.P+P = Q.P+P.P = (Q+P).P = P. And the Q may be replaced by Id-P right away, anyway.