# VVC Extension Scheme for Object Detection Using Contrast Reduction

Takahiro Shindo, Taiju Watanabe, Kein Yamada and Hiroshi Watanabe  Graduate
School of Fundamental Science and Engineering, Waseda University,
Tokyo, Japan

###### Abstract

In recent years, video analysis using Artificial Intelligence (AI) has been
widely used, due to the remarkable development of image recognition technology
using deep learning. In 2019, the Moving Picture Experts Group (MPEG) has
started standardization of Video Coding for Machines (VCM) as a video coding
technology for image recognition. In the framework of VCM, both higher image
recognition accuracy and video compression performance are required. In this
paper, we propose an extention scheme of video coding for object detection
using Versatile Video Coding (VVC). Unlike video for human vision, video used
for object detection does not require a large image size or high contrast.
Since downsampling of the image can reduce the amount of information to be
transmitted. Due to the decrease in image contrast, entropy of the image
becomes smaller. Therefore, in our proposed scheme, the original image is
reduced in size and contrast, then coded with VVC encoder to achieve high
compression performance. Then, the output image from the VVC decoder is
restored to its original image size using the bicubic method. Experimental
results show that the proposed video coding scheme achieves better coding
performance than regular VVC in terms of object detection accuracy.

###### Keywords:

video coding, VVC, object detection, VCM

##  I Introduction

With the spread of video analysis using AI, video compression methods are
essential for these purposes. The amount of video information required for
image recognition is considered to be less than that of video for human vision
[1]. Therefore, coding schemes for image recognition that exceed the coding
performance of VVC [2] are being considered. In 2019, MPEG has positioned
video coding for image recognition as VCM and started standardization. In its
standardization activities, most of the proposed coding schemes use VVC,
aiming to improve coding performance by combining VVC with video pre-
processing and post-processing. In video pre-processing, some methods have
been proposed to reduce the amount of information in videos. For example,
there are pre-processing methods that convert the image size, reduce the
number of frames, and use Region of Interest. Post-processing of video
includes methods such as restoring image size and converting to frames that
are useful for image recognition.

However, coding scheme using image contrast reduction have not been
considered, even though a lower bitrate can be achieved. Therefore, this paper
investigates the effect of reducing the image contrast on object detection
accuracy. For the object detection model, YOLO-v7 [4] is used, which has both
high object detection accuracy and fast object detection speed. Experimental
results show that VVC extention scheme using contrast reduction reduces the
bitrate required for video transmission and improves coding performance in
object detection accuracy.

##  II Related Works

VVC is the latest video coding technology standardized in July 2020. This
video coding method was created to encode video for human vision. However, due
to its high coding performance, it has also attracted attention in VCM
standardization activities. In fact, most of the proposed video coding methods
in the standardization activities partially use VVC to achieve high coding
performance.

VVC reduces the amount of video information by performing intra-frame and
inter-frame predictions. According to these prediction results, only the
prediction error need to be transmitted. After these errors are block
segmented and converted into frequency components, the information mainly in
the high-frequency components is removed. This is because the reduction of
high-frequency components does not have a significant impact on image quality.
The resulting video information from these processes is compressed to a
minimal amount by entropy coding for transmission.

##  III Proposed Method

We propose a method to lower the amount of bits required for video
transmission by reducing the contrast of the image. Videos for object
detection models need not be as vividly colored as videos for human vision. By
lowering the contrast of video frames, the entropy of them can be suppressed.
In other words, the bitrate required for video transmission can be reduced.
Furthermore, to decrease the amount of information in the video, the image
size is halved, and the image size is restored after the video is transmitted.
This image resizing method is described in the document published by MPEG [5],
and is utilized to create anchors of VCM. The bicubic method is used as the
image resizing method, and VVC is used as the video coding method. The
proposed video processing method is shown in Fig. 1-(a), and the algorithm
used for the contrast reduction process is described below.

Figure 1: Processing flow of videos. (a) proposed coding scheme using contrast
reduction; (b) coding scheme for comparison.

$I^{\prime}(x,y)=(1-\alpha){*}I(x,y)+\frac{\alpha}{3{*}X{*}Y}\sum_{x=1}^{X}\\!\sum_{y=1}^{Y}I(x,y),$
(1)

where $I(x,y)$ and $I^{\prime}(x,y)$ indicate the input and output image. $X$
and $Y$ are the width and height of the image. $\alpha$ represents the ratio
of the number of tones to be reduced.

##  IV Experiment

###  IV-A Evaluation method

To measure coding performance in object detection accuracy, we use the SFU-
HW-v1 [6] dataset. This dataset consists of raw videos and the corresponding
annotations for object detection, and is designated as Common Test Condition
[5] in VCM standardization activities. The dataset contains 18 raw videos,
which are classified into classes A to E according to its image size and
characteristics. In this experiment, a total of 8 sequences from classes B and
C are used.

We reduce the contrast of these videos using Eq. 1. In this experiment, the
value of $\alpha$ is set to 0.25. To demonstrate the effectiveness of the
proposed video coding scheme, we compare its performance with that of regular
VVC. The processing of comparison method is shown in Fig. 1-(b). In order to
accurately compare the encoding performance, the image size is changed as
referred to in the proposed method.

VTM17.2 [7] is used as the video coding method and “lowdelay_P” is used as the
frame reference structure. The quantization parameters in the proposed coding
method are 14 integers from 32 to 45. In the coding method for comparison, the
parameters are 13 integers from 35 to 47. VVC coded video is input to YOLO-v7
to perform object detection. The confidence threshold of the detection model
is set to 0.25. Average Precision (AP) is used for detection accuracy, and IoU
threshold is always set to 0.5 when calculating AP.

###  IV-B Results

The relationship between bitrate and mAP is shown in Fig. 2, and the
relationship between bitrate and AP, which represents the detection accuracy
of “person”, is shown in Fig. 3. In both figures, the blue curve represents
the coding performance of the proposed method and the red curve represents
that of the comparison method. By reducing the contrast of the image, it is
possible to encode the image with smaller quantization parameters. This leads
to decoding images with less contrast but less block noise, which improves the
coding performance in terms of object detection accuracy.

Figure 2: The relationship between bitrate and mAP. Figure 3: The relationship
between bitrate and AP (person).

##  V Conclusion

In this paper, we proposed a coding scheme to reduce bitrate without lowering
object detection accuracy by reducing image contrast before transmitting the
video. Experimental results showed that the proposed method outperforms a
general VVC in terms of coding performance of object detection accuracy. For
future research, it is necessary to measure the coding performance in terms of
object detection accuracy when object detection models are trained using low
contrast images.

## Acknowledgment

These research results were obtained from the commissioned research (No.05101)
by National Institute of Information and Communications Technology (NICT),
Japan.

## References

  * [1] H. Choi et al., “Scalable Image Coding for Humans and Machines,” IEEE Transaction on Image Processing, vol. 31, 2022, pp. 2739-2754.
  * [2] Versatile Video Coding, Standard ISO/IEC 23090-3, ISO/IEC JTC 1, Jul. 2020.
  * [3] ISO/IEC JTC1/SC29/WG2, “CfP response report for Video Coding for Machine,” N248, Oct. 2022.
  * [4] Chien-Yao Wang et al., “YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for realtime object detectors,” arXiv preprint arXiv:2207.02696, 2022.
  * [5] ISO/IEC JTC1/SC29/WG04, “Common test conditions for video coding for machines,” N278, Nov. 2022.
  * [6] H. Choi et al., “A dataset of labelled objects on raw video sequences,” Data in Brief, 34:106701, 2021.
  * [7] VTM software repository, version VTM-17.2. Available online: https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM.


# Dynamics-based quantumness certification of continuous variables using time-
independent Hamiltonians with one degree of freedom

Lin Htoo Zaw  Centre for Quantum Technologies, National University of
Singapore, 3 Science Drive 2, Singapore 117543  Valerio Scarani  Centre for
Quantum Technologies, National University of Singapore, 3 Science Drive 2,
Singapore 117543  Department of Physics, National University of Singapore, 2
Science Drive 3, Singapore 117542

###### Abstract

Dynamics-based certification of quantumness is an approach to witnessing the
nonclassical character of some continuous-variable states, under the
assumption that their dynamics is known. Contrary to other tests of
nonclassicality for single systems, it does not require sequential
measurements. This family of protocols was introduced for harmonic dynamics.
In this work, we discuss dynamics-based certification for one degree of
freedom evolving under a generic time-independent Hamiltonian. We characterize
the conditions under which such a certification is possible. Several examples
are explicitly studied: some that are approximately harmonic in the limits of
low energy (Kerr nonlinearities, the pendulum, and the Morse potential) and
one that is not (the particle in an infinite well).

##  I Introduction

The demonstration of quantum effects with large objects is a current frontier
of research. Demonstrations of typical wave effects like interference are
compelling, but are not the only options: Nonclassical features within the
mechanical framework are certainly more suited for trapped systems. The most
famous nonclassical features appear as negatives compared to classical theory:
For instance, a material point’s position and momentum cannot be localized
beyond the limits of Heisenberg’s uncertainty. The detection of such negative
features relies on calibration: Only by measuring at a precision dictated by
Planck’s constant can one claim that the remaining fluctuations are
unavoidable (and the claim would not be accepted by die-hard classical
physicists, assuming there are still some of those).

In this paper, we propose a family of positive criteria of nonclassicality,
i.e. observations that are impossible to obtain with any classical state. Our
criteria are dynamics-based (they assume that the time evolution of the system
is known) and state-dependent (only certain states, usually with suitable
negativity in their Wigner function, can be detected). Contrary to tests based
on contextuality arguments or the Leggett-Garg approach, our tests do not
depend on sequential or simultaneous measurements, instead requiring only one
measurement on each system for every round of the test.

Given a Hamiltonian of the form $H(x,p)={p^{2}}/{2m}+V(x)$, Ehrenfest’s
theorem proves that the Heisenberg equations of motion are the same as
Hamilton’s equations, with the canonical variables replaced by the
corresponding pair of quantum observables that satisfy the canonical
commutation relations. The solutions for position and momentum as a function
of time have the same expressions for classical variables and quantum
observables. Remarkably, the first examples of dynamics-based nonclassicality
criteria were built on such ostensibly classical dynamics. An early example is
the probability backflow of a free particle whose momentum is always found to
be positive [1], which was recently extended in the context of the
demonstration of quantum advantage in mechanical tasks [2]. By these criteria,
nonclassical behavior is found by measuring the position of the system after
waiting for a set duration. Similar signatures of quantumness can be found in
the time evolution of the harmonic oscillator, which is a simple precession in
phase space in both the classical and quantum cases. Tsirelson introduced a
nonclassicality test that involves measuring the coordinate of the system once
per round, at a randomly chosen time each round [3]. Extending this idea, a
family of protocols was recently introduced for detecting the nonclassicality
of a single quantum system under the sole assumption that its dynamics is a
uniform precession [4]. When applied to a normal mode of coupled oscillators,
this criterion becomes an entanglement witness [5].

These dynamics-based tests of nonclassicality utilize coarse-grained
measurements of continuous variables like $\operatorname{sgn}(x)$. Such
dichotomic measurements have also been used for nonlocality tests for two
continuous-variable systems [6, 7, 8] and for single-system nonclassicality
tests which are based on some other assumptions rather than the dynamics [9,
10, 11, 12].

Figure 1: For the harmonic oscillator, in classical theory, any pure state
$(x(t=0),p(t=0))$ initially in the orange region achieves the score of
$P_{3}^{c}=\frac{2}{3}$, while any pure state initially in the blue region
achieves the score of $P_{3}^{c}=\frac{1}{3}$. Some example trajectories are
shown for different probing duration $\mathbf{T}$, with the closed points
marking its state at $t=0$ and the open points marking its states at
$t=\mathbf{T}/3$ and $2\mathbf{T}/3$. Consider first (a), with
$\mathbf{T}=T_{0}$. A state initially in the top-right orange region will
evolve to the bottom-right orange region at $t=\mathbf{T}/3$ and then the
leftmost orange region at $t=2\mathbf{T}/3$. Therefore, that state will
achieve the score $P_{3}^{c}=\frac{2}{3}$. Repeating the same argument for
every other state initially in any of the orange regions would lead us to
conclude that any state initially in any of the orange regions will have
$P_{3}^{c}=\frac{2}{3}$. Similarly, a state initially in the bottom-left blue
region will evolve to the top-left blue region at $t=\mathbf{T}/3$ and
rightmost blue region at $t=2\mathbf{T}/3$. The same argument for every other
state initially in any of the blue regions will have $P_{3}^{c}=\frac{1}{3}$.
Analogous arguments hold for different probing duration $\mathbf{T}$, with
decreasing $\mathbf{T}$ from left to right with (b)
$3T_{0}/4<\mathbf{T}<T_{0}$ and (c) $\mathbf{T}=3T_{0}/4$, and increasing
$\mathbf{T}$ from left to right with (d) $T_{0}<\mathbf{T}<3T_{0}/2$ and (e)
$\mathbf{T}=3T_{0}/2$. Other intermediate cases for
$3T_{0}/4<\mathbf{T}<T_{0}$ and $T_{0}<\mathbf{T}<3T_{0}/2$ are similar to (b)
and (d), respectively.

In the original criterion and its extension [3, 4], the primary assumption was
that the time evolution of the system is a uniform precession. The
contribution of this paper is to extend dynamics-based nonclassicality
criteria to a conserved (i.e., time-independent) Hamiltonian of one continuous
degree of freedom. A quantum-classical gap is not always present: For our
criterion to certify nonclassicality, the dynamics should lead to some form of
trapping (precise conditions in Sec. III). While in most examples, and
probably in all tabletop implementations, trapping potentials are
approximately harmonic at low energy, this will not be a requirement for our
protocol to detect nonclassicality.

