Louis Lamarche

105 Reputation

7 Badges

19 years, 29 days
Hydro-Quebec

MaplePrimes Activity


These are replies submitted by Louis Lamarche


Instead of a URL I now use a button with an image icon showing the first
image of the animation.

The button action is something like:

use DocumentTools in
    pid:=system[launch]("C:\\Program Files\\Internet Explorer\\iexplore.exe file://C:\\Users\...\\Documents\\...l\\Animation.htm ");
end use; 
This will lauch iexplorer without exiting the Slideshow mode in
MAPLE and MAPLEPLAYER



 

@Kitonum 

To generate a GIF you right click on the plot and <export> it in GIF.
It may not be optimized. I used the Gimp software to compress it without
loss of resolution with impressive results.

 

@acer 
I was not aware of this startup code options. Sorry.
The first example works best since it can be run again with full MAPLE without changing the graphic size.


Here is an example code of what I want to do for my talk.

It works in a Maple Slideshow but not in a MaplesPlayer Slideshow (F11 function key)

MaplePlayerSlideShowTest.mw

I did not have time work on this subject since a long time.

Here are some of my latest work.
1) I added a few lines to the ExpandQop version 4 available in the last post it is now at version 5.
2) Created two procedures to work more easily with multiple qubits using the StringTool package they are in the ImplodeExplodeStates.mw file below
3) The new QuantumTeleportation file provides
    a) The dentisty matrix of |phi2>
    b) Some examples of calculations with partial traces.

Hope this is interresting.

ImplodeExplodeStates.mw


 

Author:  Louis Lamarche   lamarche.louis@ireq.ca                               
               Institute of Research of Hydro-Quebec (IREQ)
               Science des données et calcul haute performance
               2018, July 25             

File:        QuantumTeleportationDensityMatrix.mw            

Purpose:  Teleport a pure quantum state                    

This versoin was tested in Maple2018.1 and Maple2018.2 using
the ExpandQopV5 procedure and the ImplodeExplodeStates procedures.             

Note: Multi qubits states and operators are represented                   
          by sums of tensor products of non commutative bras   
          and kets.

restart;
with(Physics):
with(StringTools):
Physics:-Version();
interface(imaginaryunit=i):
Setup(mathematicalnotation=true);

"C:\Users\ax6628\maple\toolbox\2018\Physics Updates\lib\Physics Updates.maple", `2018, November 13, 10:22 hours, version in the MapleCloud: 198, version installed in this computer: 195`

 

[mathematicalnotation = true]

(1)

Setup(unitaryoperators={I,U,X,Y,Z,H,HI,CNOT,CnotI,rho});
Setup(noncommutativeprefix={q,beta,psi,ket});

[unitaryoperators = {CNOT, CnotI, H, HI, I, U, X, Y, Z, rho}]

 

[noncommutativeprefix = {beta, ket, psi, q}]

(2)

Setup(bracketrules= { %Bracket(%Bra(q0), %Ket(q0))=1,
                      %Bracket(%Bra(q1), %Ket(q1))=1,
                      %Bracket(%Bra(q1), %Ket(q0))=0,
                      %Bracket(%Bra(q0), %Ket(q1))=0
                    });

[bracketrules = {%Bracket(%Bra(q0), %Ket(q0)) = 1, %Bracket(%Bra(q0), %Ket(q1)) = 0, %Bracket(%Bra(q1), %Ket(q0)) = 0, %Bracket(%Bra(q1), %Ket(q1)) = 1}]

(3)

################################################################################
# Load the procedure and set the required global variables
#
read "ExpandQopV5.m":
optp:=op(0,Ket(q0)*Ket(q1)):
optpx:= op(0,(Ket(q0)+Ket(q1))^2):
read "ImplodeExplodeStates.m":
#
################################################################################

IS:=proc(state) ImplodeState(state) end proc: # Usefull ImplodeState name contraction
ES:=proc(state) ExplodeState(state) end proc: # Usefull ExplodeState name contraction

# Define the Ket and the Bra
DS:=proc(name)
    Ket(name):=ES(Ket(name)); Bra(name):=Dagger(Ket(name));
    return 'Ket(name)'=Ket(name), 'Bra(name)'=Bra(name);
    end proc:

# Undefine a multiqubit state
UD:=proc(name)
    Ket(name):='Ket(name)';   Bra(name):='Bra(name)';
    return;
    end proc:

# This is usefull to represent a 2 qubits system
DefineStates:=proc()
    DS(q00); DS(q01); DS(q10); DS(q11);
    return;
    end proc:
UndefineStates:=proc()
    UD(q00); UD(q01); UD(q10); UD(q11);
    return;
    end proc:

#
# ... Lines of first post deleted
#

UndefineStates(); # To prevent interference with the ImplodeState procedure

#
# Display the operator x in matrix form
#
OPtoMatrix:=proc(x,values)
    # values = true:  compute the symbolic values
    # values = false: return the marix element names
    local j,k,l,m,n,o,ik,bk,ret,iket,ibra,bra,ket;
    
    ik[0]:=Ket(q0); bk[0]:=Bra(q0);
    ik[1]:=Ket(q1); bk[1]:=Bra(q1);
    ret:=Matrix(8,8);
    for j from 0 to 1 do
        for k from 0 to 1 do
            for l from 0 to 1 do
                ibra:=j*4+k*2+l+1;
                bra:=bk[l]*bk[k]*bk[j]; # Ordre inversé
                for m from 0 to 1 do
                    for n from 0 to 1 do
                        for o from 0 to 1 do
                            iket:=m*4+n*2+o+1;
                            ket:=ik[m]*ik[n]*ik[o];
                            if values
                            then ret[ibra,iket]:=bra.x.ket;
                            else ret[ibra,iket]:=ImplodeState(bra).'rho'.ImplodeState(ket);
                            fi;
                        end do;
                    end do;
                end do;
            end do;
        end do;
    end do;
    return ret;
    end proc:

print("I would never try to compute this by hand");
rho:=ExpandQop(Ket(psi[2])*Dagger(Ket(psi[2]))): # this operator has 8x8=64 terms
'rho[m]'=OPtoMatrix(rho,false);
'rho[m]'=OPtoMatrix(rho,true);

