3
$\begingroup$

Bug introduced in 14.0, fixed in 14.1.


The Wolfram documentation says that Ket[{k}] is displayed as $$ \vert k \rangle $$

However, I am following the discussion from this thread https://www.reddit.com/r/Mathematica/comments/9wnxu7/bosonic_fock_states/ which gives some code:

qOperatorQ[expr_] := 
  MatchQ[expr, 
   qCO[_Integer] | qDO[_Integer] | Ket[{__Integer}] | 
    Times[scalar_?NumericQ, _?qOperatorQ] | 
    Plus[op_?qOperatorQ, _?qOperatorQ] | 
    CenterDot[op_?qOperatorQ, _?qOperatorQ]];

(*implement action on Fock states*)
CenterDot[left___, qCO[k_Integer], Ket[{n__Integer}]] := Module[
   {l = Max[Length[{n}], k], nn},
   nn = PadRight[{n}, l];
   Times[Sqrt[nn[[k]] + 1], 
    CenterDot[left, Ket[nn + UnitVector[l, k]]]] ];

(*effective OneIdentity attribute*)
CenterDot[op_?qOperatorQ] := op;

With these definitions, we can compute $$ a_1^\dagger\vert 0 0 \rangle $$ by evaluating

qCO[1]\[CenterDot]Ket[{0, 0}]

My expectation is that this would output as

$$|1,0\rangle$$

Instead, I get output that appears to be in input form:

Ket[{1,0}]

(re)Evaluating this output or manually changing the format of the output cell produces the desired form. Is there some reason that the provided code does not print the output in the expected format?

This issue arises in my installation of Mathematica 14.0.0.0.

$\endgroup$
4
  • $\begingroup$ A workaround is to force evaluation of Ket[] in the last step by replacing the OneIdentity attribute statement with CenterDot[op_?qOperatorQ]:=(op +1) -1; which does not modify the value of the output. $\endgroup$
    – Joalito
    Commented Oct 24 at 14:20
  • $\begingroup$ I can't reproduce the issue mentioned in the title, Ket[{0}] displays as expected in a notebook, nor can I reproduce the issue mentioned here: i.sstatic.net/Aeu4S78J.png Also, you mention DisplayForm several times but your code doesn't call DisplayForm so that is a bit confusing. $\endgroup$
    – Jason B.
    Commented Oct 24 at 14:44
  • $\begingroup$ When I run the code in Mathematica 13.2.1.0 the output is fine. The issue arises in 14.0.0.0. $\endgroup$
    – Joalito
    Commented Oct 24 at 15:01
  • 2
    $\begingroup$ Indeed, this seems to be an issue in version 14.0, which has been fixed in version 14.1 ... $\endgroup$
    – Domen
    Commented Oct 24 at 15:13

1 Answer 1

2
$\begingroup$

In the comments, Domen confirmed the issue is fixed in Mathematica version 14.1.

$\endgroup$

Your Answer

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

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