After presenting the general approach, we apply it to several examples, which
go beyond the original harmonic case with nontrivial variations. The first is
the Kerr anharmonic Hamiltonian (Sec. IV.1), which contains quartic terms and
describes several real quantum devices with nonlinearities. Second, we study
the pendulum (Sec. IV.2), which is a Hamiltonian in angular, rather than
linear, coordinates. Third, we introduce the Morse potential, a potential that
is asymmetric and not fully trapping, i.e., has open orbits at high energy
(Sec. IV.3). Finally, we study the infinite potential well (Sec. IV.4), which
is not harmonic even in the limit of small energy; this shows that our
protocol is not based on approximate harmonicity.

For each of these examples, we find the range of parameters for which
nonclassicality can be detected with this protocol. For the approximately
harmonic potentials, we also compare the complete dynamics against the
harmonic approximation in the low-energy regime. Rather than order-of-
magnitude approximations, we are able to give exact values of anharmonicities
where the nonclassicality criterion stops working. Furthermore, we also show
that a simple adjustment in the probing time permits a violation even at
larger anharmonicities.

Before discussing the new potentials, we revisit the study of the harmonic
oscillator in Sec. II, introducing the original protocol and some variations
on it.

##  II Revisiting the protocol for the harmonic oscillator

To better understand the formulation of the general criterion, it is useful to
revisit the known and simple case of the harmonic oscillator
$H(x,p)=p^{2}/{2m}+m\omega_{0}^{2}x^{2}/{2}$. It is well known that the
dynamics is such that $(x(t),p(t))$ undergoes a uniform precession in phase
space with the period $T_{0}=2\pi/\omega_{0}$. In particular,
$x(t)=x(0)\cos\omega_{0}t+[p(0)/m\omega_{0}]\sin\omega_{0}t$.

###  II.1 Overview of the original protocol [3, 4]

The original protocol consists of many independent rounds. The following steps
take place in in each round.

(1) One system is prepared in some state. For the validity of the
certification, one does not need to assume that the state is the same in every
round (of course, poor preparation will lead to a negative outcome of the
certification).

(2) After the preparation is completed, the system is decoupled from
everything else and undergoes the closed dynamics of a harmonic oscillator,
resulting in a uniform precession with period $T_{0}=2\pi/\omega_{0}$.

(3) A duration $t\in\\{0,T_{0}/3,2T_{0}/3\\}$ is randomly chosen. The system
is then left to precess for a time $t$.

(4) The position $x(t)$ is measured at the chosen time. Since the round ends
here, the measurements can be destructive.

After many rounds, the average probability of finding the position of the
particle to be positive is calculated as the score $P_{3}(T_{0})$, that is,

$\displaystyle P_{3}(T_{0})$
$\displaystyle=\frac{1}{3}\sum_{k=0}^{2}\Bqty{\Pr\bqty{x\pqty{\tfrac{kT_{0}}{3}}>0}+\frac{1}{2}\Pr\bqty{x\pqty{\tfrac{kT_{0}}{3}}=0}}$
$\displaystyle=\frac{1}{3}\sum_{k=0}^{2}\left\langle\operatorname{pos}\bqty{x\pqty{\tfrac{kT_{0}}{3}}}\right\rangle,$
(1)

where $\operatorname{pos}(x)=[1+\operatorname{sgn}(x)]/2$, with the usual
convention $\operatorname{sgn}(x=0)=0$.

The crucial observation is this: Under the assumption that the dynamics is a
uniform precession, if the observed score satisfies
$P_{3}(T_{0})>\mathbf{P}_{3}^{c}:=\frac{2}{3}$, then the system is certified
to be quantum. To see why this is the case, let us consider every classical
phase-space trajectory, some of which are illustrated in Fig. 1(a). For any
classical state of maximal information that is prepared in any of the orange
regions at $t=0$, $x(t)>0$ at two out of three possible times
$t\in\\{0,T_{0}/3,2T_{0}/3\\}$ and hence will have a score of
$P_{3}^{c}=\frac{2}{3}$. For those initially prepared in the blue regions,
$x(t)>0$ at one out of the three times with a score of
$P_{3}^{c}=\frac{1}{3}$. Meanwhile, the fixed point $(x,p)=(0,0)$ has the
score $P_{3}^{c}=\frac{1}{2}$. As a general classical state would be some
convex mixture of these states of maximal information, the maximum achievable
score with a classical harmonic oscillator is
$\mathbf{P}^{c}_{3}=\frac{2}{3}$.

In quantum theory, the score $P_{3}(T_{0})$ is given by the expectation value
$\expectationvalue{Q_{3}(T_{0})}$ of the observable

$Q_{3}(T_{0})=\frac{1}{3}\sum_{k=0}^{2}\operatorname{pos}\bqty{X\pqty{\tfrac{kT_{0}}{3}}},$
(2)

where $X(t)=e^{iHt/\hbar}Xe^{-iHt/\hbar}$ is the position observable in the
Heisenberg picture and
$\operatorname{pos}(X)\ket{x}=\operatorname{pos}(x)\ket{x}$. Generally, the
state of a quantum system is specified by a density operator $\rho$, with
which $\expectationvalue{Q_{3}(T_{0})}=\tr[\rho Q_{3}(T_{0})]$.

There are quantum states such that $\tr[\rho
Q_{3}(T_{0})]>\mathbf{P}_{3}^{c}$. The states that give the largest quantum
value are eigenvectors of $Q_{3}(T_{0})$ for the largest eigenvalue and were
discussed in [3, 4]. Here, in anticipation of the energy constraints to be
expounded in later sections, we consider the state that gives the maximal
violation under the truncation $E_{n}\leq E_{\mathbf{n}}$ for some maximal
number of excitations $\mathbf{n}$. In the original protocol, no violation is
obtained for $\mathbf{n}<6$, while for $\mathbf{n}=6$ the state

$\ket{\Psi_{6}}=\frac{1}{\sqrt{2}}\pqty{\frac{4}{\sqrt{21}}\ket{0}-\ket{3}+\sqrt{\frac{5}{21}}\ket{6}},$
(3)

where the $\ket{n}$ are the usual number states of the quantum harmonic
oscillator, achieves the score
$P_{3}(T_{0})=\matrixelement{\Psi_{6}}{Q_{3}(T_{0})}{\Psi_{6}}=0.687$.

Figure 2: For the harmonic oscillator, (a) the Wigner function and (b) the
probability density at the probing times $t=0,T_{0}/3,2T_{0}/3$ of the state
$\ket{\Psi_{6}}$ given in Eq. (3), which violates the classical bound with the
score $P_{3}(T_{0})=0.687>\mathbf{P}_{3}^{c}$. The classical scores
$P_{3}^{c}$ are superimposed on the corresponding regions as illustrated in
Fig. 1(a). The negativities of the Wigner function are concentrated in the
regions with the lowest classical score, which augments the positivity of the
Wigner function in the region with the largest classical score. This is the
state that maximally violates the classical bound for the original protocol
under the restriction $E_{n}\leq E_{\mathbf{n}}$ for $\mathbf{n}=6$.

When only position measurements (or, more generally, quadrature measurements)
are involved, a quantum state with a non-negative Wigner function is
indistinguishable from a classical state with the same joint probability
distribution. Thus, some Wigner negativity has to be present for a gap between
the quantum and classical scores. In addition, this negativity must be present
at the right location. The intuition is clearly conveyed by the Wigner
function of $\ket{\Psi_{6}}$ (Fig. 2): The negativities are concentrated in
the regions with the lowest classical score ($P_{3}^{c}=\frac{1}{3}$), which
augments the positivity in the regions with the highest classical score
($P_{3}^{c}=\frac{2}{3}$). Every other state that violates the classical bound
also shares this general behavior.

In summary, under the assumption that its dynamics is a uniform precession,
the observation $P_{3}(T_{0})>\mathbf{P}_{3}^{c}=\frac{2}{3}$ certifies the
quantumness of the system. The classical bound can be violated by preparing
states that have Wigner negativities in the regions that achieve the minimum
scores in the classical system.

Figure 3: For the harmonic oscillator, the maximum quantum score
$\mathbf{P}_{3}^{\infty}(\mathbf{T})$ against probing duration $\mathbf{T}$.
Here $\mathbf{P}_{3}^{\infty}(\mathbf{T})$ was found by solving for the
maximum eigenvalue of $Q_{3}(\mathbf{T})$ with the truncation $n\leq 6000$.

###  II.2 Changing the probing times

Now we proceed to modify step 3 of the protocol. This could be done in
different ways: choosing three arbitrary times [3] or probing at $K>3$ equally
spaced times [4]. For the sake of this work, we focus on a single-parameter
family.

(3′) A duration $t\in\\{0,\mathbf{T}/3,2\mathbf{T}/3\\}$ is randomly chosen
for a value $\mathbf{T}$ which may differ from the period of the precession.
The system is then left to evolve for a time $t$.

The rest of the protocol is unchanged, with the score $P_{3}(\mathbf{T})$ now
obtained by replacing $T_{0}$ with $\mathbf{T}$ in Eq. (II.1).

Of course, the value of $\mathbf{T}$ may affect the classical bound: For
example, $\mathbf{T}=3T_{0}$ results in
$x(0)=x(\mathbf{T}/3)=x(2\mathbf{T}/3)$ such that a state initially in the
positive-$x$ plane scores $P_{3}(\mathbf{T}=3T_{0})=1$. In that case, there
cannot be any gap between the classical and quantum expectations. It is
straightforward to prove that the bound $\mathbf{P}_{3}^{c}=\frac{2}{3}$ holds
in the range $3T_{0}/4\leq\mathbf{T}\leq 3T_{0}/2$ (Fig. 1).

For the quantum observable, we analogously define $Q_{3}(\mathbf{T})$ by
replacing $T_{0}$ with $\mathbf{T}$ in Eq. (2). As shown in Fig. 3, the
classical bound can be violated within the range of $\mathbf{T}$ up to
$\mathbf{P}^{\infty}_{3}(\mathbf{T}):=\max_{\rho}\tr[\rho Q_{3}(\mathbf{T})]$,
with maximal violation for $\mathbf{T}=T_{0}$. At the boundary points, no
violation can be found since

$\displaystyle Q_{3}(3T_{0}/4)$
$\displaystyle=\frac{1}{3}+\frac{1}{3}\operatorname{pos}[X(T_{0}/2)],$ (4)
$\displaystyle Q_{3}(3T_{0}/2)$
$\displaystyle=\frac{1}{3}+\frac{1}{3}\operatorname{pos}[X(0)],$

in which cases
$\mathbf{P}^{\infty}_{3}(3T_{0}/4)=\mathbf{P}^{\infty}_{3}(3T_{0}/2)=\frac{2}{3}=\mathbf{P}_{3}^{c}$.

The flexibility in probing durations introduces a qualitative difference when
we look at truncations. As mentioned before, no state with $\mathbf{n}<6$
violates the original protocol. If we maintain the truncation at
$\mathbf{n}=6$, the maximum is still achieved by $\ket{\Psi_{6}}$ [Eq. (3)]
for $\mathbf{T}=T_{0}$. However, by changing the probing time, we can find
states with $\mathbf{n}<6$ that give a violation. Specifically, for
$\mathbf{n}=4$ the state

$\displaystyle\ket{\Psi_{4}}$
$\displaystyle=\sqrt{0.279}\ket{0}+\sqrt{0.191}\ket{1}e^{-i\theta_{4}}+\sqrt{0.121}\ket{2}e^{-i2\theta_{4}}$
(5)
$\displaystyle\quad{}+{}\sqrt{0.309}\ket{3}e^{-i3\theta_{4}}+\sqrt{0.100}\ket{4}e^{-i4\theta_{4}},$

where $\theta_{4}=0.215\pi$, achieves
$P_{3}(\mathbf{T})=\matrixelement{\Psi_{4}}{Q_{3}(\mathbf{T})}{\Psi_{4}}=0.669$
with probing duration $\mathbf{T}=1.177T_{0}$.

Figure 4: For the harmonic oscillator, (a) the Wigner function and (b) the
probability density at the probing times $t=0,\mathbf{T}/3,2\mathbf{T}/3$ of
the state $\ket{\Psi_{4}}$ given in Eq. (5), which violates the classical
bound with the score $P_{3}(\mathbf{T})=0.669>\mathbf{P}_{3}^{c}$. The probing
duration is $\mathbf{T}=1.774T_{0}$, where $T_{0}$ is the natural period of
the harmonic oscillator. The classical scores $P_{3}^{c}$ are superimposed on
the corresponding regions as illustrated in Fig. 1(d). Here the negativities
of the Wigner function are concentrated in the regions with the lowest
classical score, which augments the positivity of the Wigner function in the
region with the largest classical score. This is the state that maximally
violates the classical bound for the protocol with varying probing times under
the restriction $E_{n}\leq E_{\mathbf{n}}$ for $\mathbf{n}=4$.

The Wigner function and marginal probability distribution of $\ket{\Psi_{4}}$
are plotted in Fig. 4. As usual, the Wigner function is distributed in such a
manner that the positive (negative) weights are concentrated in the regions
where the classical score is $P_{3}^{c}=\frac{2}{3}$
($P_{3}^{c}=\frac{1}{3}$). However, while the Wigner function of
$\ket{\Psi_{6}}$ has the same symmetry as the protocol (the system is found in
the same state at all three probing times), the positivity of $\ket{\Psi_{4}}$
is mostly concentrated on only one $P_{3}^{c}=\frac{2}{3}$ region. At the
times $t\in\\{0,2\mathbf{T}/3\\}$, almost all of the probability distribution
lies on the positive-$x$ axis. At time $t=\mathbf{T}/3$, most of the
probability is on the negative-$x$ axis, but a small contribution from the
positive-$x$ axis augments the quantum score.

The take-away message is that we can extend the notion of the probing duration
$\mathbf{T}$ to something other than the natural period $T_{0}$ of the system,
as long as we make a choice that maintains the classical bound to be
$\mathbf{P}_{3}^{c}<1$, so that a quantum-classical gap can be possible
(though it might not be guaranteed). In some cases, like with the low-energy
state $\ket{\Psi_{4}}$ with $\mathbf{n}=4$, the quantum score can be improved
by using a different probing duration.