"I would never try to compute this by hand"

 

rho[m] = (Matrix(8, 8, {(1, 1) = Bracket(Bra(q000), rho, Ket(q000)), (1, 2) = Bracket(Bra(q000), rho, Ket(q001)), (1, 3) = Bracket(Bra(q000), rho, Ket(q010)), (1, 4) = Bracket(Bra(q000), rho, Ket(q011)), (1, 5) = Bracket(Bra(q000), rho, Ket(q100)), (1, 6) = Bracket(Bra(q000), rho, Ket(q101)), (1, 7) = Bracket(Bra(q000), rho, Ket(q110)), (1, 8) = Bracket(Bra(q000), rho, Ket(q111)), (2, 1) = Bracket(Bra(q001), rho, Ket(q000)), (2, 2) = Bracket(Bra(q001), rho, Ket(q001)), (2, 3) = Bracket(Bra(q001), rho, Ket(q010)), (2, 4) = Bracket(Bra(q001), rho, Ket(q011)), (2, 5) = Bracket(Bra(q001), rho, Ket(q100)), (2, 6) = Bracket(Bra(q001), rho, Ket(q101)), (2, 7) = Bracket(Bra(q001), rho, Ket(q110)), (2, 8) = Bracket(Bra(q001), rho, Ket(q111)), (3, 1) = Bracket(Bra(q010), rho, Ket(q000)), (3, 2) = Bracket(Bra(q010), rho, Ket(q001)), (3, 3) = Bracket(Bra(q010), rho, Ket(q010)), (3, 4) = Bracket(Bra(q010), rho, Ket(q011)), (3, 5) = Bracket(Bra(q010), rho, Ket(q100)), (3, 6) = Bracket(Bra(q010), rho, Ket(q101)), (3, 7) = Bracket(Bra(q010), rho, Ket(q110)), (3, 8) = Bracket(Bra(q010), rho, Ket(q111)), (4, 1) = Bracket(Bra(q011), rho, Ket(q000)), (4, 2) = Bracket(Bra(q011), rho, Ket(q001)), (4, 3) = Bracket(Bra(q011), rho, Ket(q010)), (4, 4) = Bracket(Bra(q011), rho, Ket(q011)), (4, 5) = Bracket(Bra(q011), rho, Ket(q100)), (4, 6) = Bracket(Bra(q011), rho, Ket(q101)), (4, 7) = Bracket(Bra(q011), rho, Ket(q110)), (4, 8) = Bracket(Bra(q011), rho, Ket(q111)), (5, 1) = Bracket(Bra(q100), rho, Ket(q000)), (5, 2) = Bracket(Bra(q100), rho, Ket(q001)), (5, 3) = Bracket(Bra(q100), rho, Ket(q010)), (5, 4) = Bracket(Bra(q100), rho, Ket(q011)), (5, 5) = Bracket(Bra(q100), rho, Ket(q100)), (5, 6) = Bracket(Bra(q100), rho, Ket(q101)), (5, 7) = Bracket(Bra(q100), rho, Ket(q110)), (5, 8) = Bracket(Bra(q100), rho, Ket(q111)), (6, 1) = Bracket(Bra(q101), rho, Ket(q000)), (6, 2) = Bracket(Bra(q101), rho, Ket(q001)), (6, 3) = Bracket(Bra(q101), rho, Ket(q010)), (6, 4) = Bracket(Bra(q101), rho, Ket(q011)), (6, 5) = Bracket(Bra(q101), rho, Ket(q100)), (6, 6) = Bracket(Bra(q101), rho, Ket(q101)), (6, 7) = Bracket(Bra(q101), rho, Ket(q110)), (6, 8) = Bracket(Bra(q101), rho, Ket(q111)), (7, 1) = Bracket(Bra(q110), rho, Ket(q000)), (7, 2) = Bracket(Bra(q110), rho, Ket(q001)), (7, 3) = Bracket(Bra(q110), rho, Ket(q010)), (7, 4) = Bracket(Bra(q110), rho, Ket(q011)), (7, 5) = Bracket(Bra(q110), rho, Ket(q100)), (7, 6) = Bracket(Bra(q110), rho, Ket(q101)), (7, 7) = Bracket(Bra(q110), rho, Ket(q110)), (7, 8) = Bracket(Bra(q110), rho, Ket(q111)), (8, 1) = Bracket(Bra(q111), rho, Ket(q000)), (8, 2) = Bracket(Bra(q111), rho, Ket(q001)), (8, 3) = Bracket(Bra(q111), rho, Ket(q010)), (8, 4) = Bracket(Bra(q111), rho, Ket(q011)), (8, 5) = Bracket(Bra(q111), rho, Ket(q100)), (8, 6) = Bracket(Bra(q111), rho, Ket(q101)), (8, 7) = Bracket(Bra(q111), rho, Ket(q110)), (8, 8) = Bracket(Bra(q111), rho, Ket(q111))}))

 

rho[m] = Matrix(%id = 18446744074609312582)

(4)

rho__Alice=Tr__Bob('rho');

rho__Alice = Tr__Bob(rho)

(5)

SomBob:=proc(k)
   local ret,j,ik;
   ik[0]:=Ket(q0);
   ik[1]:=Ket(q1);
   ret:=0;
   for j from 0 to 1 do
       ret:=ret+Dagger(k*ik[j]).rho.(k*ik[j]);
   end do;
   return ret;
   end proc:

"Matrix elements of", rho__Alice;
'(Bra(q0)*Bra(q0)).rho__Alice.(Ket(q0)*Ket(q0))'='Dagger(Ket(q0)*Ket(q0)*Ket(q1)).rho.(Ket(q0)*Ket(q0)*Ket(q1))'
                                                +'Dagger(Ket(q0)*Ket(q0)*Ket(q0)).rho.(Ket(q0)*Ket(q0)*Ket(q0))';
