1
$\begingroup$

I've been trying to define the kets $|+\rangle$ and $|-\rangle$ with no sucess with

<< Notation`
Symbolize[ParsedBoxWrapper[Subscript["_", "_"]]]
Subscript[Ket[+], Q] := {1/Sqrt[2], 1/Sqrt[2]}

I believe that the error probably occurs because Mathematica tries to interpret the symbol + as an operation, as expected. Is there any workaround to this? P.S: I just added the Q in the subscript for aesthetic reasons, to regard it as a qubit-state

$\endgroup$

2 Answers 2

1
$\begingroup$

You can specify plus as a string instead, like this:

<< Notation`
Symbolize[ParsedBoxWrapper[Subscript["_", "_"]]]
Subscript[Ket["+"], Q] := {1/Sqrt[2], 1/Sqrt[2]}

Subscript[Ket["+"], Q]
(* {1/Sqrt[2], 1/Sqrt[2]} *)
$\endgroup$
0
$\begingroup$

I found out. This can be solved quite simply if we use the notation package to define

enter image description here

instead of Symbolize. By doing this we can use the plus sign as a symbol inside the ket.

enter image description here

$\endgroup$

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.