##  III Protocol for general Hamiltonians

Most forms of experimental trapping are approximately harmonic. In these
cases, our original protocol could be straightforwardly applied to detect
nonclassicality in the parameter regime where the harmonic approximation
holds. This notably includes a tight upper bound on the energy [13]. By
adopting a general approach instead of a reduction to the harmonic case, we
will be able to detect nonclassicality in a much larger parameter range. In
addition, we will also be able to deal with potentials that are not
approximately harmonic.

###  III.1 Overview of the general protocol

We consider systems with one degree of freedom with canonical coordinates
$(q,p)$ whose dynamics is generated by a time-independent Hamiltonian
$H(q,p)$. The dynamics of the corresponding quantum system is given by the
Weyl-quantized Hamiltonian $H(Q,P)$, where $(Q,P)$ are the canonically
conjugate operators which satisfy
$e^{ipQ/\hbar}e^{iqP/\hbar}=e^{-ipq/\hbar}e^{iqP/\hbar}e^{ipQ/\hbar}$, the
Weyl form of the canonical commutation relation. The Weyl relation implies
$\commutator{Q}{P}=\commutator{X}{P}=i\hbar\mathbbm{1}$ for Cartesian
coordinates $(q,p)=(x,p)$ [14], but is also valid with angular coordinates
$(q,p)=(\phi,l)$ [15]. For the Cartesian coordinates, this relation results in
the same equations of motions of $x(t)$ and $p(t)$ for both the quantum and
classical systems, regardless of the form of the Hamiltonian [16].

Once again, the general protocol consists of many independent rounds. In each
round, the following steps take place.

(1) The system is prepared in some state.

(2′) After the preparation is completed, the system is decoupled from
everything else and undergoes the closed dynamics specified by $H(q,p)$.

(3′) A duration $t\in\\{0,\mathbf{T}/3,2\mathbf{T}/3\\}$ is randomly chosen
for a specified value $\mathbf{T}$. The system is then left to evolve for a
time $t$.

(4′) The coordinate $q(t)$ is measured at the chosen time. Since the round
ends here, the measurements can be destructive.

After many rounds, we calculate $P_{3}(\mathbf{T})$, the average probability
that the coordinate is found to be positive:

$\displaystyle P_{3}(\mathbf{T})$
$\displaystyle:=\sum_{k=0}^{2}\Bqty{\Pr[q(\tfrac{k\mathbf{T}}{3})>0]+\frac{1}{2}\Pr[q(\tfrac{k\mathbf{T}}{3})=0]}$
(6)
$\displaystyle=\frac{1}{3}\sum_{k=0}^{2}\operatorname{pos}\bqty{q\pqty{\tfrac{k\mathbf{T}}{3}}}.$

If the measured score $P_{3}(\mathbf{T})$ is found to be strictly larger than
the classical bound $\mathbf{P}^{c}_{3}$, then the system must be quantum. For
the calculations in quantum theory, given a state $\rho$, the score is
calculated by $P_{3}(\mathbf{T})=\tr[\rho Q_{3}(\mathbf{T})]$, where

$Q_{3}(\mathbf{T}):=\frac{1}{3}\sum_{k=0}^{2}\operatorname{pos}\bqty{Q(\tfrac{k\mathbf{T}}{3})},$
(7)

$\operatorname{pos}(Q)=\bqty{\mathbbm{1}+\operatorname{sgn}(Q)}/2$, and
$Q(t)=e^{iHt/\hbar}Qe^{-iHt/\hbar}$.

Of course, one can more generally calculate the score with $\Pr[q(t)>q_{0}]$
against some reference position $q_{0}$ or instead consider the likelihood
$\Pr[q(t)<0]$ that the coordinate is found to be negative. In those cases, it
is a simple matter to redefine $q^{\prime}(t):=q(t)-q_{0}$ or
$q^{\prime}(t):=-q(t)$, respectively, which we can always do as we are free to
choose our coordinates. Doing so returns it to the form given in Eq. (6), so
we will stick to this standard form.

In order to find a classical-quantum gap, we will have to impose additional
constraints, which generically take the form of energy bounds
$E_{\text{min}}\leq E\leq E_{\text{max}}$ (secondary assumptions may also be
required for specific systems). We proceed to derive these constraints
rigorously.

###  III.2 Constraints in classical theory

A nontrivial classical bound is required for the protocol, which for three
probing times can only be $\mathbf{P}^{c}_{3}=\frac{2}{3}$. So we need to
exclude the possibility that $P_{3}^{c}=1$, i.e., evolutions such that
$q(t)>0$ at all measured times $t\in\\{0,\mathbf{T}/3,2\mathbf{T}/3\\}$. Like
in the case of the harmonic oscillator, $P_{3}^{c}=1$ may happen if
$\mathbf{T}$ is either too short or too long; for generic dynamics, these
bounds may vary with the trajectory. The situations to avoid are illustrated
in Fig. 5.

Formally, consider any phase-space trajectory $\gamma$, with its generalized
coordinate denoted by $q_{\gamma}(t)$. We exclude the trivial trajectory
$q_{\gamma_{0}}(t)=0\;\forall t$, which would lead to cumbersome notation but
whose score is $P_{3}(\mathbf{T})=\frac{1}{2}$ for any $\mathbf{T}$ by the
definition of $P_{3}(\mathbf{T})$. Let us define $\Delta t_{+}(\gamma)$ as the
longest amount of time that the trajectory $\gamma$ spends in the region where
$q$ is non-negative:

$\Delta t_{+}(\gamma):=\begin{cases}\infty&\text{if $q_{\gamma}(t)\geq
0\;\forall t$}\\\ \max\Bqty{\Delta t:\exists t_{0}:t_{0}\leq t\leq
t_{0}+\Delta t:q_{\gamma}(t)\geq 0}&\text{otherwise.}\end{cases}$ (8)

Similarly, we define $\Delta t_{-}(\gamma)$ as the shortest amount of time
that the trajectory $\gamma$ spends in the region where $q$ is strictly
negative:

$\Delta t_{-}(\gamma):=\begin{cases}\infty&\text{if $q_{\gamma}(t)<0\;\forall
t$}\\\ \min\Bqty{\Delta t:\exists t_{0}:q_{\gamma}(t_{0})\geq
0;q_{\gamma}(t_{0}+\Delta t)\geq 0;t_{0}<t<t_{0}+\Delta
t:q_{\gamma}(t)<0}&\text{otherwise.}\end{cases}$ (9)

For the classical bound to be $\mathbf{P}^{c}_{3}=\frac{2}{3}$, we should
restrict ourselves to a set $\Gamma$ of classical trajectories and a probing
time such that

$\begin{gathered}\max_{\gamma\in\Gamma\setminus\\{\gamma_{0}\\}}\frac{3}{2}\Delta
t_{+}(\gamma)\leq\mathbf{T}\leq\min_{\gamma\in\Gamma\setminus\\{\gamma_{0}\\}}3\Delta
t_{-}(\gamma)\,.\end{gathered}$ (10)

As a consistency check for the harmonic oscillator, $\Delta
t_{+}(\gamma)=\Delta t_{-}(\gamma)=T_{0}/2$ for all $\gamma$, recovering the
previous condition on $\mathbf{T}$.

Figure 5: For the generic condition, the score $P_{3}=1$ occurs for certain
classical trajectories (a) if all three measurements are performed before the
state crosses the $p$ axis and (b) if the state crosses the $p$ axis at least
twice between two measurements. Note that (a) also includes the situation
where the state remains in the positive-$q$ plane for all time and (b) also
includes the situation where the state crosses the $p$ axis more than twice.
Also labeled are $\Delta t_{+}$ and $\Delta t_{-}$, the longest and shortest
times spent in the positive- and negative-$q$ planes, respectively.

Quantitatively, Eq. (10) provides the exact inequality for which a nontrivial
classical bound is achieved. Qualitatively, it expounds two conditions. First,
the lower bound states that the particle cannot spend an arbitrarily long time
in the positive region, which means that there must be some barrier on the
positive side of the origin. Second, the upper bound states that the particle
cannot spend an arbitrarily short time in the negative region. Specifically,
the barrier on the negative side of the origin cannot be too strong, lest the
particle be pushed back to the positive side too rapidly even in the classical
system, which reduces the quantum-classical gap. Ultimately, to obtain
nontrivial classical bounds, some form of trapping is required on the positive
axis, without the trapping being too strong on the negative axis. We stress
once again that this trapping need not be approximately harmonic; the only
requirement is Eq. (10).

###  III.3 Energy constraints

For use in our protocol, the constraint (10) on trajectories needs to be
translated into one or several constraints on quantities that are observables
in both quantum and classical theory. The obvious choice is energy. Indeed,
when the Hamiltonian is time independent, the energy is an integral of motion;
hence $H(q_{\gamma}(t),p_{\gamma}(t))=E$ along any trajectory $\gamma$. For
systems with one degree of freedom, the equation $H(q,p)=E$ defines a one-
dimensional curve. If $E$ is not degenerate, it uniquely specifies a phase-
space trajectory. If $E$ is degenerate, as phase-space trajectories cannot
cross, $H(q,p)=E$ specifies a set $\\{\gamma_{k}\\}$ of distinct trajectories.

Now let us define

$\displaystyle\Delta t_{+}(E)$
$\displaystyle:=\max_{\gamma\in\Gamma\setminus\\{\gamma_{0}\\}:H(q_{\gamma},p_{\gamma})=E}\Delta
t_{+}(\gamma)$ (11) $\displaystyle\Delta t_{-}(E)$
$\displaystyle:=\min_{\gamma\in\Gamma\setminus\\{\gamma_{0}\\}:H(q_{\gamma},p_{\gamma})=E}\Delta
t_{-}(\gamma).$

Like previously, $\Gamma$ is the set of all classical trajectories under
consideration. Without any additional assumptions, this is the set of all
possible trajectories, while secondary assumptions would place restrictions on
$\Gamma$.

Using Eq. (11), Eq. (10) can be rewritten in terms of the energy bounds
$E_{\text{min}}\leq E\leq E_{\text{max}}$,

$\max_{E_{\text{min}}\leq E\leq E_{\text{max}}}\frac{3}{2}\Delta
t_{+}(E)\leq\mathbf{T}\leq\min_{E_{\text{min}}\leq E\leq
E_{\text{max}}}3\Delta t_{-}(E).$ (12)

Therefore, $E_{\text{min}}$ and $E_{\text{max}}$ should be chosen such that
Eq. (12) is satisfied. In the quantum system, this condition manifests as a
projection of the full Hilbert space onto a smaller, oftentimes finite,
subspace spanned by the energy eigenstates whose energies lie within that
range.

###  III.4 Summary of procedure

Let us summarize the procedure for finding the probing duration $\mathbf{T}$
with respect to some energy bounds $E_{\text{min}}$ and $E_{\text{max}}$.

(1) Identify $\Gamma$, the set of classical trajectories under consideration.
Secondary assumptions might restrict $\Gamma$ to a subset of all possible
trajectories.

(2)Find $\Delta t_{\pm}(E)$ as a function of energy.

(3) Invert Eq. (12) to obtain inequalities for $E_{\text{min}}$ and
$E_{\text{max}}$ as functions of $\mathbf{T}$. Choose a valid $\mathbf{T}$
such that $E_{\text{min}}\leq E_{\text{max}}$.

(4) Construct $Q_{3}(\mathbf{T})$ in the energy-eigenstate basis, restricted
to the subspace $\\{\ket{E_{n}}\\}$, where $E_{\text{min}}\leq E_{n}\leq
E_{\text{max}}$.

(5) Solve for the maximum eigenvalue of $Q_{3}(\mathbf{T})$.

If the maximum eigenvalue $\mathbf{P}_{3}^{\infty}$ is larger than
$\mathbf{P}_{3}^{c}=\frac{2}{3}$, then there are states that would allow us to
certify the quantumness of the system by performing the protocol with probing
duration $\mathbf{T}$.

Let us now explain how one may go about steps 2 and 4 in some generality.

####  III.4.1 Simplifications for Step 2

Depending on symmetries present in the Hamiltonian, some simplifications can
be made when calculating $\Delta t_{\pm}$.

Figure 6: For the general approach, possible trajectories for nonrelativistic
Hamiltonians when the only solutions to $E-V(q)=0$, excluding the fixed point
$(q=0,p=0)$, are $q_{-1}$ or $q_{+1}$, or both. (a) If $q_{-1}$ is not a
solution, there are two possibilities: if
$\frac{dp}{dt}\rvert_{q_{+1},p=0}=-\frac{\partial V(q)}{\partial
q}\rvert_{q_{+1}}\geq 0$, the trajectory will never enter the negative-$q$
plane and hence $\Delta t_{-}(E)=0$; if $-\frac{\partial V(q)}{\partial
q}\rvert_{q_{+1}}<0$, the trajectory enters the negative-$q$ plane, but as it
does not intersect the $q$ axis again, it remains in the negative $q$ plane
and hence $\Delta t_{-}(E)=0$. (b) If $q_{-1}$ is a solution, there are also
two possibilities: If $-\frac{\partial V(q)}{q}\rvert_{q_{-1}}>0$, the
trajectory will intersect the $p$ axis at the points $p_{-}$ and $p_{+}$ with
$p_{-}<p_{+}$, and hence $\Delta t_{-}(E)$ can be found as an integral over
the path from $(q=0,p_{-})$ to $(q=0,p_{+})$, as given in Eq. (13). If
$-\frac{\partial V(q)}{q}\rvert_{q_{-1}}\leq 0$, the trajectory will never
enter the positive-$q$ plane, and hence $\Delta t_{-}(E)=\infty$. Analogous
expressions for $\Delta t_{+}(E)$ can be found by a reflection $q\to-q$.