'(Bra(q0)*Bra(q0)).rho__Alice.(Ket(q0)*Ket(q0))'=SomBob(Ket(q0)*Ket(q0));
'(Bra(q1)*Bra(q0)).rho__Alice.(Ket(q0)*Ket(q1))'=SomBob(Ket(q0)*Ket(q1));
'(Bra(q0)*Bra(q1)).rho__Alice.(Ket(q1)*Ket(q0))'=SomBob(Ket(q1)*Ket(q0));
'(Bra(q1)*Bra(q1)).rho__Alice.(Ket(q1)*Ket(q1))'=SomBob(Ket(q1)*Ket(q1));

"Matrix elements of", rho__Alice

 

Physics:-`.`(Physics:-`*`(Physics:-Bra(q0), Physics:-Bra(q0)), rho__Alice, Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0))) = Physics:-`.`(Physics:-Dagger(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1))), rho, Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1)))+Physics:-`.`(Physics:-Dagger(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))), rho, Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0)))

 

Physics:-`.`(Physics:-`*`(Physics:-Bra(q0), Physics:-Bra(q0)), rho__Alice, Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0))) = (1/4)*abs(a)^2+(1/4)*abs(b)^2

 

Physics:-`.`(Physics:-`*`(Physics:-Bra(q1), Physics:-Bra(q0)), rho__Alice, Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1))) = (1/4)*abs(a)^2+(1/4)*abs(b)^2

 

Physics:-`.`(Physics:-`*`(Physics:-Bra(q0), Physics:-Bra(q1)), rho__Alice, Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0))) = (1/4)*abs(a)^2+(1/4)*abs(b)^2

 

Physics:-`.`(Physics:-`*`(Physics:-Bra(q1), Physics:-Bra(q1)), rho__Alice, Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1))) = (1/4)*abs(a)^2+(1/4)*abs(b)^2

(6)

rhoAlice:=proc(rho)
   local ret,j,k,l,ik,elem,ket,bra,ketbra;
   ik[0]:=Ket(q0);
   ik[1]:=Ket(q1);
   ret:=0;
   for j from 0 to 1 do
       for k from 0 to 1 do
          elem:=0;
          ket:=ik[j]*ik[k];
          bra:=Dagger(ket);
          ketbra:=ket*bra;        
          for l from 0 to 1 do
              # Sum over Bobs single qubit
              elem:=elem+Dagger(ket*ik[l]).rho.(ket*ik[l]);
          end do;
          ret:=ret+elem*ketbra;
       end do;
   end do;
   return ret;
   end proc:

rho__Alice:=simplify(rhoAlice(rho));

(1/4)*(abs(b)^2+abs(a)^2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q1))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1)))

(7)

rhoBob:=proc(rho)
   local ret,j,k,l,ik,elem,ket,bra,ketbra;
   ik[0]:=Ket(q0);
   ik[1]:=Ket(q1);
   ret:=0;
   for j from 0 to 1 do
       elem:=0;
       ketbra:=ik[j]*Dagger(ik[j]);
       # Sum over Alice two qubits
       for k from 0 to 1 do
          for l from 0 to 1 do
              ket:=ik[k]*ik[l];
              bra:=Dagger(ket);
              elem:=elem+Dagger(ket*ik[j]).rho.(ket*ik[j]);
          end do;          
       end do;
       ret:=ret+elem*ketbra;
   end do;
   return ret;
   end proc:

rho__Bob:=simplify(rhoBob(rho));

(1/2)*(abs(b)^2+abs(a)^2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1)))

(8)

M__0:=Ket(q0)*Bra(q0);
M__1:=Ket(q1)*Bra(q1);

Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))

 

Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

(9)

p__0=Tr('M__0'.Dagger('M__0').'rho__Bob');
p__0=Tr(M__0.Dagger(M__0).rho__Bob);
Tr(M__0.Dagger(M__0).rho__Bob)='Bra(q0).M__0.Dagger(M__0).rho__Bob.Ket(q0)';
Tr(M__0.Dagger(M__0).rho__Bob)=Bra(q0).M__0.Dagger(M__0).rho__Bob.Ket(q0);
p__0:=rhs(%);
abs(a)^2+abs(b)^2=1;
'p__0'=1/2;
'M__0.rho__Bob.Dagger(M__0)'=M__0.rho__Bob.Dagger(M__0);
print("State of Bob's qubit after he measures 0");
'rho[0]'=rhs(%)/p__0;

p__0 = Tr(M__0*conjugate(M__0)*rho__Bob)

 

p__0 = Tr((1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0)))

 

Tr((1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))) = Physics:-`.`(Physics:-Bra(q0), M__0, Physics:-Dagger(M__0), rho__Bob, Physics:-Ket(q0))

 

Tr((1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))) = (1/2)*abs(a)^2+(1/2)*abs(b)^2

 

(1/2)*abs(a)^2+(1/2)*abs(b)^2

 

abs(b)^2+abs(a)^2 = 1

 

p__0 = 1/2

 

Physics:-`.`(M__0, rho__Bob, Physics:-Dagger(M__0)) = (1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))

 

"State of Bob's qubit after he measures 0"

 

rho[0] = Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))

(10)

p__1=Tr(M__1.Dagger(M__1).rho__Bob);
Tr(M__1.Dagger(M__1).rho__Bob)='Bra(q1).M__1.Dagger(M__1).rho__Bob.Ket(q1)';
Tr(M__1.Dagger(M__1).rho__Bob)=Bra(q1).M__1.Dagger(M__1).rho__Bob.Ket(q1);
p__1:=rhs(%);
abs(a)^2+abs(b)^2=1;
'p__1'=1/2;
'M__1.rho__Bob.Dagger(M__1)'=M__1.rho__Bob.Dagger(M__1);
print("State of Bos's qubit after he measures 1");
'rho[1]'=rhs(%)/p__1;

p__1 = Tr((1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1)))

 

Tr((1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))) = Physics:-`.`(Physics:-Bra(q1), M__1, Physics:-Dagger(M__1), rho__Bob, Physics:-Ket(q1))

 

Tr((1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))) = (1/2)*abs(a)^2+(1/2)*abs(b)^2

 

(1/2)*abs(a)^2+(1/2)*abs(b)^2

 

abs(b)^2+abs(a)^2 = 1

 

p__1 = 1/2

 

