0
$\begingroup$

Using this answer

Clear[x, y];
$Assumptions = (x | y) \[Element] Vectors[2];

tensorExpand[expr_] := 
 Simplify[TensorExpand[expr] /. 
     Thread[{x, y} -> IdentityMatrix[2]]] /. 
   l_List :> SparseArray[l] /. s_SparseArray :> toSymbols[ArrayRules@s]

toSymbols[ruleList_] := 
 Total[ruleList /. 
   HoldPattern[Rule[a_, b_]] :> 
    Times[Apply[TensorProduct, a /. Thread[{1, 2} -> {x, y}]], b]]

I want to do something like (it don't even run):

Inner[Dot, a TensorProduct[x, x] + c TensorProduct[y, x], 
b TensorProduct[x, y], Plus]

to get zero as result and

Inner[Dot, a TensorProduct[x, x] + c TensorProduct[y, x], 
b TensorProduct[x, x], Plus]

a b for this case, just like if I was working with Dirac's notation: $$ (a\vert + + \rangle + c \vert -+\rangle,b\vert + +\rangle) = ab $$ where $(\,,\,)$ is the dot product.

I think that Inner is inadequate for this task, but is the only approach that I have.

Edit: I'm trying this because I'm using 20 qubits and using something like KroneckerProduct isn't suitable for my case.

$\endgroup$
  • 1
    $\begingroup$ library.wolfram.com/infocenter/MathSource/7622 $\endgroup$ – egwene sedai Jan 25 '16 at 11:26
  • $\begingroup$ Do you need the tensor properties, or do you just want to manipulate expressions containing the kets, and perform inner products? $\endgroup$ – Marius Ladegård Meyer Jan 25 '16 at 11:41
  • $\begingroup$ I am assuming you want to manipulate these expressions symbolically. Unfortunately, symbolic tensors aren't well integrated with the rest of Mathematica (so far, anyway). In particular, functions like Simplify, Dot, or Inner don't really do anything too useful with them. You would have to use TensorContract in place of Dot or Inner, and TensorReduce in place of Simplify, which can be awkward. $\endgroup$ – Oleksandr R. Jan 25 '16 at 12:12
  • 1
    $\begingroup$ Well, 20 qubits is really "nothing". You just need to represent your basis states as sparse vectors. Then you can do even much more. Kronecker product works well will sparse tensors (see the documentation.) $\endgroup$ – Michael Weyrauch Jan 25 '16 at 17:52
3
$\begingroup$

As suggested already in the comments it is easier to work in a concrete basis e.g. as follows:

x = {1, 0} ; y = {0, 1}; bv[a_, b_] := Flatten[KroneckerProduct[a, b]];

Then you can calculate your particular examples easily:

(a*bv[x, x] + c bv[y, x]).(b bv[x, y])
(* 0 *)
(a*bv[x, x] + c bv[x, y]).(b bv[x, x])
(* a*b *)

Using the symbolic tensors in Mathematica is somewhat awkward to my opinion.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.