(1) $H(q,p)$ even in $q$. When $H(-q,p)=H(q,p)$, every collection of
trajectories $\\{\gamma_{k}\\}$ with energy $E$ is symmetric about the $p$
axis. Therefore, the amounts of time spent in the positive- and negative-$q$
planes are the same, so $\Delta t_{+}(E)=\Delta t_{-}(E)$. If $\gamma$ is a
closed path that intersects the $p$ axis and has period $T_{0}(\gamma)$, then
$\Delta t_{\pm}(\gamma)=T_{0}(\gamma)/2$.

(2) $H(q,p)$ even in $p$. When $H(q,-p)=H(q,p)$, every trajectory $\gamma$ is
symmetric about the $q$ axis. Hence, it is adequate to consider the trajectory
$(q_{\gamma}(t),p_{\gamma}(t))$ that starts from $p(0)=0$ for the times $0\leq
t<\infty$, with the solution for $t<0$ obtained with a reflection. Hence,
given the initial conditions $p(0)=0$ and $x(0)<0$ [$p(0)=0$ and $x(0)>0$],
$\Delta t_{-}(\gamma)$ [$\Delta t_{+}(\gamma)$] is twice the time taken for
the trajectory to reach $x=0$.

_(3) Hamiltonian is nonrelativistic_. If $H(q,p)=p^{2}/2\mu+V(q)$, the
solutions to $E-V(q)=0$ are the points where a trajectory with energy $E$
intersects the $q$ axis, which we will denote by
$\cdots<q_{-2}<q_{-1}<0<q_{+1}<q_{+2}<\cdots$. Note that all possible
trajectories with energy $E$ can only intersect the $p$ axis at the two points
$p_{\pm}=\pm\sqrt{2\mu[E-V(0)]}$. Furthermore, since $H(q,p)$ is even in $p$,
the fact that every trajectory is symmetric about the $q$ axis implies that
the trajectory that contains the points $(q,0)$ and $(0,p_{+})$ must also
contain the point $(0,p_{-})$. Therefore, if $q_{+2}$ is a solution, then the
two trajectories that intersect the $q$ axis at $q_{+1}$ and $q_{+2}$ cannot
both cross the $p$ axis. In other words, at least one of the two trajectories
must remain indefinitely in the positive-$q$ plane such that $\Delta
t_{+}(E)=\infty$. If $q_{-2}$ is a solution, an analogous reasoning gives
$\Delta t_{-}(E)=\infty$.

Meanwhile, if $q=0$ is a solution to $E-V(q)=0$, there are three
possibilities: $(q=0,p=0)$ is a fixed point, $-\frac{\partial V(q)}{\partial
q}\rvert_{q=0}>0$, or $-\frac{\partial V(q)}{\partial q}\rvert_{q=0}<0$. If
$(q=0,p=0)$ is a fixed point, it is excluded from the definition of $\Delta
t_{\pm}(E)$ and can be ignored. If $-\frac{\partial V(q)}{\partial
q}\rvert_{q=0}=\frac{dp}{dt}\rvert_{(q=0,p=0)}>0$, the trajectory remains in
the positive-$q$ plane, and hence $\Delta t_{+}(E)=\infty$. Conversely,
$-\frac{\partial V(q)}{\partial
q}\rvert_{q=0}=\frac{dp}{dt}\rvert_{(q=0,p=0)}<0\implies\Delta
t_{-}(E)=\infty$.

These arguments imply that the only situation where $\Delta t_{\pm}(E)$ is
finite is when, excluding the fixed point $(q=0,p=0)$, either $q_{-1}$ or
$q_{+1}$ or both $q_{-1}$ and $q_{+1}$ are the only solutions of $E-V(q)=0$.
If that is the case, the possible trajectories are illustrated in Fig. 6,
which gives rise to the following formulas for $\Delta t_{\pm}(E)$, which
allows us to calculate $\Delta t_{\pm}(E)$ with numerical integration even
when the exact trajectories cannot be solved:

$\displaystyle\Delta t_{-}(E)$ $\displaystyle=\begin{cases}0&\text{if $q_{-1}$
is not a solution and $\left.-\frac{\partial V(q)}{\partial
q}\right\rvert_{q_{+1}}\geq 0$}\\\
\sqrt{\frac{\mu}{2}}\int_{q_{-1}}^{0}\frac{\differential{q}}{\sqrt{E-V(q)}}&\text{if
$q_{-1}$ is a solution and $\left.-\frac{\partial V(q)}{\partial
q}\right\rvert_{q_{-1}}>0$}\\\ \infty&\text{otherwise,}\end{cases}$ (13)
$\displaystyle\Delta t_{+}(E)$ $\displaystyle=\begin{cases}0&\text{if $q_{+1}$
is not a solution and $-\left.\frac{\partial V(q)}{\partial
q}\right\rvert_{q_{-1}}\leq 0$}\\\
\sqrt{\frac{\mu}{2}}\int_{0}^{q_{+1}}\differential{q}\frac{1}{\sqrt{E-V(q)}}&\text{if
$q_{+1}$ is a solution and $-\left.\frac{\partial V(q)}{\partial
q}\right\rvert_{q_{+1}}<0$}\\\ \infty&\text{otherwise.}\end{cases}$ (14)

####  III.4.2 Simplifications for Step 4

For the eigenstates $\ket{E_{n}}$ of $H$ that belong to the discrete part of
the energy spectrum, we need to compute the matrix elements

$\displaystyle\matrixelement{E_{n}}{Q_{3}}{E_{n^{\prime}}}=\frac{1}{2}\delta_{n,n^{\prime}}+\frac{1}{6}\sum_{k=0}^{2}e^{ik\mathbf{T}\theta_{n,n^{\prime}}}\matrixelement{E_{n}}{\operatorname{sgn}(Q)}{E_{n^{\prime}}},$
(15)

where $\theta_{n,n^{\prime}}:=(E_{n}-E_{n^{\prime}})/3\hbar$. In the examples
studied in this paper, the spectrum of $Q$ is continuous with support
$q\in[q_{\text{min}},q_{\text{max}}]$, where
$q_{\text{min}}<0<q_{\text{max}}$. The matrix elements of
$\operatorname{sgn}(Q)$ are found with the integration

$\matrixelement{E_{n}}{\operatorname{sgn}(Q)}{E_{n^{\prime}}}=\int_{0}^{q_{\text{max}}}\differential{q}\innerproduct{E_{n}}{q}\\!\\!\innerproduct{q}{E_{n^{\prime}}}-\int_{q_{\text{min}}}^{0}\differential{q}\innerproduct{E_{n}}{q}\\!\\!\innerproduct{q}{E_{n^{\prime}}}.$
(16)

Depending on symmetries present in the Hamiltonian, some simplifications can
be made when calculating the matrix elements of $\operatorname{sgn}(Q)$.
Notably, if $H(Q,P)$ commutes with the parity operator $\Pi$, where $\Pi
Q\Pi=-Q$, then there exists a set of eigenvectors $\ket{E_{n}}$ of $H$ that
are also eigenvectors of $\Pi$. For those states,
$\expectationvalue{\operatorname{sgn}(-Q)}{E_{n}}=\expectationvalue{\Pi\operatorname{sgn}(Q)\Pi}{E_{n}}=(\pm
1)^{2}\expectationvalue{\operatorname{sgn}(Q)}{E_{n}}$, that is,
$\expectationvalue{\operatorname{sgn}(Q)}{E_{n}}=0$.

Matrix elements for nondegenerate energies of a nonrelativistic Hamiltonian.
This simplification for systems with a nonrelativistic Hamiltonian
$H(Q,P)=P^{2}/2\mu+V(Q)$ is due to Mawby and Halliwell [10]: Given that $Q$
has the continuous spectrum stated at the start of this section and its
eigenstates $\ket{q}$ are acted upon by $P$ as
$\bra{q}P=-i\hbar\frac{\partial}{\partial q}\bra{q}$, then, for $E_{n}\neq
E_{n^{\prime}}$,

$\displaystyle\matrixelement{E_{n}}{\operatorname{sgn}(Q)}{E_{n^{\prime}}}{}={}$
$\displaystyle\frac{\hbar^{2}}{2\mu(E_{n}-E_{n^{\prime}})}\Bigg{(}\innerproduct{E_{n}}{q_{\text{max}}}\left.\frac{\partial\innerproduct{q}{E_{n^{\prime}}}}{\partial
q}\right\rvert_{q=q_{\text{max}}}+\innerproduct{E_{n}}{q_{\text{min}}}\left.\frac{\partial\innerproduct{q}{E_{n^{\prime}}}}{\partial
q}\right\rvert_{q=q_{\text{min}}}$
$\displaystyle{}-{}\innerproduct{q_{\text{max}}}{E_{n^{\prime}}}\left.\frac{\partial\innerproduct{E_{n}}{q}}{\partial
q}\right\rvert_{q=q_{\text{max}}}-\innerproduct{q_{\text{min}}}{E_{n^{\prime}}}\left.\frac{\partial\innerproduct{E_{n}}{q}}{\partial
q}\right\rvert_{q=q_{\text{min}}}$ (17)
$\displaystyle{}-{}2\innerproduct{E_{n}}{q=0}\left.\frac{\partial\innerproduct{q}{E_{n^{\prime}}}}{\partial
q}\right\rvert_{q=0}+2\innerproduct{q=0}{E_{n^{\prime}}}\left.\frac{\partial\innerproduct{E_{n}}{q}}{\partial
q}\right\rvert_{q=0}\Bigg{)}.$

With Eq. (17), the matrix elements of $Q_{3}(\mathbf{T})$ for $E_{n}\neq
E_{n^{\prime}}$ can be found with just the values of the wave functions
$\innerproduct{q}{E_{n}}$ and $\innerproduct{q}{E_{n^{\prime}}}$, as well as
their first derivatives, at the points
$q\in\\{q_{\text{min}},0,q_{\text{max}}\\}$.

##  IV Four case studies

In the remainder of the paper, we study four specific examples. The first
three examples, i.e., Kerr nonlinear systems (Sec. IV.1), the pendulum (Sec.
IV.2), and the Morse potential (Sec. IV.3), are all approximately harmonic at
low anharmonicities. The Morse potential admits unbound trajectories; yet we
show that the protocol can still be performed with that system. For the last
example, we study the particle in an infinite well (Sec. IV.4). This toy model
serves to demonstrate the applicability of the protocol to general bound
systems, even when the system is not approximately harmonic.

###  IV.1 Kerr-nonlinear systems

As a first example, we consider a perturbation of the harmonic oscillator. We
choose a form that describes both nonlinear optical systems [17] and
superconducting transmon systems [18] up to the first nonlinear order:

$\displaystyle H(Q=X,P=P)$
$\displaystyle\quad{}={}\hbar\omega_{0}\Bqty{\bqty{1+\frac{\alpha}{2}\pqty{a^{\dagger}a+\frac{1}{2}}}\pqty{a^{\dagger}a+\frac{1}{2}}+\frac{3}{8}\mathbbm{1}}$
(18)
$\displaystyle\quad{}={}\hbar\omega_{0}(1+\alpha)\pqty{a^{{\dagger}}a+\frac{1}{2}\mathbbm{1}}+\hbar\omega_{0}\frac{\alpha}{2}a^{{\dagger}2}a^{2},$

where $a=\sqrt{{m\omega_{0}}/{2\hbar}}X+iP/{\sqrt{2m\hbar\omega_{0}}}$ is the
annihilation operator defined in the usual way. The corresponding classical
Hamiltonian is

$H(q=x,p=p)=H_{0}(x,p)+\frac{\alpha}{2\hbar\omega_{0}}\bqty{H_{0}(x,p)}^{2},$
(19)

where $H_{0}(x,p)={p^{2}}/{2m}+{m\omega_{0}^{2}x^{2}}/{2}$ is the Hamiltonian
of a harmonic oscillator. We obtain a nonstandard classical Hamiltonian, with
more-than-quadratic powers of $p$, as we have used Eq. (18) as the reference
dynamics.

Concerning the anharmonicity parameter $\alpha$, negative anharmonicities are
physically unfeasible, as the energy of the system would be unbounded from
below. However, noting that $\alpha<0$ sometimes appear as low-order
approximations of other Hamiltonians when $H_{0}(x,p)/\hbar\omega_{0}\ll 1$,
we will allow negative values of $\alpha$ with the secondary assumption that
only trajectories with $H_{0}(x,p)/\hbar\omega_{0}\leq
1/\absolutevalue{\alpha}$ are permitted.

####  IV.1.1 Classical bounds

For the trajectories under consideration, the Hamiltonian in Eq. (19) permits
energies within the range

$0\leq E/\hbar\omega_{0}\leq\begin{cases}\infty&\text{for $\alpha\geq 0$}\\\
1/2\absolutevalue{\alpha}&\text{otherwise.}\end{cases}$ (20)

It can be easily verified that the solution to the classical equations of
motion for a state with energy $E$ is

$\begin{gathered}x(t)=x(0)\cos[\omega(E)t]+\frac{p(0)}{m\omega}\sin[\omega(E)t],\\\
\text{where}\;\omega(E)=\sqrt{1+\frac{2\alpha
E}{\hbar\omega_{0}}}\omega_{0}.\end{gathered}$ (21)

Each phase-space trajectory is harmonic, uniquely identified by the energy
$E$, and has an energy-dependent period $2\pi/\omega(E)$. In addition, since
the Hamiltonian is even in $x$, using Sec. III.4.1,

$\Delta t_{+}(E)=\Delta t_{-}(E)=\frac{2\pi/\omega_{0}}{2\sqrt{1+{2\alpha
E}/{\hbar\omega_{0}}}}.$ (22)

Define $\mathbf{T}=:\tau\frac{2\pi}{\omega_{0}}$, with $\tau$ the ratio
between $\mathbf{T}$ and the natural period of the unperturbed harmonic
oscillator. Then the possible values of $E_{\text{min}}$ and $E_{\text{max}}$
that satisfy the condition in Eq. (12) for the given $\tau$ are