Physics:-`.`(M__1, rho__Bob, Physics:-Dagger(M__1)) = (1/2)*(abs(b)^2+abs(a)^2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

 

"State of Bos's qubit after he measures 1"

 

rho[1] = Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

(11)

rho2:=(I/2*I/2*rho__Bob);

(1/8)*(abs(b)^2+abs(a)^2)*Physics:-`^`(Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1)), 3)

(12)

'rhoBob(I/2*I/2*rho__Bob)-rho__Bob'=simplify(rhoBob(rho2)-rho__Bob);

rhoBob(Physics:-`*`(I, Physics:-`^`(2, -1), I, Physics:-`^`(2, -1), rho__Bob))-rho__Bob = 0

(13)

rho3:=rho__Alice*I/2:

'rhoAlice(rho__Alice*I/2)-rho__Alice'=simplify(rhoAlice(rho3)-rho__Alice);

rhoAlice(Physics:-`*`(rho__Alice, I, Physics:-`^`(2, -1)))-rho__Alice = 0

(14)

# A more general solution to compute the partual trace
Tr__partial:=proc(mask,rho)
    local n,j,ik,bk,me,ret,rho__sub, mask__sub;
    ik[0]:=Ket(q0); bk[0]:=Bra(q0);
    ik[1]:=Ket(q1); bk[1]:=Bra(q1);
    n:=nops(mask);
    ret:=0;
    if n > 1 then mask__sub:=[seq(mask[j],j=2..n)]; fi;
    
    for j from 0 to 1 do
        if n > 1 then
            rho__sub:=bk[j].rho.ik[j];
            me:=Tr__partial(mask__sub,rho__sub);
        else
            me:=bk[j].rho.ik[j];
        fi;
        if op(1,mask)=0 then
            # me:=ExpandQop(ik[j]*bk[j]*me);
            me:=(ik[j]*bk[j]*me);
        fi;
        ret:=ret+me;
    end do;
    return ret;
    end proc:

AliceBits:=[1,1,0];
BobBits  :=[0,0,1];

[1, 1, 0]

 

[0, 0, 1]

(15)

simplify(Tr__partial(AliceBits,rho));
'Tr__partial(AliceBits,rho)-rho__Bob'=%-rho__Bob;

(1/2)*(abs(b)^2+abs(a)^2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1)))

 

Tr__partial(AliceBits, rho)-rho__Bob = 0

(16)

simplify(ExpandQop(Tr__partial(BobBits,rho)));
'Tr__partial(BobBits,rho)-rho__Alice'=%-rho__Alice;

(1/4)*(abs(b)^2+abs(a)^2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q1))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1)))

 

Tr__partial(BobBits, rho)-rho__Alice = 0

(17)

AllBits:=[1,1,1];
'Tr(rho)'='Tr__partial(AllBits,rho)';
'Tr(rho)'=ExpandQop(Tr__partial(AllBits,rho));

[1, 1, 1]

 

Tr(rho) = Tr__partial(AllBits, rho)

 

Tr(rho) = abs(b)^2+abs(a)^2

(18)

NoBits:=[0,0,0];
'rho[diagonal]'=Tr__partial(NoBits,rho);

[0, 0, 0]

 

rho[diagonal] = Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0), Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0), (1/4)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))*abs(a)^2+(1/4)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))*abs(b)^2)+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1), (1/4)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))*abs(b)^2+(1/4)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))*abs(a)^2))+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1), Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0), (1/4)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))*abs(a)^2+(1/4)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))*abs(b)^2)+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1), (1/4)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))*abs(b)^2+(1/4)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))*abs(a)^2))

(19)

'rho[diagonal]'=simplify(ExpandQop(Tr__partial(NoBits,rho)));

rho[diagonal] = (1/4)*abs(a)^2*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q0), Physics:-Bra(q0))+(1/4)*abs(b)^2*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q0))+(1/4)*abs(b)^2*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Bra(q0))+(1/4)*abs(a)^2*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q0))+(1/4)*abs(a)^2*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q0), Physics:-Bra(q1))+(1/4)*abs(b)^2*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1))+(1/4)*abs(b)^2*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Bra(q1))+(1/4)*abs(a)^2*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q1))

(20)

 


 

Download QuantumTeleportationUsingDensityMatrixSecondPart.mw

 

 

 

I did have any time to work on that subject until this last weekend.

Here is and update version 5 of the procedure documentation.
1) I have many typos corrected
2) The text is in Maple document block mode


 

restart

with(Physics)
Physics:-Version()

interface(imaginaryunit = i)

Setup(mathematicalnotation = true)

 

(1)





-----------------------------------
File: ExpandQopV5-doc.mw
-----------------------------------





------------------------------------------------------------------------------------------------
NOTICE     
Author: Louis Lamarche   
Institute of Research of Hydro-Quebec (IREQ)  
Science des données et calcul haute performance   
2018, August 1

  
Function name: ExpandQop (x)  
           Purpose: Compute the tensor product of two quantum  
                          operators in Dirac notations
       Argument:
                      x: a quantum operator defined with non-commutative products
                          of Bras and Kets

      Description: This procedure is a hand-crafted parser for expanding
                           polynomials of non-commutative Kets Ket(a) and Bras Bra(a) 

            Version: 5  

©  Hydro-Quebec.
Note 1: Permission to use this software is granted if you
              acknowledge its author and copyright
Note 2: Permission to copy this software is granted if you  
             leave this notice intact. Thank you.
--------------------------------------------------------------------------------------------------

Theory:

