Question: Substituting for expressions that contain operators from the Physics package

What's the simplest way to partially substitute for expressions that contain operators from the Physics package? 
(hopefully my worksheet below shows what I mean)
Thanks

restart:

with(Physics):

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1092 and is the same as the version installed in this computer, created 2021, October 18, 14:11 hours Pacific Time.`

(1)

Setup(quantumoperators = {sigma__x, sigma__y, sigma__z, rho, H, comm}, mathematicalnotation = true);

[mathematicalnotation = true, quantumoperators = {H, comm, rho, sigma__x, sigma__y, sigma__z}]

(2)

we could just use Physics:-Psigma, etc... but here let's define these manually:

Setup(algebrarules={
%Commutator(sigma__x, sigma__y) = 2*I*sigma__z,
%Commutator(sigma__y, sigma__z) = 2*I*sigma__x,
%Commutator(sigma__z, sigma__x) = 2*I*sigma__y
}
);

[algebrarules = {%Commutator(sigma__x, sigma__y) = (2*I)*sigma__z, %Commutator(sigma__y, sigma__z) = (2*I)*sigma__x, %Commutator(sigma__z, sigma__x) = (2*I)*sigma__y}]

(3)

some expression (normally long and complicated that contains many operators):

expr:=(sigma__y*sigma__x*rho - sigma__y*rho*sigma__x);

Physics:-`*`(sigma__y, sigma__x, rho)-Physics:-`*`(sigma__y, rho, sigma__x)

(4)

say want to make this type of substitution:

subs_vars:=sigma__y*sigma__x=H;

Physics:-`*`(sigma__y, sigma__x) = H

(5)

this doesn't work

algsubs(subs_vars, expr);

Physics:-`*`(sigma__y, sigma__x, rho)-Physics:-`*`(sigma__y, rho, sigma__x)

(6)

this also doesn't work:

subs(subs_vars, expr);

Physics:-`*`(sigma__y, sigma__x, rho)-Physics:-`*`(sigma__y, rho, sigma__x)

(7)

this works (here we explicitly specify the whole thing, that includes rho)

subs(sigma__y*sigma__x*rho=H*rho, expr);

Physics:-`*`(H, rho)-Physics:-`*`(sigma__y, rho, sigma__x)

(8)

but I would like for the substitution to also work for *parts* of the expression, as in the normal case, when not using operators.

 

 

 

Download maple_1.mw

Please Wait...