$\displaystyle\frac{E_{\text{min}}}{\hbar\omega_{0}}$
$\displaystyle\geq\begin{cases}\frac{1}{2\alpha}\pqty{\frac{9}{16\tau^{2}}-1}&\text{if
$\alpha\geq 0$}\\\ \frac{1}{2\alpha}\pqty{\frac{9}{4\tau^{2}}-1}&\text{if
$\alpha<0$,}\end{cases}$ (23)
$\displaystyle\frac{E_{\text{max}}}{\hbar\omega_{0}}$
$\displaystyle\leq\begin{cases}\frac{1}{2\alpha}\pqty{\frac{9}{4\tau^{2}}-1}&\text{if
$\alpha\geq 0$}\\\ \frac{1}{2\alpha}\pqty{\frac{9}{16\tau^{2}}-1}&\text{if
$\alpha<0$.}\end{cases}$

In both cases, choosing the equality maximizes the number of classical
trajectories that satisfy $P_{3}^{c}\leq\mathbf{P}_{3}^{c}$. As $E\geq 0$ for
all classical trajectories under consideration, we cannot allow
$E_{\text{max}}$ to be negative, as that would exclude all possible states. In
order to also include all classical states with $0\leq E\leq E_{\text{max}}$,
we finally arrive at the restriction $\frac{3}{4}\leq\tau\leq\frac{3}{2}$.

####  IV.1.2 Quantized system

From Eq. (18) it is clear that the Kerr nonlinear Hamiltonian shares the same
energy eigenstates $\ket{n}$ as the harmonic oscillator, with the eigenvalue

$H(X,P)\ket{n}=\underbrace{\hbar\omega_{0}\Bqty{\bqty{1+\frac{\alpha}{2}\pqty{n+\frac{1}{2}}}\pqty{n+\frac{1}{2}}+\frac{3}{8}}}_{=:E_{n}}\ket{n}.$
(24)

So the matrix elements of $Q_{3}$ as defined in Eq. (7) for the Kerr-nonlinear
Hamiltonian are

$\matrixelement{n}{Q_{3}}{n^{\prime}}=\begin{cases}\displaystyle\frac{(-1)^{({n^{\prime}-n-1})/{2}}2^{-[({n^{\prime}+n})/{2}-1]}\pqty{1+e^{i\tau\theta_{n,n^{\prime}}}+e^{i2\tau\theta_{n,n^{\prime}}}}}{6(n^{\prime}-n)}\sqrt{\frac{n^{\prime}}{\pi}\pmqty{undef}\pmqty{undef}}&\text{for
$n$ even, $n^{\prime}$ odd}\\\ \text{as above with $n\leftrightarrow
n^{\prime}$}&\text{for $n^{\prime}$ even, $n$ odd}\\\\[6.45831pt]
\displaystyle\frac{1}{2}\delta_{n,n^{\prime}}&\text{otherwise,}\end{cases}$
(25)

where
$\theta_{n,n^{\prime}}=2\pi(n-n^{\prime})\bqty{1+\frac{\alpha}{2}\pqty{n+n^{\prime}+1}}/3$
and we have used the matrix elements of
$\matrixelement{n}{\operatorname{sgn}(X)}{n^{\prime}}$ from [4]. Meanwhile,
the conditions in Eq. (23) translate to the truncation of the Hilbert space
spanned by $\\{\ket{n}\\}_{n=0}^{\infty}$ to

$\displaystyle n$
$\displaystyle\geq\begin{cases}\sqrt{\pqty{\frac{3}{4\alpha\tau}}^{2}-\frac{3}{4}}-\frac{1}{\alpha}-\frac{1}{2}&\text{if
$\alpha\geq 0$}\\\
-\sqrt{\pqty{\frac{3}{2\alpha\tau}}^{2}-\frac{3}{4}}-\frac{1}{\alpha}-\frac{1}{2}&\text{otherwise},\end{cases}$
(26a) $\displaystyle n$
$\displaystyle\leq\begin{cases}\sqrt{\pqty{\frac{3}{2\alpha\tau}}^{2}-\frac{3}{4}}-\frac{1}{\alpha}-\frac{1}{2}&\text{if
$\alpha\geq 0$}\\\
-\sqrt{\pqty{\frac{3}{4\alpha\tau}}^{2}-\frac{3}{4}}-\frac{1}{\alpha}-\frac{1}{2}&\text{otherwise}.\end{cases}$
(26b)

As such, we can construct $Q_{3}$ explicitly with the truncation (26) and find
the maximum quantum score $\mathbf{P}_{3}^{\infty}$ by solving for the largest
eigenvalue of $Q_{3}$.

####  IV.1.3 Quantum violation

Figure 7: For the Kerr nonlinear system, the maximum quantum score against
anharmonicity, for $\tau=1$ and the score maximized over
$\frac{3}{4}\leq\tau\leq\frac{3}{2}$. A larger violation is possible when the
system is weakly anharmonic, but this advantage is eventually offset due to
the energy constraints set by Eq. (26). The truncation in that equation also
explains the discontinuous jumps.

The maximum quantum score is plotted against anharmonicity in Fig. 7. For each
value of $\alpha$, we plot $\mathbf{P}_{3}^{\infty}$ both for $\tau=1$ and for
the optimal choice of probing duration $\frac{3}{4}\leq\tau\leq\frac{3}{2}$
(the two values coincide at $\alpha=0$, as they should). The discontinuous
jumps are due to the truncation of the Hilbert space, which changes discretely
according to Eq. (26).

As a general trend of the relationship between the quantum score and
anharmonicity, we find that $\mathbf{P}_{3}^{\infty}$ is maximal around
$\alpha\sim 0$ and decreases as $\absolutevalue{\alpha}$ increases. The reason
for the extremal behavior is clear: As $\absolutevalue{\alpha}$ becomes too
large, the truncation due to Eq. (26) reduces the Hilbert space dimension to
an extent where there can no longer be any violation.

In short, when the magnitude of the anharmonicity becomes too large, the
trapping becomes either too strong or too weak: For the reasons discussed
qualitatively in Sec. III.2, there is no longer be a gap between the quantum
and classical scores.

####  IV.1.4 Comparison with the harmonic approximation

In this section we compare the quantum scores of a weakly anharmonic system
with and without the harmonic approximation. First we need to quantify “weak.”
To do this, we note the following. On the one hand, in order to have a
violation we need to consider states with at least a few excitations [recall
states $\ket{\Psi_{6}}$ of Eq. (3) or states $\ket{\Psi_{4}}$ of Eq. (5)]; so
we are looking at states with $E\sim\hbar\omega_{0}$. On the other hand, these
states should be of low energy in the potential, i.e., $E\ll E_{\text{max}}$.
By setting $E_{\text{max}}/\hbar\omega_{0}\geq 10$ we find that weak
anharmonicity in our context means $\absolutevalue{\alpha}\leq 0.02$ (Fig. 8).

Figure 8: For the Kerr nonlinear system, the maximum energy bound against
anharmonicity, for $\tau=1$. To prepare states with $E/\hbar\omega_{0}\sim 1$,
the requirement $E_{\text{max}}\geq 10$ is met by anharmonicities
$\absolutevalue{\alpha}\leq 0.02$. There is an asymptotic behavior
$E_{\text{max}}/\hbar\omega_{0}\to\infty$ as $\alpha\to 0$.

Now, for fixed truncation of excitation $\mathbf{n}=6$, we study the role of
$\alpha$ in three scenarios.

(i) Find the state $\ket{\Psi}$ and time $\tau$ that violates the classical
bound maximally. Here we take the anharmonicity of the system fully into
account.

(ii) Fix the state as $\ket{\Psi_{6}}$ from the harmonic approximation [Eq.
(3)], but look for the probing time $\tau$ that maximizes the violation under
the anharmonic dynamics.

(iii) Fix the state as $\ket{\Psi_{6}}$ and set $\tau=1$, that is, import
naively the state and parameter from the harmonic approximation.

Figure 9: For the Kerr nonlinear system. (a) Score $P_{3}$ as a function of
the anharmonicity $\alpha$ for low-energy states with $n\leq 6$. Scenario (i)
corresponds to the optimal state $\ket{\Psi}$ and time $\tau$ with the largest
violation, (ii) corresponds to using $\ket{\Psi_{6}}$ from Eq. (3) with the
optimal $\tau$, and (iii) uses $\ket{\Psi_{6}}$ and $\tau=1$, treating the
anharmonic system as if it were a harmonic one. (b) Optimal $\tau$ used for
each scenario for every value of $\alpha$. Figure 10: For the Kerr nonlinear
system, the Wigner function and marginal probability distribution at times
$t\in\\{0,\mathbf{T}/3,2\mathbf{T}/3\\}$ of the $\mathbf{n}=6$ optimal state
with (a) $\alpha=0.02$ and (b) $\alpha=-0.02$. The optimal states in the
weakly anharmonic cases are slightly distorted versions of the optimal state
with $\mathbf{n}=6$ in the harmonic case (plotted in Fig. 2). The classical
score regions superimposed on the Wigner function are those that correspond to
the probing duration $\tau$ (see Fig. 1). Figure 11: Kerr nonlinear system.
(a) Score $P_{3}$ as a function of the anharmonicity $\alpha$ for the state
with truncation $n\leq 4$. Scenario (i) corresponds to the optimal state
$\ket{\Psi}$ and time $\tau$ with the largest violation, (ii) corresponds to
using $\ket{\Psi_{4}}$ from Eq. (5) with the optimal $\tau$, and (iii) uses
$\ket{\Psi_{4}}$ and $\tau=1.774$, treating the anharmonic system as if it
were a harmonic one. (b) Optimal $\tau$ for each value of $\alpha$.

The scores and probing durations for the three scenarios are plotted in Fig.
9. We find that the quantum score decreases with the magnitude of the
anharmonicity, albeit the decrease is negligible if everything is optimized
for the dynamics [scenario (i)]. The optimal probing duration decreases with
$\alpha$ increasing: Since the period of a fixed-energy state increases with
$\alpha$, decreasing the probing duration offsets this increase. For the
Wigner function of the optimal state for scenario (i) at different
anharmonicities in Fig. 10, we observe that the states at $\alpha\neq 0$ are
distorted forms of the state $\ket{\Psi_{6}}$ at $\alpha=0$, with barely
perceptible differences. In addition, comparing scenarios (ii) and (iii), we
see that the quantum violation is greatly increased by optimizing $\tau$, even
if the state is fixed as $\ket{\Psi_{6}}$. This might be of interest for
experimental implementations, as preparing a new state is arguably harder than
adjusting the probing times.

Meanwhile, for the harmonic oscillator with varying $\tau$, the lowest-
truncation state in the harmonic case is $\ket{\Psi_{4}}$ [Eq. (5)] at probing
duration $\tau=1.774$ with $\mathbf{n}=4$. The same three scenarios as before
are performed with the restriction $E_{n}\leq E_{\mathbf{n}}$ for
$\mathbf{n}=4$ and the results are plotted in Fig. 11. The optimal state at
$\alpha=0.02$ is similar to the state $\ket{\Psi_{4}}$ at $\alpha=0$, while
the state at $\alpha=-0.02$ is a “flipped” version of $\ket{\Psi_{4}}$: This
is in the sense that the bulk of the negativity is concentrated into the
region with $P_{3}^{c}=\frac{1}{3}$, while two peaks of positivity appear on
either side in the regions with $P_{3}^{c}=\frac{2}{3}$.

Figure 12: For the Kerr nonlinear system, the Wigner function and marginal
probability distribution at times $t\in\\{0,\mathbf{T}/3,2\mathbf{T}/3\\}$ of
the $\mathbf{n}=4$ optimal state with (a) $\alpha=0.02$ and (b)
$\alpha=-0.02$. The Wigner function is distributed such that there is a
significant tail of the probability density that is present in the positive
$x$ plane even when the bulk of the state is concentrated on the negative-$x$
plane.

The optimal probing duration similarly decreases with an increase in $\alpha$.
However, unlike before, the quantum score increases with $\alpha$. We can
understand this behavior as follows. The radial coordinate of the Wigner
function corresponds to energy, which increases as we move further away from
the origin. From Fig. 12(a) we find that the largest contribution to the
optimal state comes from higher-energy states. The decrease in probing
duration with the increase in anharmonicity ensures that the higher-energy
contributions are in the positive-$x$ plane at $t=0$ and $2\mathbf{T}/3$. On
the other hand, the period of the lower-energy states barely changes with
anharmonicity, so the shorter probing duration means that these lower-energy
contributions are able to remain in the positive-$x$ plane as the higher-
energy contributions precess to the negative-$x$ plane at $t=\mathbf{T}/3$,
which is present as the positive-$x$ tail in the marginal probability
distribution shown in Fig. 12(a).

###  IV.2 Pendulum potential

The Hamiltonian of a physical pendulum is

$\displaystyle H(q=\phi,p=l)$
$\displaystyle=\frac{l^{2}}{2mb^{2}}-mb^{2}\omega_{0}^{2}\cos(\phi)$ (27)
$\displaystyle=-\frac{4\alpha\omega_{0}l^{2}}{\hbar}+\frac{\hbar\omega_{0}}{8\alpha}\cos(\phi),$

where $b$ is a length parameter, $\phi$ and $l$ are the angular coordinate and
angular momentum of the system, respectively, and
$\alpha:=-\hbar/8mb^{2}\omega_{0}\leq 0$ is the anharmonicity. A small value
of $\absolutevalue{\alpha}\ll 1$ allows for the usual approximation of the
pendulum as a harmonic oscillator. Apart from describing physical pendulums
and molecular interactions [19], this Hamiltonian also describes a
superconducting circuit without the small-angle approximation [18].

####  IV.2.1 Classical bounds

A pendulum with energy $E$ has the period [20]

$T(E)=\frac{4}{\omega_{0}}K\pqty{\frac{8\absolutevalue{\alpha}E/\hbar\omega_{0}+1}{2}},$
(28)