Let H[1]^k be a Hilbert space of dimension k spanned by its associated orthonormal Ket vectors set  {Ket(a1),... "Ket(ak"} satisfying the relation Bracket(Bra(ai), Ket(aj)) = `&delta;__ij` describing a single particle, qubit or system. The projector operator on an arbitrary state of that system is defined as P__1 = Ket(ak)*Bra(ak), where  Ket(a__n)2 {Ket(a1), () .. Ket(ak)}. Suppose we now consider a system with two similar particles, qubits or systems. The projector on an arbitrary state of the second system becomes P__2 = Ket(ak)*Bra(ak), where  Ket(a__n)2 {Ket(a1), () .. Ket(ak)}. The states of the combines systems are described using a tensor product. A simple state of the resulting Hilbert space named Ket(a) is by consequence defined by the equality Ket(psi) = Ket(a__1)*Ket(a__2). An important convention to adopt is how to represent the bra vector of this Ket. The usual convention is to use Bra(a) = Bra(b)*Bra(c), so that the scalar, interior or dot product ("*")  of the bra with the Ket is given by" Bra(aKet(b)=Bra(a)&otimes; Bra(a)*Ket(b)&otimes; et(b)="  Bracket(Bra(a__1), Ket(a__1))*Bracket(Bra(a__2), Ket(a__2)). The procedure to compute this dot product requires a mental operation of counting and associating the left-hand side components before the dot ("*")  with their right-hand side counterparts. This  is useful for Hilbert spaces of small dimensions but may become tedious on a large Hilbert space. The convention proposed here (and already used by some researcher) is at the opposite Bra(a) = `&otimes;`(Bra(b), Bra(c)). The dot product then becomes. "Bracket(Bra(a),Ket(a))=Bracket(`.`(Bra(a),Bra(b)),`.`(Ket(a),Ket(b)"Bracket(Bra(a__1), Ket(a__1))*Bracket(Bra(a__2), Ket(a__2)). The rules are simple, the dot operator consumes the Kets from left to right and the Bras from right to left. Any tensor product operator 5 applied to a complex number returns that complex number.


Incidentally, MAPLE does this automatically if we specify that the Bras and Kets names begin with dedicated prefixes declared as non-commutative, with for instance the statement:

Setup(noncommutativeprefix = {a, b}) 

The Physics,* description says:

When computing with quantum-state vectors in Dirac notation, the Physics * operator also represents the tensor product of Bras and Kets , such as in  "|A>*<B|" (a quantum operator) or "|A>*|B>" (a Ket  of the tensor product of spaces).


Also the Physics,.  description says:

Scalar product between Bras, Kets, and quantum operators, and simplification of contracted indices in spacetime tensors
...
In the following situations, the scalar product can be performed:
...
A bracket rule , for example, for `<|>`(A, B) or `<|>`(A, H, B), where H represents a generic quantum operator, has been previously set by Setup , and so determines the result.

In the present application all quantum operators will be described in terms of Dirac notations. We will not use:

• 

argument 2..n of the Ket and Bra vectors procedures representing quantum numbers and defining implicitly orthonormal basis.

Bracket(Bra(a, m), Ket(a, n)) = `&delta;__m,n` 

• 

The implicit definition of the relation between quantum operators and their orthonormal basis

Setup(quantumoperators = {A})
A.Ket(A, n) = n.Ket(A, n)

NULL

Now noting that Ket(a__n) <> Ket(a, n), a__n =a__n being just a name in the left-hand side, while on the right-hand side we have a Ket with an implicit quantum number property.

Physics:-Ket(a__n) <> Physics:-Ket(a, n)

(2)

We can see that,

'Ket(a__1*a__2)' = Ket(a__1)*Ket(a__2);
'Bra(a__1*a__2)' = 'Dagger(Ket(a__1)*Ket(a__2))'; 
'Bra(a__1*a__2)' = Dagger(Ket(a__1)*Ket(a__2));
'Bracket(Bra(a__1*a__2),Ket(a__1*a__2))'='Dagger(Ket(a__1)*Ket(a__2)).(Ket(a__1)*Ket(a__2))';
'Bracket(Bra(a__1*a__2),Ket(a__1*a__2))'=Dagger(Ket(a__1)*Ket(a__2)).(Ket(a__1)*Ket(a__2));

Physics:-Bracket(Physics:-Bra(Physics:-`*`(a__1, a__2)), Physics:-Ket(Physics:-`*`(a__1, a__2))) = Physics:-Bracket(Physics:-Bra(a__1), Physics:-Ket(a__1))*Physics:-Bracket(Physics:-Bra(a__2), Physics:-Ket(a__2))

(3)

Setup(quantumoperators = {A, B, C})

Let A be an operator on the tensor product of 1..n of such Hilbert spaces (describing for instance n similar particles or qubits). A is operating in Hilbert space "`H__A`=H[1]^(k)&otimes;H[1]^(k)&otimes;...&otimes;H[1]^(k)" (n times) "= H[1]^(k^(&otimes;n))" naming an arbitrary orthonormal Ket vector of the n^th particle with the index n, Ket(a__n) where cn, Ket(a__n)2 {Ket(a1), () .. Ket(ak)}. We now consider a possible instance of A.

A = `&otimes;`(`&otimes;`(Ket(a__1), Ket(a__2)), Ket(a__3))*Ket(a__n)*Bra(a__n) .. `&otimes;`(Bra(a__3))*`&otimes;`(Bra(a__2), Bra(a__1)) 

Let H[2]^l be a second Hilbert space of dimension l spanned by its associated orthonormal Ket vectors set {Ket(a1),... Ket(ak)} satisfying the relation Bracket(Bra(ai), Ket(aj)) = `&delta;__ij`. Let B be an operator on the tensor product of 1..m of such Hilbert spaces (describing for instance m similar particles or qubits).  B is operating in Hilbert space "`H__B`=H[2]^(l)&otimes;H[2]^(l)&otimes;...&otimes;H[2]^(l)" (m times) "= H[2]^(l^(&otimes;m))" naming an arbitrary orthonormal Ket vector of the m^th particle with the index m, Ket(a__n) where cm, Ket(a__n)2 {Ket(a1), () .. Ket(ak)}. We now consider a possible instance of B.

B = `&otimes;`(`&otimes;`(Ket(a__1), Ket(a__2)), Ket(a__3))*Ket(a__n)*Bra(a__n) .. `&otimes;`(Bra(a__3))*`&otimes;`(Bra(a__2), Bra(a__1)) 

The tensor product C of these two operators acts on Hilbert space "`H__C`=`H__A`&otimes;`H__B`=" `&otimes;`(H[1]^(k^`&otimes;`(n)), H[2]^(l^`&otimes;`(m))) = H[3]^`&otimes;`(k^`&otimes;`(n), l^`&otimes;`(m)). The resulting Hilbert space size is consequently equal to k^n*l^m. The expression of the product using the convention given above is,

