13
$\begingroup$

How to draw quantum circuit as the following one with mathematica? enter image description here I only find the quantum package which is designed for MMA 7.0 as the author said. But the version of my Mathematica is 9.0 and when I try that package there is an error as following enter image description here

How to get over this problem? Is there any other method or package to draw quantum circuit?

Ps: the mathematica file including the above error

$\endgroup$
7
  • $\begingroup$ Please provide the input expression (cell expression) that does not work. $\endgroup$
    – Mr.Wizard
    Sep 13, 2014 at 2:45
  • $\begingroup$ @Mr.Wizard Thanks! I update the question. If you cannot download it, please let me know. $\endgroup$ Sep 13, 2014 at 5:08
  • $\begingroup$ I guess you copied the expression from the notebook. If you type the expression using error using the palettes in the quantum package, then the error is gone. $\endgroup$ Sep 13, 2014 at 7:33
  • 2
    $\begingroup$ see this $\endgroup$ Sep 13, 2014 at 7:40
  • $\begingroup$ @xslittlegrass Great observation! It still doesn't explain why the old expression works in v7 yet is broken in v10. $\endgroup$
    – Mr.Wizard
    Sep 13, 2014 at 7:46

1 Answer 1

5
+50
$\begingroup$

I have not yet figured out why different definitions for MakeBoxes occur, but it seems that adding this definition in version 10 allows your specific example to parse and evaluate as desired:

Needs["Quantum`Computing`"]
Needs["Quantum`Notation`"]
SetComputingAliases[];

MakeExpression[
  TagBox[SuperscriptBox[
    RowBox[{"(", 
      TagBox[Quantum`Computing`Private`a_, zz020TPdat, 
       Quantum`Computing`Private`opts1___], ")"}], 
    RowBox[{AdjustmentBox["\[CircleTimes]", BoxBaselineShift -> -(3/4)], 
      TagBox[Quantum`Computing`Private`n_, zz020TPend, 
       Quantum`Computing`Private`opts2___]}]], zz020TP, 
   Quantum`Computing`Private`opts0___], Quantum`Computing`Private`form_] := 
 MakeExpression[
  RowBox[{"zz020TensorPower", "[", Quantum`Computing`Private`a, ",", 
    Quantum`Computing`Private`n, "]"}], Quantum`Computing`Private`form]

If you confirm that this solves your problem for the specific example I shall try to figure out why this definition is missing or different when the package is loaded in version 10. (I copied this from version 7, after loading the package.)

$\endgroup$
3
  • $\begingroup$ Yeah! It solves the problems. Thanks so much! $\endgroup$ Sep 13, 2014 at 8:11
  • $\begingroup$ Will you try to figure out why? $\endgroup$ Sep 15, 2014 at 0:47
  • $\begingroup$ @Eden I did spend some time on it and I couldn't figure out why. I don't want to have to read the entire package code to track it down. I think this is the only definition (for MakeExpression) that is missing in v10. Would you please try using it for a while and see if other problems appear? $\endgroup$
    – Mr.Wizard
    Sep 15, 2014 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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