where $K(m)=\int_{0}^{\pi/2}\differential{u}(1-m\sin^{2}u)^{-1/2}$ is the
complete elliptic integral of the first kind.

The pendulum undergoes librations at large energies. However, the positions
observable along the $x$ and $y$ directions commute, and it is known that
commuting observables cannot exceed the classical score [4], so no quantum
violation of the protocol can be observed for librating states. Hence, we
limit ourselves to closed nonlibrating trajectories, which limits us to the
energy range $-1\leq 8\absolutevalue{\alpha}E/\hbar\omega_{0}<1$.

Since the potential is even, we have $\Delta t_{+}(E)=\Delta
t_{-}(E)=T_{0}(E)/2$ from Sec. III.4.1. The monotonicity of $K(m)$ within the
energy range under consideration simplifies Eq. (12) to

$\frac{3}{4}T_{0}(E_{\text{max}})\leq\mathbf{T}\leq\frac{3}{2}T_{0}(E_{\text{min}})\,.$
(29)

Although there is no closed-form expression for the inverse of $K(m)$, it can
nonetheless be computed to an arbitrary precision. In terms of $K^{-1}(m)$,
the energy bounds are

$\frac{2K^{-1}\pqty{\frac{\pi\tau}{3}}-1}{8\absolutevalue{\alpha}}\leq\frac{E_{\text{min}}}{\hbar\omega_{0}}\leq\frac{E}{\hbar\omega_{0}}\leq\frac{E_{\text{max}}}{\hbar\omega_{0}}\leq\frac{2K^{-1}\pqty{\frac{2\pi\tau}{3}}-1}{8\absolutevalue{\alpha}},$
(30)

where again $\mathbf{T}=:\tau\frac{2\pi}{\omega_{0}}$. The inclusion of the
classical ground state requires
$[2K^{-1}(\frac{\pi\tau}{3})-1]/8\absolutevalue{\alpha}\leq\hbar\omega_{0}/8\alpha\implies\tau\leq
3K(0)/\pi=\frac{3}{2}$. At the same time, the requirement $E_{\text{min}}\leq
E_{\text{max}}$ implies $\tau\geq 3K(0)/2\pi=\frac{3}{4}$. Once again, we
arrive at the restriction of the probing duration to the range
$\frac{3}{4}\leq\tau\leq\frac{3}{2}$.

####  IV.2.2 Quantized system

For the quantized system, the classical coordinates in the Hamiltonian are
replaced by the observables $\Phi$ and $L$, which are defined as

$\Phi=\int_{-\pi}^{\pi}\differential{\phi}\phi\outerproduct{\phi}{\phi},\quad
L=\sum_{m=-\infty}^{\infty}m\hbar\outerproduct{m}{m},$ (31)

with the resolution of the identity

$\int_{-\pi}^{\pi}\differential{\phi}\outerproduct{\phi}{\phi}=\sum_{m=-\infty}^{\infty}\outerproduct{m}{m}=\mathbbm{1}.$
(32)

We take the range $\phi\in(-\pi,\pi]$ for the angular coordinate. The angular
wave function of the angular momentum eigenstate is
$\innerproduct{\phi}{m}=e^{im\phi}/\sqrt{2\pi}$, with which it can be verified
that $\Phi$ and $L$ satisfy the Weyl relation ${e^{im\Phi}}{e^{i\phi
L/\hbar}}=e^{-im\phi}{e^{i\phi L/\hbar}}{e^{im\Phi}}$.

In the angular coordinate basis, the Schrödinger equation of the energy
eigenstates reads

$\pqty{4\alpha\frac{d^{2}}{d\phi^{2}}+\frac{1}{8\alpha}\cos(\phi)}\innerproduct{\phi}{E_{n}}=\frac{E_{n}}{\hbar\omega_{0}}\innerproduct{\phi}{E_{n}},$
(33)

which admits Mathieu functions that are $2\pi$ periodic in $\phi$ as
solutions, with the parameter $-1/(4\alpha)^{2}$ and characteristic values
$E_{n}/\hbar\omega_{0}\absolutevalue{\alpha}$ [19]. The eigenenergies are
ordered $E_{0}<E_{1}<\cdots<E_{n}<\cdots$, with the associated wave function

$\innerproduct{\phi}{E_{n}}=\begin{cases}\frac{1}{\sqrt{\pi}}\operatorname{ce}_{n}\pqty{\phi/2,-1/(4\alpha)^{2}}&\text{for
$n$ even}\\\
\frac{1}{\sqrt{\pi}}\operatorname{se}_{n+1}\pqty{\phi/2,-1/(4\alpha)^{2}}&\text{for
$n$ odd,}\end{cases}$ (34)

where $\operatorname{ce}$ and $\operatorname{se}$ are the Mathieu functions.
For brevity, we exclude the Mathieu function parameter $-1/(4\alpha)^{2}$ for
the rest of this section. The matrix elements of $Q_{3}$ are found using Eq.
(17) to be

$\matrixelement{E_{n}}{Q_{3}}{E_{n^{\prime}}}=\begin{cases}\displaystyle\frac{\operatorname{ce}_{n}(\tfrac{\pi}{2})\operatorname{se}^{\prime}_{n^{\prime}+1}(\tfrac{\pi}{2})-\operatorname{ce}_{n}(0)\operatorname{se}^{\prime}_{n^{\prime}+1}(0)}{3\pi\pqty{E_{n}/\hbar\omega_{0}-E_{n^{\prime}}/\hbar\omega_{0}}}2\alpha\pqty{1+e^{i\tau\theta_{n,n^{\prime}}}+e^{i2\tau\theta_{n,n^{\prime}}}}&\text{for
$n$ even, $n^{\prime}$ odd}\\\\[8.61108pt] \text{as above with
$n\leftrightarrow n^{\prime}$}&\text{for $n$ odd, $n^{\prime}$
even}\\\\[4.30554pt]
\displaystyle\frac{1}{2}\delta_{n,n^{\prime}}&\text{otherwise.}\end{cases}$
(35)

where $\theta_{n,n^{\prime}}=2\pi(E_{n}-E_{n^{\prime}})/3\hbar\omega_{0}$ and
$\operatorname{se}^{\prime}(x)=\frac{d}{dx}\operatorname{se}(x)$.

####  IV.2.3 Quantum violation

The maximum quantum score against anharmonicity is plotted in Fig. 13 for both
$\tau=1$ and the score maximized over $\frac{3}{4}\leq\tau\leq\frac{3}{2}$.
The behavior is qualitatively similar to Fig. 7 for small anharmonicities, in
that there is a general trend for the quantum score to decrease as the
magnitude of the anharmonicity increases. However, for $\alpha<-0.02$, we find
that larger scores, compared to the Kerr nonlinear system, can occur for the
pendulum. This is expected, as the contribution of the higher-order terms of
$\alpha$ can no longer be neglected as $\absolutevalue{\alpha}$ gets larger,
resulting in more significant deviations between the two types of dynamics.

Another difference to note is that there is no longer a violation at
$\alpha<-0.08$ for the pendulum, while the Kerr nonlinear system can still
beat the classical bound at $\alpha\sim-0.1$. This is largely due to the
energy bounds: For the same value of anharmonicity, the energy bounds in Eq.
(29) result in a much smaller subspace for the pendulum potential than the
truncation for the Kerr nonlinear system.

Figure 13: For the pendulum, the maximum quantum score against anharmonicity,
for $\tau=1$ and the score maximized over
$\frac{3}{4}\leq\tau\leq\frac{3}{2}$. The behavior is similar to that in Fig.
7, although it deviates as the magnitude of the anharmonicity becomes large.

####  IV.2.4 Comparison with the harmonic approximation

Upon expanding the quantized version of Eq. (27) up to the fourth order in
$\Phi$, defining the annihilation operator
$a:=\Phi/\sqrt{8\absolutevalue{\alpha}}+i\sqrt{8\absolutevalue{\alpha}}L/\hbar$,
and performing the rotating-wave approximation [18], we recover Eq. (18). The
anharmonicity defined for the pendulum corresponds exactly to the $\alpha$ in
Eq. (18). Here the anharmonicity is always nonpositive, with a weaker
anharmonicity corresponding to a larger amplitude of the potential.

The comparison with the harmonic approximation performed in Sec. IV.1.4 for
the Kerr nonlinearity is repeated for the pendulum potential in Appendix A.1.
For the values of anharmonicity considered, the results agree with what was
obtained for the Kerr nonlinear systems, and the optimal states are similar in
both cases. However, we notice that the quantum scores are slightly smaller
for the pendulum than the Kerr nonlinear system at $\alpha\sim-0.02$. This is
as we observed with the full range of anharmonicities in Fig. 7, where the
quantum scores begin to diverge between the two cases as
$\alpha\lesssim-0.02$.

###  IV.3 Morse potential

So far, the systems we have studied are even and their trajectories are closed
orbits. Our protocol is general enough that these are not conditions necessary
for the procedure to work, as we will encounter in this section.

The Morse potential is used to model molecular interactions, which also takes
into consideration the effects of bond breaking [21]. The Hamiltonian with the
Morse potential is given by

$\displaystyle H(x,p)$
$\displaystyle=\frac{p^{2}}{2m}+D_{e}\pqty{1-e^{cx}}^{2},$ (36)

where $D_{e}$ is the dissociation energy and $c$ is a length scale. Note that
the potential as defined here differs from the usual convention in two ways:
The origin is placed at the equilibrium position $x_{0}$ so that $x_{0}=0$ and
the coordinates have been flipped from $x\to-x$ so that the particle escapes
to $x\to-\infty$ upon dissociation. This was done to put Eq. (6) in its
standard form. The same physics would be obtained by keeping the usual
convention for the potential and using $\Pr[x(t)<x_{0}]$ in place of
$\Pr[x(t)>0]$ in Eq. (6).

####  IV.3.1 Classical bounds

Classically, the solution for $E<D_{e}$ with the initial condition $p(t=0)=0$
is [22]

$x(t)=\frac{1}{c}\log{\frac{1-E/D_{e}}{1-\sqrt{E/D_{e}}\cos[{2\pi
t}/{T_{0}(E)}]}},$ (37)

where the period $T_{0}(E)$ is given by

$T_{0}(E)=\frac{2\pi/\omega_{0}}{\sqrt{1-E/D_{e}}},$ (38)

where we have defined the natural frequency
$\omega_{0}:=\sqrt{2D_{e}c^{2}/m}$. An expression similar to Eq. (37) exists
for $E>D_{e}$. However, in that case, the particle escapes to $x\to-\infty$,
so the period is taken to be $T_{0}(E)=\infty$. Hence, the times that the
particle remains in the positive and negative regions are, respectively,

$\displaystyle\Delta t_{-}(E)$
$\displaystyle=\begin{cases}\frac{2\pi-2\acos\sqrt{E/D_{e}}}{\omega_{0}\sqrt{1-E/D_{e}}}&\text{for
$E<D_{e}$}\\\ \infty&\text{for $E\geq D_{e}$,}\end{cases}$ (39)
$\displaystyle\Delta t_{+}(E)$
$\displaystyle=\begin{cases}\frac{2\acos\sqrt{E/D_{e}}}{\omega_{0}\sqrt{1-E/D_{e}}}&\text{for
$E<D_{e}$}\\\ \frac{2}{\omega_{0}}&\text{for $E=D_{e}$}\\\
\frac{2\operatorname{arccosh}\\!\sqrt{E/D_{e}}}{\omega_{0}\sqrt{E/D_{e}-1}}&\text{for
$E>D_{e}$.}\end{cases}$ (40)

Therefore, $\min_{E}\Delta t_{-}(E)=\pi/\omega_{0}$ and $\max_{E}\Delta
t_{+}(E)=\pi/\omega_{0}$ for all possible values of $E$. Notice how $\Delta
t_{\pm}(E)$ is exactly the same as for the harmonic oscillator. Therefore, for
a system with the Morse potential, we can perform the original protocol
without modification.

####  IV.3.2 Quantized system

In the quantum case, the bound eigenstates are exactly solvable [21], with the
energy eigenvalues

$E_{n}=\hbar\omega_{0}\pqty{n+\frac{1}{2}}\pqty{1-\frac{1}{2\lambda}\pqty{n+\frac{1}{2}}}$
(41)

for $n=0,1,\dots,\lfloor\lambda-\frac{1}{2}\rfloor$, where we have defined
$\lambda:=2D_{e}/\hbar\omega_{0}$ for notational convenience. The
corresponding wave functions and their derivatives are [23]

$\displaystyle\innerproduct{x}{E_{n}}$
$\displaystyle=\sqrt{\frac{cn!\pqty{2\lambda-2n-1}}{\pqty{2\lambda-n-1}!}}\pqty{2\lambda
e^{cx}}^{\lambda-n-1/2}e^{-\lambda e^{cx}}$ (42)
$\displaystyle\quad{}\times{}L_{n}^{(2\lambda-2n-1)}\\!\pqty{2\lambda
e^{cx}},$ $\displaystyle\frac{d}{dx}\innerproduct{x}{E_{n}}$
$\displaystyle=c\bqty{\pqty{\lambda-n-\frac{1}{2}}-\frac{\lambda^{2}e^{cx}}{\lambda-n}}\innerproduct{x}{E_{n}}$
(43) $\displaystyle\quad{}-{}\frac{c\lambda
e^{cx}}{\lambda-n}\sqrt{\frac{n(2\lambda-n)(\lambda-n-\frac{1}{2})}{\lambda-n+\frac{1}{2}}}\innerproduct{x}{E_{n-1}}.$

Here $L_{n}^{(\alpha)}\\!(z)=\sum_{k=0}^{n}(-1)^{k}\spmqty{z^{k}}/{k!}$ are
the generalized Laguerre polynomials. Placing Eq. (43) into Eq. (17), the
matrix elements of $\operatorname{sgn}(X)$ for $n\neq n^{\prime}$ can be found
to be