"Ket(a[`1`])&otimes; Ket(a[`2`])&otimes; Ket(a[`3`])&otimes;... Ket(a[n]) &otimes;Bra(a[n]) ...&otimes;Bra(a[`3`]) &otimes;Bra(a[`2`]) &otimes;Bra(a[`1`])" 

\___________________________  ___________________________/

"Ket(a[`1`]) Ket(a[`2`])&otimes; Ket(a[`3`]) &otimes;...Ket(a[n])&otimes; Bra(a[n]) ...&otimes;Bra(a[`3`]) &otimes;Bra(a[`2`])&otimes; Bra(a[`1`])" 

"C=A&otimes;B=" 

"Ket(a[`1`])&otimes; Ket(a[`2`]) Ket(a[`3`])&otimes;... Ket(a[n]) Ket(b[`1`]) &otimes;Ket(b[`2`])&otimes;Ket(b[`3`]) &otimes;...Ket(b[m]) &otimes;Bra(b[m])&otimes; Bra(b[`3`]) &otimes;Bra(b[`2`]) &otimes;Bra(b[`1`])&otimes; Bra(a[n])...&otimes; Bra(a[`3`]) Bra(a[`2`])&otimes; Bra(a[`1`])" 


 

Download ExpandQopV5-doc.mw

 

@ecterrab 

I tried today to implement a quantum teleportation using the hilbertspaces option of the
Physics package for Maple 2017 issued in March 2018. I was unable to implement a
2 qubit operator. It appears to be issues in commutator rules and inner product definition.


 

restart;

with(Physics); interface(imaginaryunit = I)

Physics:-Version();

"C:\Program Files\Maple 2017\lib\Physics2017.mla", `2018, March 17, 23:55 hours`

(1)

Setup(hilbertspaces = {A, B});
Setup(noncommutativeprefix={psi,v,q});

[disjointedspaces = {{A}, {B}}]

 

[noncommutativeprefix = {psi, q, v}]

(2)

# Setup(hideketlabel=true);

Setup(mathematicalnotation=true);
print("Inner or scalar products.");
print("The gereral product (*) operator is needed to make it work");
'Bra(A,1)*Ket(A,1)'=Bra(A,1)*Ket(A,1);
print("The inner product (.) operator is not defined");

 'Bra(A,1).Ket(A,1)'=Bra(A,1).Ket(A,1), "NOT OK";
'Bra(A,1)*Ket(A,0)'=Bra(A,1)*Ket(A,0);
'Bra(A,0)*Ket(A,1)'=Bra(A,0)*Ket(A,1);
'Bra(A,1)*Ket(A,1)'=Bra(A,1)*Ket(A,1);

'Bra(B,1)*Ket(B,1)'=Bra(B,1)*Ket(B,1);
'Bra(B,1)*Ket(B,0)'=Bra(B,1)*Ket(B,0);
'Bra(B,0)*Ket(B,1)'=Bra(B,0)*Ket(B,1);
'Bra(B,1)*Ket(B,1)'=Bra(B,1)*Ket(B,1);

print("Outer products defined using the (*) general product");
Ket(A,0)*Bra(A,0);
Ket(A,1)*Bra(A,0);
Ket(A,0)*Bra(A,1);
Ket(A,1)*Bra(A,1);

Ket(B,0)*Bra(B,0);
Ket(B,1)*Bra(B,0);
Ket(B,0)*Bra(B,1);
Ket(B,1)*Bra(B,1);

print("Needed working for mutiple qubit systems, OK");
'Ket(A,1)*Ket(B,1)-Ket(B,1)*Ket(A,1)'=Ket(A,1)*Ket(B,1)-Ket(B,1)*Ket(A,1);
'Ket(A,1)*Ket(B,1)-Ket(B,1)*Ket(A,1)'<>0, "OK IMHO";

'Ket(A,0)*Ket(B,1)-Ket(B,1)*Ket(A,0)'=Ket(A,0)*Ket(B,1)-Ket(B,1)*Ket(A,0), "NOT OK IMHO";

[mathematicalnotation = true]

 

"Inner or scalar products."

 

"The gereral product (*) operator is needed to make it work"

 

Physics:-`*`(Physics:-Bra(A, 1), Physics:-Ket(A, 1)) = 1

 

"The inner product (.) operator is not defined"

 

Physics:-`.`(Physics:-Bra(A, 1), Physics:-Ket(A, 1)) = Physics:-`*`(), "NOT OK"

 

Physics:-`*`(Physics:-Bra(A, 1), Physics:-Ket(A, 0)) = 0

 

Physics:-`*`(Physics:-Bra(A, 0), Physics:-Ket(A, 1)) = 0

 

Physics:-`*`(Physics:-Bra(A, 1), Physics:-Ket(A, 1)) = 1

 

Physics:-`*`(Physics:-Bra(B, 1), Physics:-Ket(B, 1)) = 1

 

Physics:-`*`(Physics:-Bra(B, 1), Physics:-Ket(B, 0)) = 0

 

Physics:-`*`(Physics:-Bra(B, 0), Physics:-Ket(B, 1)) = 0

 

Physics:-`*`(Physics:-Bra(B, 1), Physics:-Ket(B, 1)) = 1

 

"Outer products defined using the (*) general product"

 

Physics:-`*`(Physics:-Ket(A, 0), Physics:-Bra(A, 0))

 

Physics:-`*`(Physics:-Ket(A, 1), Physics:-Bra(A, 0))

 

Physics:-`*`(Physics:-Ket(A, 0), Physics:-Bra(A, 1))

 

Physics:-`*`(Physics:-Ket(A, 1), Physics:-Bra(A, 1))

 

Physics:-`*`(Physics:-Ket(B, 0), Physics:-Bra(B, 0))

 

Physics:-`*`(Physics:-Ket(B, 1), Physics:-Bra(B, 0))

 

Physics:-`*`(Physics:-Ket(B, 0), Physics:-Bra(B, 1))

 

Physics:-`*`(Physics:-Ket(B, 1), Physics:-Bra(B, 1))

 

"Needed working for mutiple qubit systems, OK"

 

Physics:-`*`(Physics:-Ket(A, 1), Physics:-Ket(B, 1))-Physics:-`*`(Physics:-Ket(B, 1), Physics:-Ket(A, 1)) = Physics:-`*`(Physics:-Ket(A, 1), Physics:-Ket(B, 1))-Physics:-`*`(Physics:-Ket(B, 1), Physics:-Ket(A, 1))

 

Physics:-`*`(Physics:-Ket(A, 1), Physics:-Ket(B, 1))-Physics:-`*`(Physics:-Ket(B, 1), Physics:-Ket(A, 1)) <> 0, "OK IMHO"

 

Physics:-`*`(Physics:-Ket(A, 0), Physics:-Ket(B, 1))-Physics:-`*`(Physics:-Ket(B, 1), Physics:-Ket(A, 0)) = 0, "NOT OK IMHO"

(3)

 


 

Download Disjointedspaces_test.mw


This new version will handle
OP8 := sqrt(2)*(Ket(q0)-Ket(q1))*(Bra(q0)-Bra(q1))*(1/(1+sqrt(2)))

= sqrt(2)*(Ket(q0)*Bra(q0)-Ket(q1)*Bra(q0)-Ket(q0)*Bra(q1)+Ket(q1)*Bra(q1))*(1/(1+sqrt(2)))
 

ExpandQop.mw

ExpandQopTests.mw

NOTE: this as not impact on the example but

There is a sign inversion in the  Y operator it  should read.

Y:=i*Ket(q1)*Bra(q0)-i*Ket(q0)*Bra(q1);    # = sigma[2] = sigma[y]

and not

Y:=-i*Ket(q1)*Bra(q0)+i*Ket(q0)*Bra(q1);


I have include here an upgrade of the ExpandQop procedure compatible with theMaple2018
Physics Library. It  is essentially a parser of non commutativre products of Bras and Kets
defined in the Physics package.

Quantum qubit circuits diagrams states where the qubits are viewed from top to bottom are
represented by tensor products of noncommutative  Ket(q0) and Ket(q1)  aligned from left to right.

Global operators on a set of qubits are represented by tensor product of operators. For instance
H * I * Cnot  is a four qubit operator and applies the Hadamard operator on the firts qubit, and
Identity to the second and a Cnot operation on the last two.

I will try to see if this can be made compatible with the work done by the
Physics of Information Lab of the University of Waterloo . It would be great if we could mix
qubits and harmonic oscillators.

The first file contains the procedure ExpandQop.mw
The second contains a test workshhep for the procedure ExpandQopTests.mw
The third contains an upgrade version of the quantum teleportation example. QuantumTeleportation.mw
 


I am having difficulties applying the option to get what is needed probably due
to a lack of understading of this disjointed spaces option.

The example you gave works fine but I did not obtained the good result
when trying to define a tensor product of two operator operating
on multiple qubits.

Thank you for your help.
LL
 

restart;

with(Physics); interface(imaginaryunit = I)

Physics:-Version();

"C:\Program Files\Maple 2017\lib\Physics2017.mla", `2018, March 17, 23:55 hours`

(1)

Setup(quantumoperators={A,B,C,E,F,G});

[quantumoperators = {A, B, C, E, F, G}]

(2)

Setup(hilbertspaces = {a__1, a__2, a__3, a__4, a__5, b__1, b__2, b__3, q__0, q__1})

[disjointedspaces = {{a__1}, {a__2}, {a__3}, {a__4}, {a__5}, {b__1}, {b__2}, {b__3}, {q__0}, {q__1}}]

(3)

Setup(mathematicalnotation=true);

[mathematicalnotation = true]

(4)

kets1 := Ket(a__1)*Ket(a__2)*Ket(a__3)*Ket(a__4)*Ket(a__5)

Physics:-`*`(Physics:-Ket(a__1), Physics:-Ket(a__2), Physics:-Ket(a__3), Physics:-Ket(a__4), Physics:-Ket(a__5))

(5)

A := kets1*Dagger(kets1)

Physics:-`*`(Physics:-Ket(a__1), Physics:-Ket(a__2), Physics:-Ket(a__3), Physics:-Ket(a__4), Physics:-Ket(a__5), Physics:-Bra(a__5), Physics:-Bra(a__4), Physics:-Bra(a__3), Physics:-Bra(a__2), Physics:-Bra(a__1))

(6)

kets2 := Ket(b__1)*Ket(b__2)*Ket(b__3)

Physics:-`*`(Physics:-Ket(b__1), Physics:-Ket(b__2), Physics:-Ket(b__3))

(7)

B := kets2*Dagger(kets2)

Physics:-`*`(Physics:-Ket(b__1), Physics:-Ket(b__2), Physics:-Ket(b__3), Physics:-Bra(b__3), Physics:-Bra(b__2), Physics:-Bra(b__1))

(8)

C := A*B

Physics:-`*`(Physics:-Ket(a__1), Physics:-Ket(a__2), Physics:-Ket(a__3), Physics:-Ket(a__4), Physics:-Ket(a__5), Physics:-Ket(b__1), Physics:-Ket(b__2), Physics:-Ket(b__3), Physics:-Bra(b__3), Physics:-Bra(b__2), Physics:-Bra(b__1), Physics:-Bra(a__5), Physics:-Bra(a__4), Physics:-Bra(a__3), Physics:-Bra(a__2), Physics:-Bra(a__1))

(9)

kets3 := Ket(q__1)*Ket(q__0)*Ket(q__1)*Ket(q__0)*Ket(q__1);
kets4 := Ket(q__0)*Ket(q__0)*Ket(q__1)*Ket(q__1)*Ket(q__1);
E:=kets3*Dagger(kets3);
F:=kets4*Dagger(kets4);
G := E*F;

Physics:-`*`(Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__0), Physics:-Ket(q__0))

 

Physics:-`*`(Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__0), Physics:-Ket(q__0))

 

Physics:-`*`(Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__0), Physics:-Ket(q__0), Physics:-Bra(q__0), Physics:-Bra(q__0), Physics:-Bra(q__1), Physics:-Bra(q__1), Physics:-Bra(q__1))

 