$\displaystyle\matrixelement{E_{n}}{\operatorname{sgn}(X)}{E_{n^{\prime}}}=\frac{2}{c\pqty{n-n^{\prime}}\pqty{2\lambda-(1+n+n^{\prime})}}\Bigg{\\{}$
$\displaystyle-(n-n^{\prime})\pqty{1+\frac{\lambda^{2}}{(\lambda-n)(\lambda-n^{\prime})}}\innerproduct{E_{n}}{0_{x}}\\!\innerproduct{0_{x}}{E_{n^{\prime}}}$
(44)
$\displaystyle\quad{}-{}\frac{\lambda}{\lambda-n}\sqrt{\frac{n(2\lambda-n)(\lambda-n-\frac{1}{2})}{\lambda-n+\frac{1}{2}}}\innerproduct{E_{n-1}}{0_{x}}\\!\innerproduct{0_{x}}{E_{n^{\prime}}}$
$\displaystyle\quad{}+{}\frac{\lambda}{\lambda-n^{\prime}}\sqrt{\frac{n^{\prime}(2\lambda-n^{\prime})(\lambda-n^{\prime}-\frac{1}{2})}{\lambda-n^{\prime}+\frac{1}{2}}}\innerproduct{E_{n}}{0_{x}}\\!\innerproduct{0_{x}}{E_{n^{\prime}-1}}\Bigg{\\}},$

where $\ket{0_{x}}=\ket{x=0}$. Meanwhile, the diagonal elements are

$\matrixelement{E_{n}}{\operatorname{sgn}(X)}{E_{n}}=\frac{4\pqty{2\lambda}^{2\lambda-2n-1}e^{-2\lambda}P^{n}(\lambda)}{(2\lambda-n-1)!}\pqty{2\lambda-2n-1}+2Q(2\lambda-2n-1,2\lambda)-1,$
(45)

where $Q(a,x)=\int_{x}^{\infty}\differential{t}t^{a-1}e^{-t}/(a-1)!$ is the
regularized $\Gamma$ function and $P^{n}(\lambda)$ is a polynomial of degree
$n-1$ given in Eq. (59).

The coefficients of $P^{n}(\lambda)$ grow large with $n$ very quickly, which
results in some difficulty in computing higher-order matrix elements of
$\operatorname{sgn}(X)$ due to the numerical instability. Hence, we consider
only the comparison with the harmonic approximation performed in the weak-
anharmonicity and low-energy regime for the Morse potential. For this reason,
we will also ignore the free-particle solutions within the continuous spectrum
of the Hamiltonian that only occur for large energies with $E>D_{e}$.

####  IV.3.3 Comparison with the harmonic approximation

We repeat the study performed in Sec. IV.1.4 for the Morse potential in
Appendix A.2. While we again find that the quantum score approaches the
harmonic case as $\alpha\to 0$, the same score requires anharmonicities that
are an order of magnitude smaller here compared to the previous cases. This is
due to the shape of the Morse potential, where $\lim_{x\to-\infty}V(x)=D_{e}$
is finite in comparison to $\lim_{x\to\infty}V(x)=\infty$, so the particle is
much less effectively trapped from the negative-$x$ direction. Therefore, the
Morse potential needs to be much deeper, hence less anharmonic, to confine the
particle as effectively as the other potentials.

###  IV.4 Particle in an infinite well

Although the particle in an infinite well exhibits pathological behaviors in
both the classical (phase-space trajectories are not continuous) and quantum
(momentum operator is not self-adjoint) cases, this toy model serves to
illustrate the generality of the protocol. We show how the procedure laid out
in Sec. III.4 can be applied to this system, even when the particle in an
infinite well is not approximately harmonic at small energies.

Its Hamiltonian is usually written as

$H(x,p)=\frac{p^{2}}{2m}+V(x),\qquad V(x)=\begin{cases}0&\text{if
$\absolutevalue{x}\leq L/2$}\\\ \infty&\text{otherwise.}\end{cases}$ (46)

The quantized Hamiltonian is obtained with a direct replacement $x\to X$ and
$p\to P$. In the classical and quantum cases, the trajectories and wave
functions, respectively, have support only within the range $x\in[-L/2,L/2]$,
where $x$ is the position and $L$ is the length of the well.

####  IV.4.1 Classical bounds

Apart from the fixed points $(x(t),p(t))=(x(0),0)$, every classical trajectory
is closed and passes the position $x=-L/2$. Since every other classical state
can be obtained by an offset $t\to t-t_{0}$, without any loss of generality,
we only need to consider the trajectories with $x(0)=-L/2$. These trajectories
are uniquely specified by the energy $E=p^{2}/2m$, and their position in time
is

$x(t)=-\frac{L}{2}+\operatorname{sgn}\bqty{\sin(\frac{2\pi
t}{T_{0}(E)})}\sqrt{\frac{m}{2E}}\pqty{t\bmod\frac{T_{0}(E)}{2}},$ (47)

where the period of oscillation is

$T_{0}(E)=\sqrt{\frac{2m}{E}}L=:\frac{2\pi/\omega_{0}}{\sqrt{E/\hbar\omega_{0}}}.$
(48)

For later convenience, we define the natural frequency of the system as
$\omega_{0}:=2\pi^{2}\hbar/mL^{2}$.

To find $\Delta_{\pm}(E)$, we notice that the potential $V(x)$ is even, so
Sec. III.4.1 implies

$\Delta t_{+}(E)=\Delta
t_{-}(E)=\frac{2\pi/\omega_{0}}{2\sqrt{E/\hbar\omega_{0}}}.$ (49)

When performing the protocol with $\mathbf{T}=:\tau\frac{2\pi}{\omega_{0}}$,
the energy bounds that satisfy the condition in Eq. (12) for $\tau$ are

$\frac{9}{16\tau^{2}}\leq\frac{E_{\text{min}}}{\hbar\omega_{0}}\leq\frac{E}{\hbar\omega_{0}}\leq\frac{E_{\text{max}}}{\hbar\omega_{0}}\leq\frac{9}{4\tau^{2}}.$
(50)

Figure 14: For the infinite well, plot of $\mathbf{P}_{3}^{\infty}$ against
$\tau^{-1}$. There is no violation for all values of $\tau>\frac{1}{3}$, while
all values of $\tau<\frac{3}{16}$ violate the classical bound.

####  IV.4.2 Quantized system

The solutions for the quantum particle in an infinite well are well known to
be

$E_{n}=\pqty{\frac{n}{2}}^{2}\hbar\omega_{0},\quad\innerproduct{x}{E_{n}}=\begin{cases}\sqrt{\frac{2}{L}}\cos(\frac{n\pi}{L}x)&\text{$n$
odd}\\\ \sqrt{\frac{2}{L}}\sin(\frac{n\pi}{L}x)&\text{$n$ even,}\end{cases}$
(51)

where $n\geq 1$ and $\omega_{0}$ is as previously defined. Hence, we can
obtain the matrix elements for $Q_{3}$ using Eq. (17),

$\matrixelement{E_{n}}{Q_{3}}{E_{n^{\prime}}}=\begin{cases}\displaystyle\frac{1}{2}\delta_{n,n^{\prime}}&\text{if
$(n-n^{\prime})\bmod 2=0$}\\\\[4.30554pt] \frac{1+e^{i(n^{2}-n^{\prime
2})({\pi\tau}/{6})}+e^{i(n^{2}-n^{\prime
2})({2\pi\tau}/{6})}}{3}\frac{1}{\pi}\pqty{\frac{1}{n+n^{\prime}}+\frac{(-1)^{n\bmod
2}}{n-n^{\prime}}}&\text{otherwise.}\end{cases}$ (52)

Meanwhile, rewriting Eq. (50) in terms of $n$,

$\frac{3}{2\tau}<n<\frac{3}{\tau}.$ (53)

Therefore, we can construct the matrix for $Q_{3}$ explicitly with the
truncation given in Eq. (53) to find $\mathbf{P}_{3}^{\infty}$.

Figure 15: For the infinite well, Wigner functions and probability densities
of the optimal state for (a) $\tau=\frac{1}{3}$ and (b) $\tau=\frac{1}{30}$ at
the three different probing times. The interference patterns of the Wigner
function in the latter case are intricate (they can be seen more clearly in
the probability distributions), but the working principle is similar to the
former case. The probability densities at times $0$ and $2\mathbf{T}/3$
overlap in both cases. Just like in Fig. 4, the quantum score is augmented by
the positive-$x$ tail when the state is mostly in the negative-$x$ axis.

####  IV.4.3 Quantum violation

The maximum quantum score $\mathbf{P}_{3}^{\infty}$ is plotted against the
inverse of the probing duration $\tau^{-1}$ in Fig. 14. Two particular regions
of $\tau$ are also highlighted: There is no violation for all values of
$\tau>\frac{1}{3}$, while all values of $0<\tau<\frac{3}{16}$ violate the
classical bound.

The probability distributions of the optimal states are plotted in Fig. 15 for
$\tau=\frac{1}{3}$ and $\tau=\frac{1}{30}$. Their behavior is reminiscent of
Fig. 4: A violation of the classical bound is achieved by having a small but
consequential contribution from the positive-$x$ tail of the state when most
of the state is concentrated on the negative-$x$ axis.

Similar states known as ultraslow states have been studied in the context of
the quantum projectile [2]. Equation (50) constrains the speed of the particle
so that it should only travel a distance of $L/2\leq\Delta x\leq L$ between
successive probing times. However, the positive-$x$ tail shows that there is a
nonzero probability of the particle traveling much slower and remaining in the
positive-$x$ axis (hence ultraslow), increasing the quantum score.

##  V Conclusion

Dynamics-based certification of quantumness is a witness of nonclassicality
for continuous-variable systems, based on the assumption that the dynamics is
known. It was previously introduced for the harmonic oscillator [3, 4]. In
this paper we have extended the protocol to time-independent Hamiltonians. We
have characterized the generic conditions under which a classical-quantum gap
is expected and have explicitly worked out four examples: an anharmonic
oscillator, a pendulum (where one of the conjugate variables is compact and
therefore the other has a discrete spectrum), an asymmetric potential with
open orbits, and a system that cannot be approximated as harmonic even at low
energies. While we have placed our focus on the certification of
nonclassicality in the context of quantum theory, we note that the protocol
and its classical bounds depend only on measuring position, bounding energy,
and the requirement that the Hamiltonian is the generator of time evolution.
So the study could carry over to more general theories that uphold those
features [24], possibly with a different degree of violation of the classical
bound.

With an eye on experimental implementations, we have shown that the original
harmonic protocol is robust to weak anharmonicity in the low-energy regime;
simple modifications like adjusting the probing time can already provide
significant improvements. For example, transmon qubits are engineered to be
weakly anharmonic with $\absolutevalue{\alpha}\ll 1$ [18] and the state space
$\\{\ket{n}\\}_{n=0}^{\infty}$ is restricted to $n\ll n_{\text{crit}}$ for
some critical photon number in the dispersive regime [25], which are exactly
the conditions we have considered. Similar conditions and approximations are
also found in a wide variety of optical systems, ranging from nonlinear fibers
[26] to optomechanics [27].

A possible generalization to this protocol would be to use probing times
$\\{0,t_{1},t_{2}\\}$ that are not equally spaced, as considered in the
Tsirelson paper [3] for the harmonic case. This requires updating the
classical condition in Eq. (12) to $\max_{E}\Delta t_{+}(E)\leq t_{2}$ and
$t_{1}\leq\min_{E}\Delta t_{-}(E)$. The rest of the protocol proceeds
analogously. One could also use more than three probing times, although this
may not be beneficial: For uniform precessions, this was found to decrease the
classical-quantum gap [4].

Additionally, the protocol readily extends itself to multiple degrees of
freedom. Equations (9) and (8) make reference only to the measured observable
$q$, and would more generally quantify how long the state remains in the
positive or negative regions of $q$ in a higher-dimensional phase space. Since
that is enough to specify the classical score, the condition in Eq. (10)
maintains $\mathbf{P}_{3}^{c}=\frac{2}{3}$. Therefore, barring the
simplifications at the end of the section that are specific to systems with a
single degree of freedom, the procedure laid out in Sec. III can still be used
for systems with multiple degrees of freedom.

In this paper we have taken the dynamics of the system as given and studied
the protocol for what we believe to be a reasonable choice of the generalized
coordinate $q$. This determines the states, whose nonclassicality can be
detected. Conversely, one’s goal may be to detect the nonclassicality of a
given state: Then one would look for the coordinate $q$ for a given $H$, with
which the classical bound can be violated for that state, or even better
optimize $H$ for that task. In particular, it remains an open question whether
initial states with a positive Wigner function can violate the classical bound
for some dynamics. For Hamiltonians that are at most quadratic in position and
momentum, like a free particle or the harmonic oscillator, the time evolutions
of both the classical probability distribution in phase space and the Wigner
function are exactly the same, which means that a negative Wigner function is
necessary for a violation of the classical bound. In those cases, this
protocol acts as a negativity witness for the state. For a general time-
independent Hamiltonian, while the canonical variables have the same time
evolution for both the classical and quantum cases, the states might not. As
such, it is not clear if Wigner negativity is still a necessary condition for
a violation of the classical bound or if some Hamiltonians enable dynamics-
based certification of quantumness of Wigner positive states or even Gaussian
states.

## Acknowledgments

This research was supported by the National Research Foundation, Singapore and
A*STAR under its CQT Bridging Grant.

## References

  * Bracken and Melloy [1994] A. J. Bracken and G. F. Melloy, Probability backflow and a new dimensionless quantum number, J. Phys. A: Math. Gen. 27, 2197 (1994).
  * Trillo  _et al._ [2023] D. Trillo, T. P. Le, and M. Navascués, Quantum advantages for transportation tasks - projectiles, rockets and quantum backflow, npj Quantum Inf. 9, 69 (2023).
  * [3] B. Tsirelson, How often is the coordinate of a harmonic oscillator positive?, arXiv:quant-ph/0611147 .
  * Zaw  _et al._ [2022] L. H. Zaw, C. C. Aw, Z. Lasmar, and V. Scarani, Detecting quantumness in uniform precessions, Phys. Rev. A 106, 032222 (2022).
  * Jayachandran  _et al._ [2023] P. Jayachandran, L. H. Zaw, and V. Scarani, Dynamics-Based Entanglement Witnesses for Non-Gaussian States of Harmonic Oscillators, Phys. Rev. Lett. 130, 160201 (2023).
  * Gilchrist  _et al._ [1998] A. Gilchrist, P. Deuar, and M. D. Reid, Contradiction of Quantum Mechanics with Local Hidden Variables for Quadrature Phase Amplitude Measurements, Phys. Rev. Lett. 80, 3169 (1998).
  * Banaszek and Wódkiewicz [1998] K. Banaszek and K. Wódkiewicz, Nonlocality of the Einstein-Podolsky-Rosen state in the Wigner representation, Phys. Rev. A 58, 4345 (1998).
  * Chen  _et al._ [2002] Z.-B. Chen, J.-W. Pan, G. Hou, and Y.-D. Zhang, Maximal Violation of Bell’s Inequalities for Continuous Variable Systems, Phys. Rev. Lett. 88, 040406 (2002).
  * Bose  _et al._ [2018] S. Bose, D. Home, and S. Mal, Nonclassicality of the Harmonic-Oscillator Coherent State Persisting up to the Macroscopic Domain, Phys. Rev. Lett. 120, 210402 (2018).
  * Mawby and Halliwell [2022] C. Mawby and J. J. Halliwell, Leggett-Garg tests for macrorealism in the quantum harmonic oscillator and more general bound systems, Phys. Rev. A 105, 022221 (2022).
  * Mawby and Halliwell [2023] C. Mawby and J. J. Halliwell, Leggett-Garg violations for continuous-variable systems with Gaussian states, Phys. Rev. A 107, 032216 (2023).
  * [12] D. Das, D. Home, H. Ulbricht, and S. Bose, Mass-independent test of quantumness of a massive object, arXiv:2211.10318 .
  * Arnold [1978] V. I. Arnold, Mathematical methods of classical mechanics (Springer, New York, 1978) pp. 98–122.
  * Weyl [1950] H. Weyl,  _The Theory of Groups and Quantum Mechanics_ (Dover, Mineola, 1950).
  * Rigas  _et al._ [2011] I. Rigas, L. Sánchez-Soto, A. Klimov, J. Řeháček, and Z. Hradil, Orbital angular momentum in phase space, Ann. Phys. (N.Y.) 326, 426 (2011).
  * Moyal [1949] J. E. Moyal, Quantum mechanics as a statistical theory, Math. Proc. Cambridge Philos. Soc. 45, 99–124 (1949).
  * Boyd [2020] R. W. Boyd,  _Nonlinear Optics_ , 4th ed. (Academic, New York, 2020).
  * Krantz  _et al._ [2019] P. Krantz, M. Kjaergaard, F. Yan, T. P. Orlando, S. Gustavsson, and W. D. Oliver, A quantum engineer’s guide to superconducting qubits, Appl. Phys. Rev. 6, 021318 (2019).
  * Baker  _et al._ [2002] G. L. Baker, J. A. Blackburn, and H. J. T. Smith, The quantum pendulum: Small and large, Am. J. Phys. 70, 525 (2002).
  * Goldstein [1965] H. Goldstein,  _Classical Mechanics_ (Addison-Wesley, Reading, 1965).
  * Morse [1929] P. M. Morse, Diatomic Molecules According to the Wave Mechanics. II. Vibrational Levels, Phys. Rev. 34, 57 (1929).
  * Slater [1957] N. B. Slater, Classical motion under a morse potential, Nature 180, 1352 (1957).
  * Dong  _et al._ [2002] S.-H. Dong, R. Lemus, and A. Frank, Ladder operators for the morse potential, Int. J. Quantum Chem. 86, 433 (2002).
  * Branford  _et al._ [2018] D. Branford, O. C. O. Dahlsten, and A. J. P. Garner, On Defining the Hamiltonian Beyond Quantum Theory, Found. Phys. 48, 982 (2018).
  * Blais  _et al._ [2021] A. Blais, A. L. Grimsmo, S. M. Girvin, and A. Wallraff, Circuit quantum electrodynamics, Rev. Mod. Phys. 93, 025005 (2021).
  * Caglioti  _et al._ [1988] E. Caglioti, B. Crosignani, and P. Di Porto, Hamiltonian description of nonlinear propagation in optical fibers, Phys. Rev. A 38, 4036 (1988).
  * Gong  _et al._ [2009] Z. R. Gong, H. Ian, Y.-x. Liu, C. P. Sun, and F. Nori, Effective Hamiltonian approach to the Kerr nonlinearity in an optomechanical system, Phys. Rev. A 80, 065801 (2009).

##  Appendix A Comparisons to the harmonic approximation

We repeat the study of the protocol in the comparison to the harmonic
approximation, reported in Sec. IV.1.4 for the Kerr-nonlinear system, with
both the pendulum (Sec. IV.2) and Morse potentials (Sec. IV.3). We consider
low-energy states of the form $\sum_{n\leq\mathbf{n}}\psi_{n}\ket{E_{n}}$ and
weak anharmonicities with $\absolutevalue{\alpha}\ll 1$.

For both systems, the Hamiltonian approaches that of the harmonic oscillator
as $\alpha\to 0$. At this limit,

$\ket{\Psi_{6}}=\frac{1}{\sqrt{2}}\pqty{\frac{4}{\sqrt{21}}\ket{E_{0}}-\ket{E_{3}}+\sqrt{\frac{5}{21}}\ket{E_{6}}}$
(54)

is the optimal state that achieves the largest quantum score $P_{3}=0.687$ for
$n\leq\mathbf{n}=6$ and $\tau=1$, while

$\displaystyle\ket{\Psi_{4}}$
$\displaystyle=\sqrt{0.279}\ket{E_{0}}+\sqrt{0.191}\ket{E_{1}}e^{-i\theta_{4}}+\sqrt{0.121}\ket{E_{2}}e^{-i2\theta_{4}}$
(55)
$\displaystyle\quad{}+{}\sqrt{0.309}\ket{3}e^{-i3\theta_{4}}+\sqrt{0.100}\ket{E_{4}}e^{-i4\theta_{4}},$

with $\theta_{4}=0.215\pi$, achieves the largest quantum score $P_{3}=0.669$
for $n\leq\mathbf{n}=4$ and $\tau=1.774$.

In this low-energy regime, we study the following three scenarios.

(i) Under the truncation $\mathbf{n}=6$ ($\mathbf{n}=4$), we find the optimal
state $\ket{\Psi}$ and time $\tau$ that violates the classical bound
maximally. This fully takes into account the anharmonicity of the system.

(ii) We use the state $\ket{\Psi_{6}}$ ($\ket{\Psi_{4}}$) and find the optimal
$\tau$. This only corrects for the change in the period of the state caused by
the anharmonicity.

(iii) We use the state $\ket{\Psi_{6}}$ and $\tau=1$ ($\ket{\Psi_{4}}$ and
$\tau=1.774$). This ignores the anharmonicity of the system completely.

###  A.1 Pendulum potential

For the pendulum potential, we plot the three scenarios with the low-energy
states with truncations $\mathbf{n}=6$ (Fig. 16) and $\mathbf{n}=4$ (Fig. 17).
As mentioned in the main text, the results here agree with what was previously
obtained, although they begin to deviate as $\alpha\sim-0.02$. The optimal
states obtained are also similar, as illustrated with the Wigner functions
plotted in Fig. 18.

Figure 16: Same as Fig. 9 but for the pendulum, for low-energy states with
truncation $\mathbf{n}=6$. (a) Score $P_{3}$ as a function of the
anharmonicity $\alpha$ for the three scenarios described above. (b) Optimal
$\tau$ used for scenarios (i) and (ii). Figure 17: Same as Fig. 11 but for the
pendulum, for low-energy states with truncation $\mathbf{n}=4$. (a) Score
$P_{3}$, optimized over $\tau$, plotted against $\alpha$ (b) Optimal $\tau$
that achieves the optimized quantum score. Figure 18: For the pendulum, the
angular Wigner function $W(\varphi,m)$ [15] and marginal probability density
of the optimal low-energy state at $\alpha=-0.02$ with truncation (a)
$\mathbf{n}=6$ and (b) $\mathbf{n}=4$. Note that the angular momentum $m\hbar$
only takes discrete values with integer $m$. These states have the same
features as Figs. 12 and 10.

###  A.2 Morse potential

The results for the Morse potential with truncation $\mathbf{n}=6$ is plotted
in Fig. 19. Note that the horizontal axis is an order of magnitude smaller
than those in Figs. 9 and 16, so a much weaker anharmonicity is required in
the Morse potential for a violation of the classical bound. For the truncation
$\mathbf{n}=4$, shown in Fig. 20, the anharmonicities are two orders of
magnitude smaller than those in Figs. 11 and 17. The Wigner functions of the
optimal state for both truncations $\mathbf{n}=6$ and $\mathbf{n}=4$ are shown
in Fig. 21.

Figure 19: Same as Fig. 9 but for the Morse potential, for low-energy states
with truncation $\mathbf{n}=6$. (a) Score $P_{3}$ as a function of $\alpha$
for the three scenarios. (b) Optimal $\tau$. Note that $\alpha$ is an order of
magnitude smaller than in Figs. 9 and 16. Figure 20: Same as Fig. 11 but for
the Morse potential, for low-energy states with truncation $\mathbf{n}=4$. (a)
Score $P_{3}$, optimized over $\tau$, is plotted against $\alpha$. (b) Optimal
$\tau$. Note that $\alpha$ is about two orders of magnitude smaller than in
Figs. 11 and 17. Figure 21: For the Morse potential, the Wigner function
$W(x,p)$ and marginal probability density of the optimal low-energy state at
(a) $\mathbf{n}=6$ and $\alpha=1.6\times 10^{-3}$ and (b) $\mathbf{n}=4$ and
$\alpha=2\times 10^{-4}$. These states have the same features as in Figs. 12
and 10, but there is far less negativity present.

##  Appendix B Diagonal Matrix Elements for the Morse potential

The diagonal matrix elements of $\operatorname{sgn}(X)$ for the Morse
potential is given by

$\displaystyle\matrixelement{E_{n}}{\operatorname{sgn}(X)}{E_{n}}$ (56)
$\displaystyle\quad{}={}\int_{0}^{\infty}\differential{x}\absolutevalue{\innerproduct{x}{E_{n}}}^{2}-\int_{-\infty}^{0}\differential{x}\absolutevalue{\innerproduct{x}{E_{n}}}^{2}$
$\displaystyle\quad{}={}1-2\frac{n!\pqty{2\lambda-2n-1}}{\pqty{2\lambda-n-1}!}$
$\displaystyle\qquad\quad{}\times{}\int_{0}^{2\lambda}\differential{z}z^{2\lambda-2n-2}e^{-z}\pqty{L_{n}^{(2\lambda-2n-1)}\\!(z)}^{2},$

where the integration variable was changed to $z=2\lambda e^{cx}$ and
$L_{n}^{(\alpha)}\\!(z)=\sum_{k=0}^{n}(-1)^{k}\spmqty{z^{k}}/{k!}$ are the
generalized Laguerre polynomials. The integral can be worked out by using the
explicit form of Laguerre polynomials and the definition of the regularized
$\Gamma$ function

$\displaystyle\frac{1}{(2\lambda-2n-2+k)!}\int_{0}^{2\lambda}\differential{z}z^{2\lambda-2n-2+k}e^{-z}$
(57) $\displaystyle\qquad{}={}1-Q(2\lambda-2n-1+k,2\lambda),$

which satisfy the recursive relation

$Q(\alpha+k,2\lambda)=Q(\alpha+(k-1),2\lambda)+\frac{(2\lambda)^{\alpha+(k-1)}}{[\alpha+(k-1)]!}e^{-2\lambda},$
(58)

with which the above integral can be simplified to the form given in Eq. (45).
The first few polynomials $P^{n}(\lambda)$ are given in Eq. (59). However,
because the size of the coefficients grows large very quickly, we were only
able to compute the matrix elements of $\operatorname{sgn}(X)$ for the weak
anharmonicity and low-energy regime:

$\displaystyle P^{0}(\lambda)$ $\displaystyle=0,$ (59a) $\displaystyle
P^{1}(\lambda)$ $\displaystyle=1,$ (59b) $\displaystyle P^{2}(\lambda)$
$\displaystyle=6+2\lambda,$ (59c) $\displaystyle P^{3}(\lambda)$
$\displaystyle=180-42\lambda+\frac{32}{2}\lambda^{2},$ (59d) $\displaystyle
P^{4}(\lambda)$
$\displaystyle=6440-\frac{5828}{3}\lambda+190\lambda^{2}+\frac{58}{3}\lambda^{3},$
(59e) $\displaystyle P^{5}(\lambda)$
$\displaystyle=347\,760-140\,604\lambda+\frac{102\,376}{5}\lambda^{2}-\frac{4912}{5}\lambda^{3}+\frac{212}{3}\lambda^{4},$
(59f) $\displaystyle P^{6}(\lambda)$
$\displaystyle=32\,802-\frac{450\,763}{30}\lambda+\frac{372\,931}{150}\lambda^{2}-\frac{215\,779}{1350}\lambda^{3}+\frac{31\,411}{8100}\lambda^{4}+\frac{19}{108}\lambda^{5},$
(59g) $\displaystyle P^{7}(\lambda)$
$\displaystyle=1\,979\,385\,408-\frac{4\,965\,563\,888}{5}\lambda+\frac{6\,608\,820\,632}{35}\lambda^{2}-\frac{5\,199\,530\,008}{315}\lambda^{3}+\frac{73\,504\,376}{105}\lambda^{4}-\frac{553\,792}{45}\lambda^{5}+\frac{1192}{3}\lambda^{6}.$
(59h)