Physics:-`*`(Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__0), Physics:-Ket(q__0), Physics:-Bra(q__0), Physics:-Bra(q__0), Physics:-Bra(q__1), Physics:-Bra(q__1), Physics:-Bra(q__1))

 

Physics:-Bracket(Physics:-Bra(q__1), Physics:-Ket(q__1))^3*Physics:-Bracket(Physics:-Bra(q__0), Physics:-Ket(q__0))^2*Physics:-`*`(Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__0), Physics:-Ket(q__0), Physics:-Bra(q__0), Physics:-Bra(q__0), Physics:-Bra(q__1), Physics:-Bra(q__1), Physics:-Bra(q__1))

(10)

 

####################################################################################
# Load the procedure and set the required global variables
# Using version 3
read "ExpandQop.m": optp:=op(0,Ket(q0)*Ket(q1)): optpx:= op(0,(Ket(q0)+Ket(q1))^2):
#
####################################################################################

print("Using ExpandQop on G gives the same result.");
print("This is related to the presence of indexes in the names.");
ExpandQop(G);

"Using ExpandQop on G gives the same result."

 

"This is related to the presence of indexes in the names."

 

Physics:-Bracket(Physics:-Bra(q__1), Physics:-Ket(q__1))^3*Physics:-Bracket(Physics:-Bra(q__0), Physics:-Ket(q__0))^2*Physics:-`*`(Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__1), Physics:-Ket(q__0), Physics:-Ket(q__0), Physics:-Bra(q__0), Physics:-Bra(q__0), Physics:-Bra(q__1), Physics:-Bra(q__1), Physics:-Bra(q__1))

(11)

print("Defining the operators in a other way works better");
kets3 := Ket(q,1)*Ket(q,0)*Ket(q,1)*Ket(q,0)*Ket(q,1);
kets4 := Ket(q,0)*Ket(q,0)*Ket(q,1)*Ket(q,1)*Ket(q,1);
E:=kets3*Dagger(kets3);
F:=kets4*Dagger(kets4);
G := E*F;
print("But the expandQop is needed for the solution");
'ExpandQop(G)'=ExpandQop(G);

"Defining the operators in a other way works better"

 

Physics:-`*`(Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1))

 

Physics:-`*`(Physics:-Ket(q, 0), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Ket(q, 1))

 

Physics:-`*`(Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 1))

 

Physics:-`*`(Physics:-Ket(q, 0), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 0))

 

Physics:-`*`(Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 0))

 

"But the expandQop is needed for the solution"

 

ExpandQop(G) = Physics:-`*`(Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 0), Physics:-Ket(q, 0), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Ket(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 0), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 1), Physics:-Bra(q, 0), Physics:-Bra(q, 1))

(12)

print("Now trying something else");
kets3 := Ket(q,1,0,1,0,1);
kets4 := Ket(q,0,0,1,1,1);
E:=kets3*Dagger(kets3);
F:=kets4*Dagger(kets4);
G:=E*F;

"Now trying something else"

 

Physics:-Ket(q, 1, 0, 1, 0, 1)

 

Physics:-Ket(q, 0, 0, 1, 1, 1)

 

Physics:-`*`(Physics:-Ket(q, 1, 0, 1, 0, 1), Physics:-Bra(q, 1, 0, 1, 0, 1))

 

Physics:-`*`(Physics:-Ket(q, 0, 0, 1, 1, 1), Physics:-Bra(q, 0, 0, 1, 1, 1))

 

Physics:-`*`(Physics:-Ket(q, 1, 0, 1, 0, 1), Physics:-Bra(q, 1, 0, 1, 0, 1), Physics:-Ket(q, 0, 0, 1, 1, 1), Physics:-Bra(q, 0, 0, 1, 1, 1))

(13)

print("This is what is needed");
Setup(noncommutativeprefix={q});
kets3 := Ket(q1)*Ket(q0)*Ket(q1)*Ket(q0)*Ket(q1);
kets4 := Ket(q0)*Ket(q0)*Ket(q1)*Ket(q1)*Ket(q1);
E:=kets3*Dagger(kets3);
F:=kets4*Dagger(kets4);
Gok := E*F;
Gok:=ExpandQop(Gok);

"This is what is needed"

 

[noncommutativeprefix = {q}]

 

Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1))

 

Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1))

 

Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1))

 

Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q0))

 

Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q0))

 

Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1), Physics:-Bra(q0), Physics:-Bra(q1))

(14)

 


 

Download Disjointedspaces.mw

@ecterrab 
It is necessary to use the
   Setup(noncommutativeprefix={a,b,c});

 Physics("*")  operator now glues the bras and the kets in a non commutative way
that for instance Ket(a2)*Ket(a1) <> Ket(a1)*Ket(a1) . It appear that Maple will not reorder
the elements of these expressions. I used indexes the bras and kets but these are justs
names in the worksheet.
 

Implicitely  the non commutative  kets separated by the * operator belongs to different Hilbert
spaces. Each element of the product representing a different particule, qubit, position, momentum,
etc. state

 I suggest that the ExpandQop solves the problem of computing the tensor product of
two operators defined with properly ordered non commutative kets and bras. 

Now I will try to do it with the new Physics package.

Louis Lamarche
IREQ

 

@ecterrab 

The purpose of my post was to share my work and I thank you for your reply.

Point 1 - I  agree, this is my error. The Hilbert space size in m x n. I will correct that.

Point 2- The product of kets of one single Hilbert space do not form a tensor product.
              a) The Physics ("*")  definition plus the
                   Setup(noncommutativeprefix={a,b,c}) rule
                   enables to form new states in the tensor product of the Hilbert spaces.
              b)  Operators apprears when we have Bras and Kets back to back.

Point 3- I will very interrested in using and tresting this new library update. For the moment the 
             Setup(hilberspaces=...) is nor defined in my version.

Thank you again.

LL

 

 

 

Not using quantum numbers for the state vectors solve the issue.

It appears the the sent program was not included in the post.


This computer the tensor product an arbitrairy Vet vector with 
the Bell State B00. The simplified expression is wrong.

1 2 Page 1 of 2