Thermodynamics along individual trajectories of a quantum bit %\hspace{1in
M. Naghiloo
D. Tan
P. M. Harrington
J. J. Alonso
E. Lutz
A. Romito
K. W. Murch
We use a near-quantum-limited detector to experimentally track individual quantum trajectories of a driven qubit formed by the hybridization of a waveguide cavity and a transmon circuit. For each measured quantum coherent trajectory, we separately identify energy changes of the qubit as heat and work, and verify the first law of thermodynamics for an open quantum system. We further employ a novel quantum feedback loop to compensate for the exchanged heat and effectively isolate the qubit. By verifying a generalized Jarzynski equality for the distribution of applied work, we demonstrate the validity of the second law of thermodynamics. Our results establish thermodynamics along individual quantum trajectories.
arxiv_Naghiloo.tex
%\documentclass[prb,preprint]{revtex4}
\documentclass[prl,twocolumn,english,superscriptaddress,floatfix]{revtex4}
%\documentclass[prb,preprint,english,superscriptaddress,floatfix]{revtex4}
%\documentclass[prb,preprint,english,superscriptaddress]{revtex4}
%\documentclass[prb,preprint, superscriptaddress,floatfix]{revtex4}
%\documentclass[prb,preprint,english,superscriptaddress,floatfix]{revtex4-1}
%\documentclass[prb,twocolumn,english,superscriptaddress,floatfix]{revtex4-1}
%
\usepackage{graphicx}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{pdfpages}
%\usepackage{babel}
\usepackage{verbatim}
\usepackage{lipsum}
%\usepackage{times}

\usepackage{color,soul}
\setulcolor{red} %set underlining color
\setstcolor{red} %set overstriking color
\sethlcolor{yellow} % set highlighting color
%\so{letterspacing} l e t t e r s p a c i n g
%\caps{CAPITALS, Small Capitals} CAPITALS, Small Capitals
%\ul{underlining} underlining
%\st{overstriking} overstriking
%\hl{highlighting} highlighting
\newcommand{\aleadd}[1]{{\color{purple} #1}}
%
%\def\dbar{{\mathchar'26\mkern-12mu d}}
%\def\dbar{{\mathchar'26\mkern-12mu\text{d}}}
\def\dbar{{\delta}}
\def\tr{\mathrm{tr}}
\newcommand{\nbar}[0]{\bar{n}}
\newcommand{\qlin}[0]{Q_\textrm{lin}}
\newcommand{\qext}[0]{Q_\textrm{\small{ext}}}
\newcommand{\qint}[0]{Q_\textrm{\small{int}}}
\newcommand{\pin}[0]{P_\textrm{\small{in}}}
\newcommand{\adag}[0]{a^\dagger}
\newcommand{\omegr}[0]{\omega_0}
\newcommand{\Oq}[0]{\omega_\textrm{q}}
\newcommand{\sigz}[0]{\sigma_z}
\newcommand{\sigp}[0]{\sigma_+}
\newcommand{\sigm}[0]{\sigma_-}
\newcommand{\x}[0]{\mathrm{X}}
\newcommand{\y}[0]{\mathrm{Y}}
\newcommand{\z}[0]{\mathrm{Z}}
\newcommand{\pii}[0]{\rho_{11}}
\newcommand{\poi}[0]{\rho_{01}}
\newcommand{\poo}[0]{\rho_{00}}
\newcommand{\pio}[0]{\rho_{10}}
\newcommand{\op}[1]{\hat{ #1}}                % Operator
\def\be{\begin{equation}}
\def\ee{\end{equation}}
\def\bea{\begin{eqnarray}}
\def\eea{\end{eqnarray}}
\def\la{\langle}
\def\ra{\rangle}
\def\l{\langle\!\langle}
\def\r{\rangle\!\rangle}
\def\cur{\mathcal{I}}

\newcommand{\longdivide}[2]{\ensuremath{#1)\! \! \overline{\ #2}}}
\newcommand{\longdividest}[2]{\ensuremath{#1 | \! \overline{\thinspace #2}}}
\newcommand{\rii}{\rho_{11}}
\newcommand{\roo}{\rho_{00}}
\newcommand{\roi}{\rho_{01}}
\newcommand{\rio}{\rho_{10}}
\newcommand{\corr}[1]{{\color{blue} #1}}
\newcommand{\sugg}[1]{{\color{black} #1}}
\newcommand{\comm}[1]{{\color{black} #1}}
\newcommand{\addkm}[1]{{\color{black} #1}}
\newcommand{\mah}[1]{{\color{black}  #1}}
 \newcommand{\adde}[1]{{\color{black} #1}}
  \newcommand{\revk}[1]{{\color{black} #1}}
 
 
\begin{document}
%
\title{Thermodynamics along individual trajectories of a quantum bit
%\hspace{1in}\\
%One sentence summary: Experimental identification of heat and work establish the laws of thermodynamics along single quantum trajectories\\
\hspace{1in}}



\author{M. Naghiloo}
\affiliation{Department of Physics, Washington University, St.\ Louis, Missouri 63130}
\author{D. Tan}
\affiliation{Department of Physics, Washington University, St.\ Louis, Missouri 63130}
\author{P. M. Harrington}
\affiliation{Department of Physics, Washington University, St.\ Louis, Missouri 63130}
\author{J. J. Alonso}
\affiliation{Department of Physics, Friedrich-Alexander-Universit\"at Erlangen-N\"urnberg, D-91058 Erlangen, Germany}
\author{E. Lutz}
\affiliation{Department of Physics, Friedrich-Alexander-Universit\"at Erlangen-N\"urnberg, D-91058 Erlangen, Germany}
\author{A. Romito}
\affiliation{Department of Physics, Lancaster University, Lancaster LA1 4YB, United Kingdom}
\author{K. W. Murch}
\affiliation{Department of Physics, Washington University, St.\ Louis, Missouri 63130}
\affiliation{Institute for Materials Science and Engineering, St.\ Louis, Missouri 63130}

\date{\today}

%One sentence summary: Experimental identification of heat and work establish the laws of thermodynamics along single quantum trajectories

\begin{abstract}
  We use a near-quantum-limited detector to experimentally track individual quantum trajectories of a driven qubit formed by the hybridization of a waveguide cavity and a transmon circuit. For each measured quantum coherent trajectory, we separately identify energy changes of the qubit as heat and work, and verify the first law of thermodynamics for an open quantum system. We further employ a novel quantum feedback loop to compensate for the exchanged heat and effectively isolate the qubit. By verifying  a generalized Jarzynski equality for the distribution of applied work, we demonstrate the validity of the second law of thermodynamics. Our results establish thermodynamics along individual quantum trajectories.
\end{abstract}


\maketitle

The laws of thermodynamics are fundamental laws of nature that classify energy changes for macroscopic systems as work performed by external driving and heat exchanged with the environment. In the past decades, these principles have been successfully  extended to the level of classical trajectories of microscopic systems to account for  thermal fluctuations  \cite{jar11,sei12,cil13}. \addkm{In particular, experimentally tested generalizations of the second law \cite{lip02,wan02,bli06}, known as fluctuation theorems, quantify the occurrence of negative entropy production. %In particular, generalizations of the second law, known as fluctuation theorems, which quantify the occurrence of negative entropy production, have been tested in experiments  \cite{lip02,wan02,bli06}.
 The extension of thermodynamics to include quantum fluctuations faces unique challenges such as the proper identification of heat and work and clarification of the role of quantum coherence \revk{ \cite{gal16,alon16,elou17,deff16,kamm16,cott17}.}} %In continuously monitored quantum systems, where quantum trajectories can be followed,  heat and work can be defined consistently  \cite{alon16}. I felt like this sentence broke the usual flow of a nature bold paragraph - and we mention the importance of this paper in paragraph 2.
Here, we present an experimental protocol to measure heat and work along single quantum trajectories of a superconducting qubit evolving under continuous unitary evolution and measurement. We show that the measured heat and work are consistent with the first law and demonstrate the second law in the form of  a generalized Jarzynski equality  \cite{jarz1997,kafr12} by employing a novel quantum feedback loop. The latter effectively \addkm{compensates} for the heat allowing the work distribution to be inferred from energy measurements. %We confirm experimentally the first and second laws of thermodynamics and compensate the heat contribution with the help of a novel feedback loop.  
Our results establish thermodynamics along individual quantum trajectories.


 In classical thermodynamics, work is defined as the variation of internal energy in an isolated system, $  W=\Delta U$. For non-isolated systems the first law of thermodynamics introduces heat as the difference, $ Q =\Delta U -  W$.  Thermal isolation is thus essential to distinguish heat  from work  \cite{pip66}.  This definition cannot be directly replicated at the quantum level. \addkm{Quantum systems do not necessarily occupy definite states and  thermodynamic quantities are defined in terms of transition probabilities between energy eigenstates.} %At the quantum level, thermodynamic quantities are random owing to the presence of quantum and thermal  fluctuations. [there was a kink in the flow here, we need to motivate why we introduce transition probabilities.
For a driven quantum system described by the Hamiltonian $H_t$, the  distribution of  the total energy \addkm{change} $\Delta U$ is  \cite{talk07},
\begin{equation}\label{eq:pu}
P(\Delta U)  =  \sum_{m,n} P_{m,n}^{\tau} P_{n}^{0} \delta(\Delta U - (E^\tau_m-E^0_n)),
\end{equation}
where $P_{n}^{0}$ denote the initial occupation probabilities, $P_{m,n}^{\tau}$ are the transition probabilities  between   initial and final eigenvalues $E^0_n$ and $E^\tau_m$ of  $H_t$,  and $\tau$ is the duration of the protocol. 
%For thermally isolated systems, the change in energy is only due to work performed on or by the system itself, $dU= \dbar W$. For a driven quantum systems, without a heat contribution,  transition probabilities between energy levels can be used on the ensemble level to extract the work probability distribution for certain driving protocols. In this case the change in the internal energy is obtained by the transition probabilities $P_{m,n}^{t}$ between eigenstates $n$ and $m$ during time $t$,
%
%for initial probabilities $P_n^0$ and Hamiltonian eigenvalues $E_m$ and $E_n$ at initial and final times respectively.
This relation has been used to determine the work distribution and corresponding fluctuation theorems in isolated  NMR  and trapped ion  systems  \cite{bata2014,shuo2015} for which $\Delta U= W$.  


\addkm{In open quantum systems, the total energy change cannot, in general, be uniquely separated into heat and work \cite{cam11}}. \comm{However, for systems whose environment consists of a continuously coupled quantum limited detector, heat and work may be evaluated along single quantum trajectories \revk{ \cite{alon16,elou17,dere08,horo12}}.  These systems are only weakly coupled to the detector and information about their states $\tilde \rho(t)$ may  be inferred the measured signal} without projecting them into eigenstates. Such systems might thus generically be in  coherent superpositions of energy eigenstates. In this case, the evolution consists of both a unitary part and, because of the continuous monitoring, an additional nonunitary  component: the former is identified as work, the latter as heat. 
Specifically, for an infinitesimal time interval $dt$, $d \tilde{\rho}_t= \delta \mathbb{W}[\tilde \rho_t] dt+ \delta \mathbb{Q}[\tilde \rho_t]dt$, where  $\delta \mathbb{W}[\tilde \rho_t] $ and $\delta \mathbb{Q}[\tilde \rho_t] $ are  \comm{superoperators} associated with the respective unitary and nonunitary dynamics. 
The first law  along a single quantum trajectory $\tilde \rho(t)$ takes then the form  \cite{alon16}, $d \tilde U=\delta \tilde W + \delta \tilde Q$, with $\delta\tilde W =\tr[\tilde\rho_{t-dt}dH_t]$ and $\delta\tilde Q=\tr[H_{t}d\tilde{\rho}_t]$ (Methods). When integrated over time, the first law takes the form
\begin{equation}
\label{2}
\Delta \tilde U=\int_0^\tau  \frac{\delta \tilde W}{dt} \, dt + \int_0^\tau  \frac{\delta \tilde Q}{dt}  \, dt,
\end{equation} 
for each single quantum trajectory. Equation \eqref{2} is a quantum extension of the first law of stochastic thermodynamics. \addkm{It relates the path-independent  average change of energy $\Delta  \tilde U $ with the path-dependent heat and work.} In the unitary limit, the heat contribution vanishes and Eq.~\eqref{2} reduces to the known expression from the two-energy-measurement approach \eqref{eq:pu}, $\Delta \tilde U = \Delta U = E_m^\tau-E_n^0=W$ (Methods).
%The  usual first law  is recovered when \eqref{2} is averaged over  stochastic and quantum fluctuations. 
Similarly, we may distinguish heat and work contributions to changes of the transition probabilities, $d\tilde P_{m,n} =\delta\tilde P^W_{m,n}+\delta\tilde  P^Q_{m,n}$, along individual  trajectories (Methods).  

%$\dbar\mathbb{W}[\rho_t] \equiv -\frac{i}{\hbar}[H(t),\rho(t)] dt$ and $\dbar\mathbb{Q}[\rho_t] \equiv d\rho(t) - \dbar\mathbb{W}[\rho_t]$ are the work and heat contributions of the system's evolution.
%
%
% In these systems, weak measurements that only slightly perturb the time evolution are used to gain information 
%
%unless the state of the system and environment is measured during the driving  \cite{tal11}. Though this is a hard task for thermal baths, heat and work have been theoretically determined for a system continuously monitored by quantum limited detector  \cite{alon16}, for which the state of the system $\rho(t)$ is inferred by the measured signal in the detector  \cite{wisebook, koro11, hatr13,murc13traj}. In this case, there is both unitary evolution of the system and additional stochastic changes to the state by the detector: The former is identified as work, the latter as heat. 
%Specifically, for an infinitesimal time interval $dt$, $\dbar\mathbb{W}[\rho_t] \equiv -\frac{i}{\hbar}[H(t),\rho(t)] dt$ and $\dbar\mathbb{Q}[\rho_t] \equiv d\rho(t) - \dbar\mathbb{W}[\rho_t]$ are the work and heat contributions of the system's evolution.
%The total heat and work contribution to the dynamics of the system, initially in  eigenstate $n$, during the complete trajectory can be integrated as,
%\begin{align}\label{eq:probb}
%\begin{split}
%P_{m,n}^Q &= \int_0^Tdt\,\tr\big[\Pi_m\,\dbar\mathbb{Q}[\rho_t]\big],\\
%P_{m,n}^W &= \int_0^Tdt\,\tr\big[\Pi_m\,\dbar\mathbb{W}[\rho_t]\big],\\
%\end{split}
%\end{align}
%where $\Pi_m$ is the projective measurement operator of the eigenstate $m$ of the Hamiltonian at the integration time. %\comm{[ Note that, $ \hbar \omega_q ~\tr\big[\Pi_{1(0)}\,\dbar\mathbb{W}[\rho_t]\big]= \pm \delta \tilde{W}$, instantaneous work and similarly for instantaneous heat $ \hbar \omega_q ~\tr\big[\Pi_{1(0)}\,\dbar\mathbb{Q}[\rho_t]\big]= \pm \delta \tilde{Q}$]}. 
%Thus, the first law of thermodynamics for a given quantum process takes the form:
%\begin{equation}\label{eq:summ}
%P_{m,n} = P_{m,n}^{Q} +  P_{m,n}^{W}
%\end{equation}
%where the total transition probabilities, which are path independent since they only rely in the initial and final state of the system, are the sum of two trajectory-dependent contributions, work and heat. Equivalently, along individual quantum trajectory, $\rho(t)$, it is possible to separately identify work $\dbar W$ and heat $\dbar Q$:
%\begin{equation}\label{eq:distinc}
%dU=d(\tr[\rho {H}])= 
%\underbrace{\tr[H\,d\rho ]}_{\dbar Q}
%+
%\underbrace{\tr[\rho\,dH]}_{\dbar W}.
%\end{equation}
%



\begin{figure*}[!htb]
\begin{center}
\includegraphics[width =\textwidth]{fig1_v2.pdf}
\caption{\small  {\bf Evaluating heat and work along single quantum trajectories.}  
\textbf{a}, Schematic of the qubit system, drive, and homodyne detection. 
\textbf{b}, Instantaneous work (blue), heat (red) and energy (green) along a single trajectory. 
%
\textbf{c}, A scatter plot of  final work and heat contributions to the  $P_{0,0}$ transition probability for an ensemble of $\sim 10^4$ experimental protocols of duration $2\ \mu$s.  Each experimental sequence terminates with a projective measurement and the color of the points indicate the outcome of this measurement (orange: $m=1$, purple: $m=0$). \addkm{The heat and work contributions are not necessarily bounded, but their sum is limited to [-1,0] as expected.}
%
\textbf{d}, The total energy along a single quantum trajectory (green) compared to the total energy as determined from an ensemble of projective measurements at each time point (circles). The error bars indicate the standard error of the mean.
%
\textbf{e}, Projective measurements binned and averaged according to the sum of the work and heat contributions $\tilde{P}_{0,0}^W+\tilde{P}_{0,0}^Q$. The agreement with the dashed line demonstrates the first law of thermodynamics. The error bars indicate the standard error of the mean based on the number of occurrences for each value of $\tilde{P}_{0,0}^W+\tilde{P}_{0,0}^Q$ (inset). }
\label{fig:fig1}
\end{center}
\end{figure*}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%EXPERIMENTAL SYSTEM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Here we report direct measurements of $\dbar \tilde W$ and $\dbar \tilde Q$ along individual quantum trajectories of a continuously monitored two-level system. The two-level quantum system is formed by the hybridization of a microwave frequency waveguide cavity and a transmon circuit  \cite{koch07,paik113D,murc13,nagh16,camp16}, which is described by the Hamiltonian,  $H_\mathrm{q}= -\hbar \omega_\mathrm{q}\sigma_z/{2}$,  and depicted in Figure~\ref{fig:fig1}(a).  
The qubit is driven by a classical time-dependent field described by the Hamiltonian $H_{\mathrm{R}} =  \hbar \Omega_\mathrm{R}  \sigma_y \cos(\omega_\mathrm{q} t + \phi)$, %\comm{[ $H_{\mathrm{R}} = - \Omega_\mathrm{R}/2~  \sigma_y$ in the rotating frame)]}
where $\sigma_z, \sigma_y$ are Pauli matrices, $\omega_\mathrm{q}$ is the resonance frequency of the qubit, and $\Omega_\mathrm{R}$ is the Rabi drive frequency.
The qubit is radiatively coupled  to a transmission line. Homodyne monitoring of  the transmission line using a Josephson parametric amplifier results in weak measurement of the qubit given by the detector signal  (Methods), %By virtue of this interaction Hamiltonian, a homodyne measurement along an arbitrary quadrature of the quantized electromagnetic field of the transmission line, $a e^{-\phi} + a^{\dagger} e^{+\phi}$, results in weak measurement along the corresponding dipole of the qubit, $\sigma_+ e^{-\phi} + \sigma_- e^{+\phi}$. We adjust the homodyne detection quadrature such that the homodyne signal $dV_t$ obtained over the time interval $(t, t+dt)$ is given by
$d V_t = \sqrt{\eta}\gamma \langle \sigma_x \rangle dt + \sqrt{\gamma} dX_t$, 
where $\eta$ is the quantum efficiency of the homodyne detection, $\gamma$ is the radiative decay rate, and $dX_t$ is a zero-mean, Gaussian random variable with variance $dt$. The evolution of the qubit, given both driven evolution $H_\mathrm{R}$ and  homodyne measurement results $dV_t$, is described \revk{in the rotating frame} by the stochastic master equation  \cite{bolu14},
\begin{align}\label{eq:sme}
\begin{split}
d \tilde \rho_t &=  - \frac{i}{\hbar} [H_R, \tilde \rho_t]\,dt + \gamma \mathcal{D}[\sigma_-] \tilde \rho_t\,dt\\
&\hspace{3.5cm}+ \sqrt{\eta \gamma } \mathcal{H}[\sigma_- dX_t] \tilde \rho_t ,
\end{split}
\end{align}
where $ \mathcal{D}[\sigma_-] \tilde \rho = \sigma_- \tilde \rho \sigma_+ -\frac{1}{2} (\sigma_+ \sigma_- \tilde \rho + \tilde \rho  \sigma_+ \sigma_- )$ and $ \mathcal{H}[O]  \tilde \rho = O \tilde\rho + \tilde \rho O^\dagger - \mathrm{tr}[(O+O^\dagger)\tilde \rho]\tilde \rho$ are the dissipation and jump superoperators, respectively.   We further note that the quantum-jump approach (see e.g. Ref.  \cite{hekk13}) cannot be directly applied here  since the environment (detector) is  not an equilibrium reservoir and detailed balance is generally not verified.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%HEAT AND WORK
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Based on the identification of work and heat as the respective unitary and nonunitary contributions to the system evolution, we readily identify the instantaneous work contribution $\dbar\mathbb{W}[\tilde \rho_t]$ with the  first term in (\ref{eq:sme}), while the instantaneous heat contribution $\dbar \mathbb{Q}[\tilde \rho_t]$ is associated with the latter two terms.  \addkm{Although the system could, in general, exchange energy with the detector in the form of heat or work, the homodyne measurement in our experiment only induces a zero-mean stochastic back-action, which guarantees no extra work is done by the detection process.}


Having access to the instantaneous heat and work contributions \addkm{from} a single quantum trajectory, we now verify the  first law of thermodynamics in the form of Eq. (\ref{2}); we perform work by driving the qubit while monitoring the heat exchanged through continuous measurement.  For this, we initialize the qubit in the eigenstate $n$,  and then drive the qubit while collecting the homodyne measurement signal. Figure~\ref{fig:fig1}(b) shows the path-dependent instantaneous heat and work  contributions,  $\dbar \tilde {Q}$ and $\dbar \tilde {W}$, and the corresponding changes in internal energy $d\tilde U$  for a single quantum trajectory, originating in the state $n=0$.  After time $\tau$ we projectively measure   \cite{reed10} the qubit in state $m$ and then repeat the experiment several times. In Figure~\ref{fig:fig1}(c)  we show a scatter plot of the calculated heat and work contributions, $\tilde{P}_{m,n}^Q$ and $\tilde{P}_{m,n}^W$ for $\tau = 2\ \mu$s. Each trajectory exhibits different heat and work contributions,  highlighting the stochastic nature of its quantum evolution. 

In Figure~\ref{fig:fig1}(d) we show the path-dependent total energy $\Delta \tilde{U}\equiv \sum \delta\tilde{U}$ for a single trajectory and the path-independent total energy change $\Delta U \equiv (\hbar \omega_q) P_{1,0}^\tau$ obtained via projective measurements (Methods). We find that the path-independent energy changes are in excellent agreement with the energy changes along a single quantum trajectory.  In Figure~\ref{fig:fig1}(e) we compare the path-independent transition probabilities to the sum of the path-dependent work and heat contributions for experiments of variable duration $\tau = [0,8]\ \mu$s. \addkm{The close agreement demonstrates the successful identification of heat and work and the verification of the first law. }

% The projective measurements allow us to determine the path-independent total transition probability $P_{m,n}^\tau$, and we compare the path-. In addition, the homodyne signal allows us to evaluate the path-dependent heat and work transition probability contributions $P_{m,n}^Q$ and $P_{m,n}^W$ for individual trajectories.  }


%\comm{I think figures are organized in this way that, for individual trajectories we explicitly show heat and work, but in ensemble level we show in terms of transition probabilities.} Figure \mah{The total energy evolution also depicted (black curve).}  \st{demonstrating the validity of the first law}. A scatter plot of the calculated heat and work contributions, $P^Q_{00}$ and $P^W_{00}$, to the transition probability at a final time ($\tau=2\, \mu\text{s}$) for an ensemble of trajectories is presented in Figure~\ref{fig:fig1}(c).  Each trajectory exhibits different heat and work contributions  highlighting the stochastic nature of its quantum evolution. The heat and work contributions are not necessarily bounded, but their sum is limited to [0,1] as expected. Verification of the first law at the level of transition probabilities, $P_{m,n} = P_{m,n}^{Q} +  P_{m,n}^{W}$, 
% is shown in  Figure~\ref{fig:fig1}(d), where we compare the measured \mah{path-independent} total transition probabilities with the summed \mah{path-dependent} heat and work contributions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FEEDBACK AND JARZYNSKI %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{figure}[!htb]
\begin{center}
\includegraphics[width =.5\textwidth]{fig2.pdf}
\caption{\small {\bf Quantum feedback loop.} \textbf{a}, Schematic of the feedback protocol. \textbf{b}, Instantaneous heat and feedback work along a single trajectory. \comm{The feedback work has been time shifted by $20$ ns to account for the time delay in the feedback circuit.} The anti-correlation ($r=-0.68$) of  heat and feedback work is evident in the scatter plot ({\bf c}). \textbf{d}, Average of the instantaneous contribution of heat and feedback to the transition probability for $10^4$ experimental iterations. \textbf{e,} Parametric plot of $\tilde{P}_{0,0}^{W}$ versus $\tilde{P}_{0,0}^{Q}$ (red) and $\tilde{P}_{0,0}^{F+Q}$ (blue) indicating how the feedback cancels the heat contribution, narrowing and shifting the distribution toward zero for $\tau = 6 \ \mu$s.}   \label{fig:fig2}
\end{center}
\end{figure}


We next show that the heat and work contributions identified above fulfill the second law of thermodynamics  in the form of a generalized Jarzynski equality  \cite{jarz1997,kafr12}.  For a system initially prepared in a thermal state at inverse temperature $\beta$,  the Jarzynski equality  \cite{jarz1997} reads,
\begin{equation}\label{eq:jar1}
\langle e^{- \beta W}\rangle= \int P(W) e^{- \beta W} dW = e^{- \beta \Delta F}.
\end{equation}
Equation \eqref{eq:jar1} relates the  free energy difference $\Delta F$ between the equilibrium states of the system defined by $H_t$ and $H_0$ to the
nonequilibrium work $W$ done on the system. It is valid arbitrarily far from equilibrium and is an extension of the second law, $\langle W \rangle \geq \Delta F$, which follows from \eqref{eq:jar1} via Jensen's inequality  \cite{jarz1997}. For an open system, the work distribution defined in Eq.\ (\ref{eq:pu}) does not fulfil the Jarzynski equality due to the heat exchanged with the external environment.  The Jarzynski equality may be recovered by  compensating the effects of the environment with the help of quantum feedback control  \cite{wis10, gong16}. 
\addkm{Unit efficiency feedback has been theoretically shown to effectively achieve thermal isolation of the system by suppressing the detector back-action and the resulting heat exchange \cite{alon16}.}
%By suppressing the detector back-action and the resulting heat exchange, unit efficiency feedback  has been theoretically shown to effectively achievethermal isolation of the system  \cite{alon16}. 
%At the same time, quantum feedback provides a   test of the consistency of the above definitions of heat and work. An incorrect definition of work would indeed lead to a violation of the Jarzynski equality.


%The consistency in the above definitions of heat and work can be verified by showing that the heat contribution is related to the irreversibility of the process. This can be conveniently done by quantifying the violations of the Jarzynski equality  \cite{jarz1997}, a restatement of the second law of thermodynamics applicable to the work probability distribution of non-equilibrium closed systems:
%
%where $\Delta F$ is the free energy difference between the thermal equilibrium states defined by the Hamiltonian of the system at the beginning and at the end of the protocol. For an open system, the work distribution defined in Eq. (\ref{eq:pu}) would not fulfill the Jarzynski equality due to the heat exchanged with the external environment. The equality  (\ref{eq:jar1}) would be recovered if extra work were done on the system to compensate the effects of the environment. Theoretically, unity efficiency quantum feedback does precisely that, and it has been shown  \cite{alon16} that its contribution indeed restores Eq. (\ref{eq:jar1}).

\begin{figure}[!htb]
\begin{center}
\includegraphics[width =.5\textwidth]{fig3_v2.pdf}
\end{center}
\caption{{\bf Second law of thermodynamics.} {\bf a}, The time evolution of the transition probability $P_{0,0}$ without feedback (red), with feedback (blue), and ideal unitary evolution (green). {\bf b}, \revk{Comparison of the efficacy calculated by the generalized Jarzynski equality via the work distribution inferred from the measured transition probabilities at $\beta/(\hbar \omega_\mathrm{q})= 3.5$ (blue)  to the efficacy calculated from the quantum trajectories (red, methods). The shaded regions indicate the standard error of the mean. Inset, the mean squared deviation of the efficacy from unity in the time interval $[0,1]\ \mu$s for different quantum efficiencies. $\eta = 0$ corresponds to the experimental no feedback case, $\eta = 0.3$ corresponds to the experimental feedback result (shaded region). Using simulations, the efficacy is also determined at different quantum efficiencies, showing that the efficacy approaches unity with increasing quantum efficiency.  The dashed line is a guide to the eye.}}   \label{fig:fig3}
\end{figure}


The essence of feedback is to adjust the Hamiltonian at each time step to compensate for the effect of the detector, $\dbar\mathbb{Q}[\tilde \rho_t]$, thus making the system effectively closed. The dynamics of the system is then simply described by a unitary evolution where only the work $\dbar\mathbb{W}[\tilde \rho_t]$ contributes. \addkm{In order to implement feedback, we adapt the phase-locked loop protocol introduced in Ref.  \cite{vija12}, schematically depicted in  Figure~\ref{fig:fig2}(a).  This is achieved by multiplying the homodyne measurement signal with a reference oscillator of the form $A[\sin(\Omega_\mathrm{R} t+\phi)+B]$ yielding a feedback control,  $\Omega_\mathrm{F}$, that modulates the amplitude of the qubit drive thereby applying additional work, \comm{$\dbar\mathbb{W}_F[\tilde \rho_t] = 
 ({i}/{\hbar}) [
\hbar \Omega_\mathrm{F} \sigma_y\cos(\omega_q t + \phi), \rho_t]$,} to eliminate exchanged heat.}

 
 
% $\dbar \tilde W_\mathrm{F} =\mathrm{tr}\left[\Pi_m \dbar\mathbb{W}_\mathrm{F}[\tilde \rho_t]\right]$, ($\Pi_m$ denotes the projector onto the eigenstate $m$) together with the corresponding instantaneous heat contribution, $\dbar \tilde Q = \mathrm{tr}\left[\Pi_m \dbar\mathbb{Q}[\tilde \rho_t]\right]$, along a single trajectory for a state-of-the-art quantum efficiency of 35$\%$. 
 
Figure~\ref{fig:fig2}(b) shows the instantaneous feedback work, \comm{$\dbar \tilde W_\mathrm{F} =\hbar \omega_\mathrm{q}\mathrm{tr}\left[\Pi_{m=1} \dbar\mathbb{W}_\mathrm{F}[\tilde \rho_t]\right]dt$ (where $\Pi_m$ is the projector onto eigenstate $m$), together with the corresponding instantaneous heat contribution, $\dbar \tilde Q =  \hbar \omega_\mathrm{q}\mathrm{tr}\left[\Pi_{m=1} \dbar\mathbb{Q}[\tilde \rho_t]\right] dt$,} %$\dbar \tilde Q = \mathrm{tr}\left[H_t \dbar\mathbb{Q}[\tilde \rho_t]\right] dt$,
 along a single trajectory for a state-of-the-art quantum efficiency of 35$\%$.  It is clear from the figure that the feedback partially cancels the heat at each point in time. The anti-correlation between the instantaneous feedback and heat contributions depicted in Figure~\ref{fig:fig2}(c) confirms that the feedback loop  compensates for exchanged heat at each time step. In addition, by averaging the instantaneous heat and work contributions to the transition probability over many iterations of the experiment (Fig.~\ref{fig:fig2}d), we  clearly see how feedback works toward canceling the heat contribution on average.

 
In the presence of feedback, the work includes both drive and feedback contributions.  The total transition probability may  be  rewritten as 
$\tilde{P}_{m,n}^\tau = \tilde{P}_{m,n}^{W} +   \tilde{P}_{m,n}^{Q}+  \tilde{P}_{m,n}^{F}$,  with the work contribution from feedback $\tilde{P}_{m,n}^{F}$. Figure~\ref{fig:fig2}e shows the transition probabilities $\tilde{P}_{0,0}^{W}$ versus  $ \tilde{P}_{0,0}^{Q} + \tilde{P}_{0,0}^{F}$ for about $10^4$ experiments of duration $6\ \mu$s. By comparing the transition probabilities with and without feedback, we observe  that the heat contribution  is significantly reduced by the feedback.  In the limit of unit quantum efficiency and null loop delay, a feedback loop could exactly compensate for the exchanged heat by the application of additional work, resulting in pure unitary evolution of the qubit  (Methods).  However, owing to the non unit quantum efficiency, the Jarzynski equality \eqref{eq:jar1} takes the generalized form $\langle \exp(-\beta (W- \Delta F)\rangle = \gamma_q$, where $\gamma_q$ is the so-called efficacy, whose value depends on the quantum efficiency  \cite{kafr12} (Methods). 


%, hence  the work contribution to the transition probability is expressed as $P^W=P^{W_\mathrm{Rabi}}+P^{W_\mathrm{f}}$. The transition probability sum of Eq.~\ref{eq:summ} is conveniently rewritten as
%\begin{equation}
%P_{m,n} =  P_{m,n}^{W_\mathrm{Rabi}} +   P_{m,n}^{Q}+  P_{m,n}^{W_\mathrm{f}}, \label{tp1}
%\end{equation}
%where we have isolated the feedback's work contribution $P_{m,n}^{W_\mathrm{f}} = \int_0^Tdt\,\tr\big[\Pi_m\dbar\mathbb{W}_\mathrm{f}[\rho_t]\big]$.
%Figure~\ref{fig:fig2}e shows the transition probabilities $\delta P_{0,0}^{W_\mathrm{Rab}$ versus the $ \delta P_{0,0}^{Q} + \delta P_{0,0}^{W_\mathrm{f}}$ for $\sim 10^4$ experiments of duration $6\ \mu$s. By comparing the transition probabilities with and without feedback it is clear the contribution of heat to the transition probabilities is reduced by the additional work.

%The effect of finite efficiency is such that at a time step $t$, too much or too little work is applied to exactly compensate the exchanged heat (see Methods for more detailed study of feedback loop).  

We now use the above feedback protocol to test  the second law in the form of the generalized Jarzynski  equality.
We first compare the transition probabilities  with and without feedback  to the expected transition probabilities for a closed system undergoing Rabi oscillations, for which $P^{t}_{11}=P^{t}_{00}=\cos^2(\Omega t)$ and $P^{t}_{10}=P^{t}_{01}=\sin^2(\Omega t)$ (Fig.~\ref{fig:fig3}a).  We observe that  in the absence of feedback (red), the oscillations are damped and the transition probabilities approach the constant value $1/2$. On the other hand, in the presence of  feedback (blue), the transition probabilities  oscillate in agreement with those for the closed system (green), albeit with a smaller amplitude due to finite quantum efficiency.
%of  Therefore, the feedback is effective in closing the system, giving better agreement with the Jarzynski equality. \comm{[If we want to keep graph 3b Here we may bring that; In our case where the system overwhelmed by heat we expect to observe less violation of Jarzynski at the beginingg of experiment in time scale of the decay of qubit. ]}
%We use Eq.~\ref{eq:jar1} for the Jarzynski equality as follows,
%\begin{equation}
%\begin{split}
%\langle e^{- \beta W} \rangle &= \frac{1}{2 \cosh(\beta)} \lbrace P^{t}_{11} e^{-\beta} e^{0} + P^{t}_{01} e^{-\beta} e^{+2\beta}\rbrace  \\
%&+\frac{1}{2 \cosh(\beta)} \lbrace P^{t}_{00} e^{+\beta} e^{0} + P^{t}_{10} e^{+\beta} e^{-2\beta}\rbrace  \\
%  &               = e^{- \beta \Delta F}.\\
%\end{split}
%\label{jar1}  
%\end{equation}
\revk{For our system, the initial and final Hamiltonians are the same and we expect $\Delta F = 0$.  In  Figure~ \ref{fig:fig3}b we display $\langle \exp(-\beta (W)\rangle = \gamma_q$, where the work distribution is calculated from the the measured transition probabilities with feedback.  For perfect quantum measurement and feedback efficiency, we expect the efficacy $\gamma_q = 1$, corresponding to the Jarzynski equality.  To verify the generalized Jarzynski equality, we determine the efficacy from the individual quantum trajectories under feedback control (Methods). As shown in Figure~ \ref{fig:fig3}b, the two curves are in close agreement,}  thus verifying the generalized second law in our system. We moreover note that quantum feedback provides a test of the consistency of the above definitions of heat and work. \revk{Figure~ \ref{fig:fig3}b, inset displays $\langle (\gamma_q - 1)^2\rangle$ for the experimental data without ($\eta =0$) and with ($\eta = 0.3$) feedback, as well as simulation results at higher efficiencies.  As the quantum efficiency is improved, the efficacy approaches unity, thus verifying that heat and work have been correctly identified, as an incorrect definition of work would not result in unity efficacy.}


%from the Jarzynski  In the case without feedback, $\Delta F$ starts from zero, but quickly deviates and then damps into a constant non-zero value $-0.07 \hbar \omega_\mathrm{q}$ after a few oscillations, reflecting that the steady state of the driven and dissipated qubit is not purely mixed  \cite{gard86}.  In contrast,  the feedback strongly suppresses the amplitude of the initial oscillations and  reduces the deviation from $\Delta F = 0$ by a factor of $2$ on average.  \addkm{We find from numerical simulations (Methods) that the remaining deviations from the Jarzynski equality are due to the finite efficiency of the feedback protocol and these  vanish as the efficiency is improved (Fig.\ \ref{fig:fig3}b inset).}



\addkm{Our experiment successfully generalizes} classical stochastic thermodynamics to the quantum regime. In the confirmation of the first and second laws along individual quantum trajectories, we have allowed for a thermodynamic description of coherent superpositions of energy eigenstates during time evolution, and have demonstrated a practical feedback scheme to consistently distinguish quantum heat from quantum work. Our results pave the way for future experimental and theoretical investigations in information  \cite{par15} and quantum  thermodynamics  \cite{gem04}, ranging from the design of microscopic quantum machines  \cite{kos14,raam15}, the exploration of far from equilibrium quantum phenomena  \cite{esp09} and the interplay of quantum information and energy  \cite{goo16},  to the very foundations of quantum statistical mechanics and quantum measurement  \cite{dre16}. 

%\bibliographystyle{unsrt}

%
%\pagebreak
%\section{Experimental set-up}
%The transmon qubit was fabricated by double angle evaporation of aluminium on high resistivity silicon substrate and is characterized  by charging energy$ E_{C}/h=293$ MHz and Josephson energy $ E_{J}/h=20.8$ GHz. The $E_{C}$ is obtained from the anharmonicity of the lowest two qubit levels and $ E_{J}$ is calculated from the relation $\hbar\omega_{q}=\sqrt{8E_{J}E_{C}}-E_{C}$. The qubit transition frequency is $\omega_{q}/2\pi=6.69$ GHz. The qubit coherence properties were measured by standard techniques, The energy decay time $T_{1}=1.6$ $\mu s$ and Ramsy decay time $T_{2}^{\ast}=2.5$ $\mu s$.  The qubit is resonantly coupled to a wave-guide cavity. The cavity transition frequency is $\omega_c/2\pi =7.2$ GHz with linewidth $\kappa/2\pi = 2.25$ MHz. The resonant coupling between the qubit and the cavity is given by an interaction Hamiltonian, $H_\mathrm{int.}  = \hbar g (a \sigma_+ + a^{\dagger} \sigma_ -)$, where $\hbar$ is the reduced Plank's constant, $a^\dagger (a)$ is the creation (annihilation) operator, and $\sigma_+(\sigma_\pm)$ is the qubit ladder operator that acts on the qubit in the energy basis. We use a near-quantum-limited Josephson parametric amplifier which consists of a 1.5 pF capacitor shunted by a SQUID composed of two $I_{0}=1 $ $\mu A$ Josephson junctions. The LJPA is operated with negligible flux threading the SQUID loop and pumped by two sidebands that are equally separated from the carrier by 360 MHz which produces 20 dB gain with an instantaneous 3-dB-bandwidth of 50 MHz.
%
%
%\begin{figure*}\begin{center}
%\includegraphics[angle = 0, width =.72\textwidth]{schematic.pdf}
%\end{center}
%\caption{ \label{fig6} Experimental set-up. Qubit pulse  the amplifier pump and the local oscillator for the demodulation are generated by microwave frequency generator. }
%\end{figure*}
%




\begin{center}{\bf METHODS}\end{center}

\textbf{Heat and work definitions and contributions to transition probabilities}--- 
The definition of heat and work in the manuscript stems from the association of work with the deterministic driving of the quantum system, and of heat with the stochastic evolution due to the detection process, $d \tilde{\rho}_t= \delta \mathbb{W}[\tilde \rho_t] dt+ \delta \mathbb{Q}[\tilde \rho_t]dt$.
In fact, the change in the internal energy between times $t$ and $t+dt$ along a single quantum trajectory is   expressed as
\begin{align*}
d \tilde U_t=& \tr[H_t(\tilde\rho_{t-dt}+d\tilde\rho_t)]-\tr[H_{t-dt}\tilde\rho_{t-dt}]\nonumber\\
=& \tr[ \tilde\rho_{t-dt}dH_t]+\tr[H_{t}\delta\mathbb{W}dt ] + \tr[H_{t}\delta\mathbb{Q}dt ]\nonumber\\
=&\delta \tilde W_t + \delta \tilde Q_t,
\end{align*} 
\addkm{where in the second line $dH_t=H_t-H_{t-dt}$ and  $\tr[H_t\delta\mathbb{W}dt]= -\frac{i}{\hbar} \text{tr}[H_t [H_t,\rho_t] dt]=0$.} In the last line, $\delta\tilde W_t=\tr[\tilde\rho_{t-dt}dH_t]$ and $\delta\tilde Q=\tr[H_{t}d\tilde{\rho}_t]$, indicating that work is related to a change of the Hamiltonian, as expected, and heat to the nonunitary changes in the state.

The different contributions of heat and work to the quantum evolution are reflected in different contributions to the transition probabilities.
The changes to the transition probabilities due to heat and work are defined as $\delta \tilde{P}_{m,n}^Q = \tr\left[\Pi_m\,\dbar\mathbb{Q}[\tilde{\rho}_t]\right]$, and $\delta \tilde{P}_{m,n}^W =  \tr\left[\Pi_m\,\dbar\mathbb{W}[\rho_t]\right]$,  where $\Pi_m$ is the projective measurement operator of the eigenstate $m$ at time $t$  and the trajectory $\tilde{\rho}(t)$ originates in eigenstate $n$. 
Correspondingly, we define the path-dependent total transition probabilities, 
\begin{align}\label{eq:probb}
\tilde{P}_{m,n}^Q = \int_0^\tau dt\, \delta \tilde{P}_{m,n}^Q,\quad
\tilde{P}_{m,n}^W = \int_0^\tau dt\, \delta \tilde{P}_{m,n}^W .
\end{align}
The definition of heat and work contributions to the evolution of the density matrix, $d \tilde{\rho}_t= \delta \mathbb{W}[\tilde \rho_t] dt+ \delta \mathbb{Q}[\tilde \rho_t]dt$, imply that, starting form a density matrix $\rho_0$ corresponding to an eigenstate $n$, the total transition probabilities $\tilde{P}_{m,n}^\tau$ are expressed as \addkm{
\begin{equation}
\begin{split}
\tilde{P}_{m,n}^\tau & = \tr[\Pi_m \tilde{\rho}_t] = P^0_{m,n}+ \int_0^\tau dt\, \tr[\Pi_m \delta \mathbb{Q}[\tilde \rho_t]]dt \\
& + \int_0^\tau dt\, \tr[\Pi_m \delta \mathbb{Q}[\tilde \rho_t]]dt = \tilde{P}_{m,n}^Q+ \tilde{P}_{m,n}^W,
\end{split} \label{eq:traiettoria}
\end{equation}}

\addkm{The instantaneous heat, work, and feedback are also expressed in terms of energy by $\dbar \tilde Q =\hbar \omega_\mathrm{q}\mathrm{tr}\left[\Pi_{m=1} \dbar\mathbb{Q}[\tilde \rho_t]\right]$, $\dbar \tilde W =\hbar \omega_\mathrm{q}\mathrm{tr}\left[\Pi_{m=1} \dbar\mathbb{W}[\tilde \rho_t]\right]$, and $\dbar \tilde W_\mathrm{F} =\hbar \omega_\mathrm{q}\mathrm{tr}\left[\Pi_{m=1} \dbar\mathbb{W}_\mathrm{F}[\tilde \rho_t]\right]$, respectively. }These changes reflect only the instantaneous changes in energy and do not depend on the initial state of the system.

Transition probabilities can be experimentally obtained by preparing the qubit in a specific initial state $n$ and terminating the experiment at time $\tau$ with a projective measurement  \cite{reed10}
 in the energy basis. These projective measurements allow us to determine the total energy difference for the qubit and compare to the total energy calculated from the heat and work along individual quantum trajectories, in a manner similar to the tomographic validation for trajectories in previous work  \cite{murc13traj,webe14}.  
  In Figure 1d we show the total energy changes of the qubit $\Delta U$ obtained from the transition probability $P_{1,0}$ which was determined from an ensemble of $10^5$ experiments of variable duration $\tau$ where the path-dependent energy $\tilde{U}$ was within $\pm 0.05$ of the black curve shown in Figure 1d at time $\tau$.  The transition probability is corrected for the finite readout fidelity of 65\%.  In Figure 1e, we compare the measured, path-independent, transition probability $P_{0,0}$, to the path-dependent transition probability $\tilde{P}^W_{0,0} + \tilde{P}^Q_{0,0}$, by binning experiments of variable duration according to the final path-dependent transition probability and determining the transition probability $P_{0,0}$ at each point from the outcomes of the projective readout. The close agreement between  $P_{0,0}$ and $\tilde{P}^W_{0,0} + \tilde{P}^Q_{0,0}$ indicates that the two independent measures of the qubit energy are in agreement, thereby confirming the first law of thermodynamics. 

\textbf{The unitary limit}--- 
In the absence of a detector, the system under consideration reduces to an isolated system and our definition work agrees with the standard definition in Eq. (1) of the manuscript. In order to see this for a two-energy-measurement protocol, blue we note that our distinction between heat and work amounts in this case to the separation of work-like and heat-like components of the transition probabilities, $\tilde{P}^W_{m,n}$ and $\tilde{P}^Q_{m,n}$. When the system-detector coupling is vanishing,  one has $\tilde{P}^W_{m,n} = P_{m,n}^{\tau}$. In fact, for an isolated system initially prepared in the $E_n^0$ energy eigenstate, the only trajectory is that dictated by the unitary evolution, with the nonunitary part being zero along the entire trajectory, $ \delta \mathbb{Q}[\tilde \rho_t]/dt =0$, hence $\tilde{P}^Q_{m,n}=0$ and $d \tilde{\rho}_t= \delta \mathbb{W}[\tilde \rho_t] dt$. Together with Eq. \eqref{eq:traiettoria}, this implies
\begin{equation}
\tilde{P}^W_{m,n}=\tilde{P}^{\tau}_{m,n}={\rm tr} [ \Pi_m \tilde{\rho}_{\tau} ]=P^{\tau}_{m,n},
\end{equation} 
i.e. the work-like component of the transition probability reduced to that of an isolated system. 

%Our formalism reproduces the physics of the isolated system also for the average quantities computed along single trajectories, $\delta \tilde{W}$ and $\delta \tilde{Q}$.  In fact, for an isolated system, $ \delta \mathbb{Q}[\tilde \rho_t]=0$, hence $\delta \tilde{Q}/dt=0$. We can therefore write Eq. (2) in the manuscript as 
%%\begin{equation}
%%\Delta U= \int_0^{\tau}\frac{\delta W}{dt} dt =\sum_{j=1}^N {\rm tr} [\tilde{\rho_{t_{j-1}} (H_{t_j}-H_{t_{j-1}})]={\rm tr} [\rho_{t_j}H_{t_j} - \rho_{t_0}H_{t_0}] - \sum_{j=1}^N {\rm tr} [H_{t_{j}}(\rho_{t_j}-\rho_{t_{j-1}})] = {\rm tr} [\rho_{t_j}H_{t_j} - \rho_{t_0}H_{t_0}] -
%%\end{equation}
%\begin{equation}
%\begin{split}
%\Delta \tilde{U}= \int_0^{\tau}\frac{\delta W}{dt} dt = \int_0 ^{\tau} {\rm tr} [ \rho_t \frac{dH}{dt}]dt={\rm tr} [\rho_{\tau} H_{\tau} - \rho_0 H_0] -{\rm tr}\int_0^{\tau} [\frac{d \rho_t}{dt} H] dt \\ = {\rm tr} [\rho_{\tau} H_{\tau} - \rho_0 H_0] + i \int_0^{\tau} {\rm tr}[[H,\rho_t] H] dt =  {\rm tr} [\rho_{\tau} H_{\tau} - \rho_0 H_0] = {\color{blue} \langle  \Delta {U} \rangle},
%\end{split}
%\end{equation}
%where the average in the last equality is that obtained from the distribution in Eq.~(1) of the manuscript. {\color{blue} We have here used that $\tilde \rho_{t-dt} \rightarrow \tilde\rho_{t}$ in the limit $dt \rightarrow 0$.}

In addition, our formalism also reproduces the physics of an isolated system at the level of a single two-energy-measurement realization. In that case, one identifies four possible trajectories corresponding to the transitions from the possible initial states of energy $E_n^0$ to the final states with energy $E_m^{\tau}$. The probability of such a trajectory is $P_n^0 P_{m,n}^{\tau}$. Each of these trajectories consists of a unitary evolution from $0$ to $t_f$ ending with a density matrix $\rho_f$ and a final extra  nonunitary step from $t_f$ to $t_F+\Delta t_M=\tau$ determined by the measurement, which changes $\rho_f \to \rho_m=\vert m \rangle \langle m \vert$.  The Hamiltonian $H=H_\tau$ is  unmodified in this last step.
%Since the extra measurement step is a purely nonunitary contribution, we can compute 
 The work contribution from the unitary evolution is
\begin{equation}
\int_{0}^{\tau} \frac{\delta  \tilde W}{dt} \, dt= \int_{0}^{t_f} \frac{\delta \tilde  W}{dt} \, dt = {\rm tr} [\tilde  \rho_f H_{\tau} - \tilde \rho_0 H_0] = {\rm tr} [\tilde \rho_f   H_{\tau} ] - E_n^0 .
\end{equation}
Similarly, the only contribution to the heat term arises from the last nonunitary step, yielding
\begin{align}
\int_{0}^{\tau} \frac{\delta \tilde  Q}{dt} \, dt&= \int_{t_f}^{t_f+\Delta t_M} \frac{\delta \tilde  Q}{dt} \, dt & \nonumber\\   &= {\rm tr} [\tilde  \rho_m H_{\tau} - \tilde  \rho_f H_{\tau}] = E_m^{\tau}- {\rm tr} [\tilde  \rho_f   H_{\tau} ] .
\end{align}
This correctly reproduces the change of internal energy, $\Delta \tilde U = \Delta U = E_m^\tau -E_n^0= W$ associated with the trajectory from energies $E_n^0$ to $E_m^\tau$.  We therefore recover the full probability distribution in Eq. (1) of the manuscript.  




\textbf{Homodyne detection}---The qubit is realized by the near-resonant interaction of a transmon circuit   \cite{koch07}
 and a three-dimensional aluminum cavity  \cite{paik113D}
  which is coupled to a $50\  \Omega$ transmission line. The radiative interaction between the qubit and transmission line is given by the interaction Hamiltonian, $H_\mathrm{int.}=\hbar\gamma(a \sigma_+ + a^{\dagger} \sigma_ -)$, where $\gamma$ is the coupling rate between the electromagnetic field mode corresponding to $a$ ($a^\dagger$), the annihilation (creation) operator, and qubit state transitions by $\sigma_+$ ($\sigma_-$), the raising (lowering) ladder operator for the qubit. By virtue of this interaction Hamiltonian, a homodyne measurement along an arbitrary quadrature of the quantized electromagnetic field of the transmission line, $a e^{-\phi} + a^{\dagger} e^{+\phi}$, results in weak measurement along the corresponding dipole of the qubit, $\sigma_+ e^{-\phi} + \sigma_- e^{+\phi}$   \cite{nagh16}.
   Homodyne monitoring is performed with a  Josephson parametric amplifier \cite{cast08,hatr11para}   operated in phase-sensitive mode. We adjust the homodyne detection quadrature such that the homodyne signal $dV_t$ obtained over the time interval $(t, t+dt)$ provides an indirect signature  \cite{jord15}     of the real part of $\sigma_- = (\sigma_x+i\sigma_y)/2$. The detector signal  is given by $d V_t = \sqrt{\eta}\gamma \langle \sigma_x \rangle dt + \sqrt{\gamma} dX_t$, where $dX_t$ is a zero-mean Gaussian random variable that arises due to the quantum fluctuations of the field mode.

\textbf{ Heat and work tracking}---The stochastic master equation (Eq. 3) is used to update state of the qubit conditioned on the collected homodyne signal which is digitized in $20$ ns steps, and scaled such that its variance is $\gamma dt$.  \comm{Our identification of work and heat as the respective unitary and nonunitary changes of the state applies in the laboratory frame. However, it is convenient to calculate the state trajectories in the frame rotating with the qubit drive, yet we can still identify these energy changes in the rotating frame.} The discretized stochastic master equation (in It$\hat{\mathrm{o}}$ form) is used to obtain evolution of the qubit in the rotating frame  \cite{nagh16caustic}.
% \begin{align}\label{eq:smez}
% \begin{split}
% z[i+1] =& z[i] + \Omega x[i] dt+ \gamma (1-z[i]) dt\\ &
% +\sqrt{\eta} x[i] (1-z[i]) ( dV_t[i] - \gamma \sqrt{\eta} x[i] dt)\\ 
% x[i+1] =& x[i] -\Omega z[i+1] dt-\frac{\gamma}{2} x[i] dt \\ &
% +\sqrt{\eta} (1-z[i] - x[i]^2)(dV_t[i] -\gamma \sqrt{\eta} x[i] dt ) ,
% \end{split}
% \end{align}
\begin{align}
d\tilde{\rho}_{00}[i] =&    \Omega_\mathrm{R} \tilde{\rho}_{01}[i] dt +  \gamma(1-\tilde{\rho}_{00}[i]) dt \nonumber \\ &+ \sqrt{\eta}(dV[i]-\sqrt{\eta} \gamma 2 \tilde{\rho}_{01}[i] dt) \\ &\quad \quad \quad \times 2\tilde{\rho}_{01}[i] (1-\tilde{\rho}_{00}[i]),\nonumber\\
d \tilde{\rho}_{01}[i] =& \Omega_\mathrm{R} (1/2-\tilde{\rho}_{00}[i]) dt  -\gamma \tilde{\rho}_{01}[i]/2 dt \nonumber \\ &+ \sqrt{\eta}(dV[i]-\sqrt{\eta}\gamma 2 \tilde{\rho}_{01}[i]dt) \\ &\quad \quad \quad \times (1-\tilde{\rho}_{00}[i]-2\tilde{\rho}^2_{01}[i]).\nonumber
\end{align}  \label{sme:ito}


%
%\begin{align}
%d\rii[i] =   + \Omega \roi[i&] dt -  \gamma\rii[i] dt \nonumber \\ &- \sqrt{\eta}(dV[i]-\sqrt{\eta} \gamma 2 \roi[i] dt) \\ &\quad \quad \quad \times (2\roi[i] \rii[i])\nonumber\\
%\roi[i+1]  	 =- \Omega \roi[i&] dt  -\gamma \roi[i]/2 dt \nonumber \\ &+ \sqrt{\eta}(dV[i]-\sqrt{\eta}\gamma 2 \roi[i]dt) \\ &\quad \quad \quad \times (\rii[i]-2\roi[i] \roi[i])\nonumber
%\end{align} \label{sme:ito}

Each time-step $i$ is divided into two sub-steps. The first sub-step updates the $\tilde{\rho}(t)$ by the unitary terms. Subsequently, in the second sub-step $\tilde{\rho}(t)$ updated by the nonunitary terms   \cite{alon16}.
 Therefore, in each time step, we accordingly distinguish between instantaneous work and instantaneous heat \addkm{and can determine these energy changes in the lab frame.}


\textbf{Feedback}---In this section, we analyze in detail the feedback protocol used in the experiment and compare it with optimal feedback protocols in the presence of finite efficiency and feedback loop delay.


If $\eta=1$ the state of the system is pure at any time, and is described by a vector on the surface of the Bloch sphere. An ideal feedback loop would then exactly and immediately compensate for the heat exchanged with the environment resulting in completely unitary evolution of the state. 
\addkm{This is not possible at finite inefficiency, where the evolution of the system is no longer constrained to the surface of the Bloch sphere. Since the evolution due to the feedback protocol is unitary, it preserves the length of the Bloch vector, and cannot restore unitary evolution once purity has been lost. } Therefore, it is impossible to exactly compensate for the exchanged heat with a unitary operation. %This means even if we have immediate access to $x$ and $z$ and able to respond immediately we would not perfectly close the system and recover full contrast unitary evolution. In reality, Feedback loop delay also reduces the efficiency of the feedback.\\

Given access to the trajectory in real time, the best possible feedback is to maintain the phase of the oscillation as if it were to undergo closed unitary evolution (Extended Data Fig.\ \ref{sub1}a). In this case, the feedback output would be 
$\Omega_\mathrm{F} dt=- \theta_Q $ where $\theta_Q$ can be calculated by the state of the qubit at $t$ and $t+dt$. In this case we would not have control over the purity of the state and it will change by measurement back-action from point to point. Extended Data Figure~\ref{sub1} shows simulation results for this type of feedback for $35\%$ quantum efficiency. As depicted in Extended Data Figure~\ref{sub1}b, the exchanged heat contribution is compensated by the feedback contribution. The scatter plot in Extended Data Figure \ref{sub1}(c) shows the anti-correlation of these contributions. Therefore, as we expect, the system will behave more like a closed system and we observe persistent Rabi oscillations with $70 \%$ of full contrast (Extended Data Fig.\ \ref{sub1}d). However, a realistic feedback loop would also have a finite loop delay, given by the time it takes for the measurement signal to travel to a detector and for the feedback output to be calculated. Considering a feedback loop delay of $\sim 500$ ns  \cite{camp13strob,Rist12},
 Extended Data Figure \ref{sub1}(d) (blue curve) shows that the feedback performance would be reduced.

\setcounter{figure}{0}

\begin{figure}
\renewcommand\figurename{Extended Data Figure}
  \begin{center}
    \includegraphics[width=0.5\textwidth]{sub1.pdf}Extended Data
  \end{center}
  \vspace{-.2in}
  \caption{ \textbf{Simulation of optimal unitary feedback.} \small  {\bf a}, Schematic of the feedback operation, the qubit evolution from $A$ at time $t$ to $C$ at time $t+dt$ comprises of two different type of evolution; a unitary evolution due to the Rabi drive ($A \rightarrow B$) and a stochastic evolution due to coupling to the environment. Because the environment is monitored with sub-unity quantum efficiency we effectively average over some of the stochastic evolution reducing the state purity  ($B \rightarrow C$). The ideal unitary feedback maintains the phase relation with unitary evolution by application of a rotation $-\theta_Q$ to state $B'$. {\bf b}, Instantaneous contribution of heat and feedback to the transition probability $P_{0,0}$ for a single run of experiment. {\bf c}, Scatter plot of the instantaneous heat versus feedback for 100 runs of experiment which shows anti-correlation ($r=-0.9$) between feedback and heat contribution to transition probability $P_{00}$. {\bf d}, Ensemble behavior of the trajectories in presence of feedback with no delay (red) and $500$ ns loop delay (blue) showing a persistent Rabi oscillations. }\label{sub1}
\end{figure}

The feedback loop implemented in our experiment differs from the optimal feedback in that it does not require real-time state tracking and error processing.  This feedback takes a copy of homodyne signal,  $dV_t$, and multiplies it by a sinusoidal reference signal, $A\left[\sin(\Omega_R t + \phi)+ B\right]$ resulting in a feedback signal $\Omega_\mathrm{F}$, which is used to modulate the drive amplitude. %to compensate for heat in each time step (In our experiment $A=1$v for $\Omega_R=1$MHz and $B=-1$v) The output of feedback loop then mixed with qubit frequency and added to the drive.


This feedback loop essentially implements a phase-locked loop, and in order to clarify how the loop works we may cast the stochastic master equation (3) in terms of the Bloch components $x$ and $z$,
\begin{align}\label{eq:smezz}
\begin{split}
dz =& + \Omega x dt\\ &+ \gamma (1-z) dt
+\sqrt{\eta} x (1-z) ( dV_t - \gamma \sqrt{\eta} x dt)\\ 
dx =& -\Omega z dt\\ &-\frac{\gamma}{2} x dt 
+\sqrt{\eta} (1-z - x^2)(dV_t -\gamma \sqrt{\eta} x dt ) .
\end{split}
\end{align}
It is apparent that by canceling the last two terms, the evolution would be a completely unitary evolution as we expect from a closed system. However, with only unitary rotations we can change $dz$ and $dx$ in the following way,
\begin{eqnarray}
dz = \Omega_\mathrm{F} x dt ,\quad 
 dx = -\Omega_\mathrm{F} z dt, \label{xf}
\end{eqnarray}
where, we wish to cancel all the stochastic terms in (\ref{eq:smezz}) with the unitary terms (\ref{xf}).
%\begin{subequations}
%\begin{eqnarray}
%\Omega_f x dt &\nleftrightarrow &  + \gamma (1-z) dt
%+\sqrt{\eta} x (1-z) ( dI_t - \gamma \sqrt{\eta} x dt), \label{cancelz}\\
% -\Omega_f z dt & \nleftrightarrow &  -\frac{\gamma}{2} x dt 
%+\sqrt{\eta} (1-z - x^2)(dI_t -\gamma \sqrt{\eta} x dt ). \label{cancelx}
%\end{eqnarray}
%\end{subequations}
Regardless how complicated $\Omega_\mathrm{F}$ is, with finite efficiency, it is impossible to compensate for all terms as mentioned earlier and the best choice recovers about $70 \%$ of contrast for 35\% quantum efficiency. To understand how the phase-locked loop approximates the optimal feedback, we consider just the $z$ component of the state. This is reasonable since all thermodynamics parameters e.g. work, heat and transition probabilities directly relate to the $z$ component. This requires $\Omega_\mathrm{F} x dt = -\sqrt{\eta} x (1-z) ( dV_t - \gamma \sqrt{\eta} x dt)$, where for weak measurement $\gamma \sqrt{\eta} x dt$ is negligible compared to $dV_t$.  Thus, we have  $\Omega_\mathrm{F}  = - \sqrt{\eta} (1-z) dV_t/dt $. The essence of the phase-locked loop is to replace $z$ with $\cos(\Omega t + \phi)$, which is the ``target" $z$ that would be obtained for closed evolution. Here $\phi=0\ (\pi)$ for an initial ground (excited) state. This choice for $z$ has two-fold effect: not only it is a reasonable approximation for $z$ in presence of feedback but it also locks the phase of oscillation which addresses the damping term in (\ref{eq:smezz}). Note that the choice of phase $\phi$ only affects the transient behavior and appears as a overall phase shift in the persistent Rabi oscillations without affecting the contrast. Thus the feedback signal is,
\begin{subequations}
\begin{eqnarray}
\Omega_\mathrm{F}  =  \sqrt{\eta} (\cos(\Omega t + \phi)-1) dV_t/dt , \label{jcancelz}
\end{eqnarray}
\end{subequations}
This equation suggests that the scale for feedback should be around $A=\sqrt{\eta}/dt \sim 30$ which is in agreement with optimal value found empirically in the experiment of $A=34$. Experimentally, this factor may be set by pre-amplification of homodyne signal. Note that this result also suggests the offset term of $B=-1$ as we use in our feedback setup. Extended Data Figure~\ref{sub2} shows the simulation result for the phase-locked feedback with $35 \%$ quantum efficiency.

\begin{figure}
\renewcommand\figurename{Extended Data Figure}
  \begin{center}
    \includegraphics[width=0.5\textwidth]{sub2.pdf}
  \end{center}
  \vspace{-.2in}
  \caption{ \textbf{Simulation of phase-lock feedback.} \small   {\bf a}, Instantaneous contribution of heat and feedback to the transition probability $P_{00}$ for a single run of experiment. {\bf b}, Scatter plot of instantaneous heat versus feedback for 100 runs of experiment which shows anti-correlation  ($r=-0.81$) between the feedback and heat contributions to transition probability $P_{0,0}$. {\bf c}, Ensemble behavior of the trajectories in presence of feedback with no delay (red) and $100$ ns loop delay (blue) showing a persistent Rabi oscillations. {\bf d}, Simulated feedback efficiency versus feedback scale ($A$) and offset $(B)$.  The green dot indicates the expected parameters for optimal feedback.}\label{sub2}
\end{figure}

As we see in Extended Data Figure~\ref{sub2}(a,b), the phase-locked feedback loop effectively compensates for the heat at each point in time. Extended Data Figure~\ref{sub2}(c) shows persistent Rabi oscillations for this case. In Extended Data Figure \ref{sub2}(d), we explore the contrast of persistent Rabi oscillations versus feedback parameters: feedback scale and offset. The simulated result shows that maximum contrast occurs around $B \sim -1$ and $A \sim 35$ as we expect.

\textbf{Calculation of the Efficacy}---
Kafri and Deffner  \cite{kafr12}  have derived a generalization of the Jarzynski equality to account for information lost to the environment due to finite efficiency. In this section, we summarize how the efficacy displayed in Figure 3, is calculated from the quantum trajectory data. The efficacy is defined as,
%\begin{equation}
%\gamma_q= \langle \exp(- \Delta a) \rangle, 
%\end{equation}
%where $P(\Delta a) = \sum_{m,n} \delta(\Delta a - \Delta a_{m,n}) P_{m\rightarrow n}$. and $P_{m\rightarrow n}$ is transition probability from $n$ to $m$. And $\gamma$ is defined in equation ((6)) in  \cite{dvir12} ( I use ((?)) to refer equations in Sebastian's paper).\\
%
%Lets first translate Sebastian's notation:
%$A^i , A^f$ are measurement operator (observable) at initial and final points which in our case let say it is $A^i=A^f=\beta H(0)= - \beta /2 \sigma_z$ (in our conventional scaled notation). $a_i$ is eigenvalue for observable $A^i$. In our case $a_{0(1)}=\frac{\beta}{2} (-\frac{\beta}{2})$ ( $\hbar=1$).\\
%Now Lets verify that ((5)) gives us Jarzynski.  For that we have
%\begin{equation}
%\begin{split}
%\langle exp(- \Delta a) \rangle =& P(\Delta a_{00}) e^{P(\Delta a_{00})} + P(\Delta a_{11}) e^{P(\Delta a_{11})} \\ & + P(\Delta a_{10}) e^{P(\Delta a_{10})} + P(\Delta a_{01}) e^{P(\Delta a_{01})} 
%\end{split}
%\label{effi1}
%\end{equation}
%Here $a_{m,n}$'s are eigenvalues of the measurement operators at initial and final points. In our case $\Delta a_{m,n}= \frac{\beta}{2}( z_m - z_n)$. So we have
%\begin{equation}
%\begin{split}
%\langle exp(- \Delta a) \rangle =& P_{0\rightarrow 0}  + P_{1\rightarrow 1} \\ & + P_{1\rightarrow 0} e^{-\beta} + P_{0\rightarrow 1} e^{+\beta} 
%\end{split}
%\label{effi2}
%\end{equation}
%Then we substitute for $P_{m\rightarrow n}=P_n P_{m,n}$,
%\begin{equation}
%\begin{split}
%\langle exp(- \Delta a) \rangle =& \frac{1}{1+e^{-\beta}} [  P_{0,0} + e^{-\beta} P_{1,1}\\ & +  P_{1,0} e^{-\beta} + e^{-\beta} P_{0,1} e^{+\beta} ]
%\end{split}
%\label{effi3}
%\end{equation}
%Which is exactly Left-hand-side of Jarsynski. We know that $P_{n,n} = 1-P_{m,n},n \neq m$ So we have,
%\begin{equation}
%\begin{split}
%\langle exp(- \Delta a) \rangle =& \frac{1}{1+e^{-\beta}} [  P_{0,0}(1-e^{-\beta}) - P_{1,1} (1-e^{-\beta}) + 1+e^{ -\beta} ] \\
%\gamma =&\tanh(\beta/2) [P_{0,0} - P_{1,1} ]+1
%\end{split}
%\label{effi4}
%\end{equation}
%This is exactly what we have from Jarzynski. As Sebastian mentions later on in his paper(top-left page 2). And because our measurement operator (Projective measurement) is proportional to initial Hamiltonian. SO by definition the deviation is efficacy.\\
%Now lets study equation ((6)) which comes from trajectories 

\begin{equation}
\begin{split}
\gamma_q =& \mbox{tr}[\exp(-A^\mathrm{f}) \mathbb{E} (M^\mathrm{i}(\rho_0) \exp(A^\mathrm{i}))]
\end{split}
\label{effi5}
\end{equation}
 where $A^\mathrm{i} , A^\mathrm{f}$ are the measurement operators that characterize the initial and final states of the qubit.  We will let $A^\mathrm{i}=A^\mathrm{f}=\beta H(0)= - \beta /2 \sigma_z$ to describe the initial and final energy states. $M^\mathrm{i}(\rho_0)$ denotes the state at the beginning of the measurement and feedback protocol, which in our case is simply $M^\mathrm{i}(\rho_0) = \rho_0$ because the measurement operator and initial state commute, and $\mathbb{E}$ represents the linear map of the state described by the quantum trajectory evolution. The initial state $\rho_0$ is given by,
% So we have
%\begin{equation}
%\begin{split}
%\gamma =& \mbox{tr}[\exp(-A^f) \mathbb{E} (\rho_0 \exp(A^i))]
%\end{split}
%\label{effi5}
%\end{equation}
\begin{align}
\rho_0 \exp(-\beta \sigma_z/2)= \nonumber& \\ \frac{1}{e^{+\beta/2} + e^{-\beta/2}} &\left[ \ e^{+\beta/2} |0\rangle\langle0| + e^{-\beta/2} |1\rangle\langle1| \ \right].
\end{align}
% we set $A^\mathrm{i}= -\frac{\beta}{2} \sigma_z$ (as this suggested by Sebastian and we saw that this gives us Jarzynski).
We therefore apply the linear map $\mathbb{E}$ of the quantum trajectory evolution to the (unnormalized) state, 
\begin{equation}
\rho_0= \frac{1}{e^{+\beta/2} + e^{-\beta/2}} \left[ \  |0\rangle\langle0| +  |1\rangle\langle1| \ \right] \label{effi6}
\end{equation}
 which is simply a completely mixed state. The outcome of the map $\mathbb{E}$ on this mixed state can be determined by averaging the quantum trajectories with equal weighting from the ground and excited initial states:
\begin{equation}
\begin{split}
 \mathbb{E} [& \rho_0 \exp(-\beta \sigma_z/2) ] =  \\ & \frac{1}{e^{+\beta/2} + e^{-\beta/2}} \bigl[ \  C_{00}(t)|0\rangle\langle0| + C_{11}(t)|1\rangle\langle1| + \\ &\quad \quad \quad\quad \quad \quad \quad+ C_{01}(t)|0\rangle\langle1|  + C_{10}(t)|1\rangle\langle0| \ \bigr],
\end{split}
\label{effi7}
\end{equation}
where the coefficients $C_{nm}$ are determined from the equally weighted averaged trajectories.\begin{equation}
\begin{split}
C_{00}(t)=& \frac{1}{N}\sum_{k=0}^{N} [ \rho^{(g)}_{00}(t) + \rho^{(e)}_{00}(t)]\\ 
C_{11}(t)=& \frac{1}{N} \sum_{k=0}^{N} [\rho^{(g)}_{11}(t) + \rho^{(e)}_{11}(t)]
\end{split}
\label{effi10}
\end{equation}
The superscripts $(g)$ and $(e)$ specify the initial state for the individual trajectories and we average $N= 500$ trajectories for each preparation. The efficacy $\gamma_q$ shown in Figure 3 in the main text is determined from the coefficients (\ref{effi10}) which are in turn used  in (\ref{effi5}) via (\ref{effi7}).

\textbf{Jarzynski equality at higher quantum efficiency}---In Extended Data Figure \ref{fig:jar} we show the change in free energy obtained for different values of the quantum efficiency.  We find that the remaining violations of the Jarzynski equality are reduced as the quantum efficiency is increased.  For the simulations with non-unity quantum efficiency, we use the It$\hat{\mathrm{o}}$ form of stochastic master equation (Eqs.~\ref{eq:smezz}) to simulate trajectories for finite efficiencies, which is consistent with the state update used in the experiment. For the unity efficiency feedback simulation we instead use the Stratonovich form of the stochastic master equation  \cite{jord15}. 
%\begin{align}\label{eq:smez}
%\begin{split}
%dz =& + \Omega x dt + \gamma (1-z)(1-\frac{\eta(1-z)}{2}) dt \\ &
%+\sqrt{\eta} x (1-z) ( dV_t - \gamma \sqrt{\eta} x dt)\\ 
%dx =& -\Omega z dt -\frac{\gamma}{2} (1-\eta(1-z)) x dt \\ &
%+\sqrt{\eta} (1-z - x^2)(dV_t -\gamma \sqrt{\eta} x dt ).
%\end{split}
%\end{align}

\begin{figure}[!htb]
\renewcommand\figurename{Extended Data Figure}
\begin{center}
\includegraphics[width =.5\textwidth]{sup_4_jar}
\end{center}
\caption{ {\bf Quantum Jarzynski equality.}  Free energy difference calculated by the Jarzynski equality via the work distribution inferred from the measured transition probabilities at $\beta/(\hbar \omega_\mathrm{q})= 3.5$. Left panel shows that Feedback reduces the heat contributions to the transition probability showing better agreement with the expected $\Delta F = 0$.  Simulations (dashed lines, right panel) show agreement with the experimental data (solid lines) and indicate how the remaining deviations from the Jarzynski equality vanish as the measurement quantum efficiency is improved.}  \label{fig:jar}
\end{figure}

\textbf{Experimental setup and parameters---}The transmon circuit was fabricated using double angle evaporation of aluminum on a high resistivity silicon substrate. The circuit was placed at the center of a 3D aluminum waveguide cavity which was machined from 6061 aluminum. The bare cavity frequency is $\omega_\mathrm{c}/2\pi=7.257$ GHz. The near-resonant interaction between the circuit and the cavity (characterized by coupling rate $g/2 \pi = 136$ MHz) results in hybrid states, as described by the Jaynes-Cummings Hamiltonian. The lowest energy transition of hybrid states ($\omega_\mathrm{q}/2\pi=6.541$ GHz) can therefore be considered a ``one-dimensional" artificial atom because the radiative decay of the system is dominated by the cavity's coupling to a  50 $\Omega$ transmission line, characterized by a quality factor $Q=630$.  This radiative decay was characterized by a decay of rate $\gamma=1.7$ $\mu$s$^{-1}$. Resonance fluorescence  from the artificial atom is amplified by a near-quantum-limited Josephson parametric amplifier, consisting of a $1.5$ pF capacitor, shunted by a Superconducting Quantum Interference Device (SQUID) composed of two $I_0 = 1\ \mu $A Josephson junctions.
The amplifier produces 20 dB of gain with an instantaneous 3-dB-bandwidth of 50 MHz. The quantum efficiency was measured to be 35\%. We drive the qubit by sending a resonant coherent signal via a weakly coupled transmission line, and the strength of the drive is characterized by a Rabi frequency of $\Omega/2\pi \simeq 1$ MHz. The total loop delay for the feedback is 100 ns. The initial state fidelity was limited by a 3\% thermal population of the excited state. 

\begin{figure}
\renewcommand\figurename{Extended Data Figure}
\begin{center}
\includegraphics[width =.5\textwidth]{schematic.pdf}
\end{center}
\caption{\small {\bf Experimental setup} The qubit and Josephson parametric amplifier share a signal generator to maintain the phase relation defining the amplification quadrature. We use a double side-band technique to pump the parametric amplifier. The homodyne signal is split in two for the purpose of feedback and state tracking. Both the feedback signal and homodyne signal are digitized for state tracking in a post-processing step.}
\label{fig:schematic}
\end{figure}



\textbf{Statistical Analysis---}Error bars reported in Figure 1 indicate the standard error of the mean for binomial data, which are subsequently scaled by the readout fidelity.  On average 300 projective energy measurements were used for the determination of $\Delta U$ at each time point in  Figure 1d. The number of data points for each value reported in Figure 1e is shown in the inset. In Figure 3, the shaded regions indicate the standard error of the mean based on binomial data used to determine the work distribution and the standard error of the mean based on the trajectories used to calculate the efficacy.

%\bibliographystyle{naturemag}
%\bibliographystyle{unsrt_withcaps}
%\bibliography{ppp_references-1}

\begin{thebibliography}{10}

\bibitem{jar11}
C.~Jarzynski.
\newblock Equalities and Inequalities: Irreversibility and the Second Law of
  Thermodynamics at the Nanoscale.
\newblock {\em C. Annu. Rev. Condens. Matter Phys.}, 2:329, 2011.

\bibitem{sei12}
Udo Seifert.
\newblock Thermodynamics, Fluctuation Theorems and Molecular Machines.
\newblock {\em Rep. Prog. Phys.}, 75:126001, 2012.

\bibitem{cil13}
S.~Ciliberto, R.~Gomez-Solano, and A.~Petrosyan.
\newblock Fluctuations, Linear Response, and Currents in Out-of-Equilibrium
  Systems.
\newblock {\em C. Annu. Rev. Condens. Matter Phys.}, 4:235, 2013.

\bibitem{lip02}
Jan Liphardt, Sophie Dumont, Steven~B. Smith, Ignacio Tinoco, and Carlos
  Bustamante.
\newblock Equilibrium Information from Nonequilibrium Measurements in an
  Experimental Test of Jarzynski's Equality.
\newblock {\em Science}, 296(5574):1832--1835, 2002.

\bibitem{wan02}
G.~M. Wang, E.~M. Sevick, Emil Mittag, Debra~J. Searles, and Denis~J. Evans.
\newblock Experimental Demonstration of Violations of the Second Law of
  Thermodynamics for Small Systems and Short Time Scales.
\newblock {\em Phys. Rev. Lett.}, 89:050601, 2002.

\bibitem{bli06}
V.~Blickle, T.~Speck, L.~Helden, U.~Seifert, and C.~Bechinger.
\newblock Thermodynamics of a Colloidal Particle in a Time-Dependent
  Nonharmonic Potential.
\newblock {\em Phys. Rev. Lett.}, 96:070603, 2006.

\bibitem{gal16}
R~Gallego, J~Eisert, and H~Wilming.
\newblock Thermodynamic work from operational principles.
\newblock {\em New Journal of Physics}, 18(10):103017, 2016.

\bibitem{alon16}
Jose~Joaquin Alonso, Eric Lutz, and Alessandro Romito.
\newblock Thermodynamics of Weakly Measured Quantum Systems.
\newblock {\em Phys. Rev. Lett.}, 116:080403, Feb 2016.

\bibitem{elou17}
Cyril Elouard, David~A. Herrera-Mart\`i, Maxime Clusel, and Alexia Auff\'eves.
\newblock The role of quantum measurement in stochastic thermodynamics.
\newblock {\em npj Quantum Information}, 3:9, 2017.

\bibitem{deff16}
Sebastian Deffner, Juan~Pablo Paz, and Wojciech~H. Zurek.
\newblock Quantum work and the thermodynamic cost of quantum measurements.
\newblock {\em Phys. Rev. E}, 94:010103, Jul 2016.

\bibitem{kamm16}
P.~Kammerlander and J.~Anders.
\newblock Coherence and measurement in quantum thermodynamics.
\newblock {\em Scientific Reports}, 6:22174, Feb 2016.

\bibitem{cott17}
Nathana{\"e}l Cottet, S{\'e}bastien Jezouin, Landry Bretheau, Philippe
  Campagne-Ibarcq, Quentin Ficheux, Janet Anders, Alexia Auff{\`e}ves, R{\'e}mi
  Azouit, Pierre Rouchon, and Benjamin Huard.
\newblock Observing a quantum Maxwell demon at work.
\newblock {\em Proceedings of the National Academy of Sciences},
  114(29):7561--7564, 2017.

\bibitem{jarz1997}
C.~Jarzynski.
\newblock Nonequilibrium Equality for Free Energy Differences.
\newblock {\em Phys. Rev. Lett.}, 78:2690--2693, Apr 1997.

\bibitem{kafr12}
Dvir Kafri and Sebastian Deffner.
\newblock Holevo's bound from a general quantum fluctuation theorem.
\newblock {\em Phys. Rev. A}, 86:044302, Oct 2012.

\bibitem{pip66}
A.~B. Pippard.
\newblock {\em Elements of Classical Thermodynamics}.
\newblock Cambridge, 1966.

\bibitem{talk07}
Peter Talkner, Eric Lutz, and Peter H\"anggi.
\newblock Fluctuation theorems: Work is not an observable.
\newblock {\em Phys. Rev. E}, 75:050102, May 2007.

\bibitem{bata2014}
Tiago~B. Batalh\~ao, Alexandre~M. Souza, Laura Mazzola, Ruben Auccaise,
  Roberto~S. Sarthour, Ivan~S. Oliveira, John Goold, Gabriele De~Chiara, Mauro
  Paternostro, and Roberto~M. Serra.
\newblock Experimental Reconstruction of Work Distribution and Study of
  Fluctuation Relations in a Closed Quantum System.
\newblock {\em Phys. Rev. Lett.}, 113:140601, Oct 2014.

\bibitem{shuo2015}
Shuoming An, Jing-Ning Zhang, Mark Um, Dingshun Lv, Yao Lu, Junhua Zhang,
  Zhang-Qi Yin, H.~T. Quan, and Kihwan Kim.
\newblock Experimental test of the quantum Jarzynski equality with a
  trapped-ion system.
\newblock {\em Nature Physics}, 11:193199, Dec 2015.

\bibitem{cam11}
Michele Campisi, Peter H\"anggi, and Peter Talkner.
\newblock Quantum fluctuation relations: Foundations and applications.
\newblock {\em Rev. Mod. Phys.}, 83:771--791, 2011.

\bibitem{dere08}
Jan Derezi{\'{n}}ski, Wojciech De~Roeck, and Christian Maes.
\newblock Fluctuations of Quantum Currents and Unravelings
  of�Master�Equations.
\newblock {\em Journal of Statistical Physics}, 131(2):341--356, Apr 2008.

\bibitem{horo12}
Jordan~M. Horowitz.
\newblock Quantum-trajectory approach to the stochastic thermodynamics of a
  forced harmonic oscillator.
\newblock {\em Phys. Rev. E}, 85:031110, Mar 2012.

\bibitem{koch07}
Jens Koch, Terri~M. Yu, Jay Gambetta, A.~A. Houck, D.~I. Schuster, J.~Majer,
  Alexandre Blais, M.~H. Devoret, S.~M. Girvin, and R.~J. Schoelkopf.
\newblock Charge-insensitive qubit design derived from the Cooper pair box.
\newblock {\em Phys. Rev. A}, 76:042319, Oct 2007.

\bibitem{paik113D}
Hanhee Paik, D.~I. Schuster, Lev~S. Bishop, G.~Kirchmair, G.~Catelani, A.~P.
  Sears, B.~R. Johnson, M.~J. Reagor, L.~Frunzio, L.~I. Glazman, S.~M. Girvin,
  M.~H. Devoret, and R.~J. Schoelkopf.
\newblock Observation of High Coherence in Josephson Junction Qubits Measured
  in a Three-Dimensional Circuit QED Architecture.
\newblock {\em Phys. Rev. Lett.}, 107:240501, Dec 2011.

\bibitem{murc13}
K.~W. Murch, S.~J. Weber, K.~M. Beck, E.~Ginossar, and I.~Siddiqi.
\newblock Reduction of the radiative decay of atomic coherence in squeezed
  vacuum.
\newblock {\em Nature}, 499:62--65, 2013.

\bibitem{nagh16}
M.~Naghiloo, N.~Foroozani, D.~Tan, A.~Jadbabaie, and K.~W. Murch.
\newblock Mapping quantum state dynamics in spontaneous emission.
\newblock {\em Nature Communications}, 7:11527, 2016.

\bibitem{camp16}
P.~Campagne-Ibarcq, P.~Six, L.~Bretheau, A.~Sarlette, M.~Mirrahimi, P.~Rouchon,
  and B.~Huard.
\newblock Observing Quantum State Diffusion by Heterodyne Detection of
  Fluorescence.
\newblock {\em Phys. Rev. X}, 6:011002, Jan 2016.

\bibitem{bolu14}
Anders Bolund and Klaus M\o{}lmer.
\newblock Stochastic excitation during the decay of a two-level emitter subject
  to homodyne and heterodyne detection.
\newblock {\em Phys. Rev. A}, 89:023827, Feb 2014.

\bibitem{hekk13}
F.~W.~J. Hekking and J.~P. Pekola.
\newblock Quantum Jump Approach for Work and Dissipation in a Two-Level System.
\newblock {\em Phys. Rev. Lett.}, 111:093602, Aug 2013.

\bibitem{reed10}
M.~D. Reed, L.~DiCarlo, B.~R. Johnson, L.~Sun, D.~I. Schuster, L.~Frunzio, and
  R.~J. Schoelkopf.
\newblock High-Fidelity Readout in Circuit Quantum Electrodynamics Using the
  Jaynes-Cummings Nonlinearity.
\newblock {\em Phys. Rev. Lett.}, 105:173601, Oct 2010.

\bibitem{wis10}
G.~Milburn H.~W~Wiseman.
\newblock {\em Quantum Measurement and Control}.
\newblock Cambridge, 2010.

\bibitem{gong16}
Zongping Gong, Yuto Ashida, and Masahito Ueda.
\newblock Quantum-trajectory thermodynamics with discrete feedback control.
\newblock {\em Phys. Rev. A}, 94:012107, Jul 2016.

\bibitem{vija12}
R.~Vijay, C.~Macklin, D.~H. Slichter, S.~J. Weber, K.~W. Murch, R.~Naik, A.~N.
  Korotkov, and I.~Siddiqi.
\newblock Stabilizing Rabi oscillations in a superconducting qubit using
  quantum feedback.
\newblock {\em Nature}, 490:77, 2012.

\bibitem{par15}
Juan M.~R. Parrondo, Jordan~M. Horowitz, and Takahiro Sagawa.
\newblock Thermodynamics of information.
\newblock {\em Nature Physics}, 11:131, 2015.

\bibitem{gem04}
G.~Mahler J.~Gemmer, M.~Michel.
\newblock {\em Quantum Thermodynamics}.
\newblock Springer, 2004.

\bibitem{kos14}
Ronnie Kosloff and Amikam Levy.
\newblock Quantum Heat Engines and Refrigerators: Continuous Devices.
\newblock {\em Annual Review of Physical Chemistry}, 65(1):365--393, 2014.

\bibitem{raam15}
Raam Uzdin, Amikam Levy, and Ronnie Kosloff.
\newblock Equivalence of Quantum Heat Machines, and Quantum-Thermodynamic
  Signatures.
\newblock {\em Phys. Rev. X}, 5:031044, Sep 2015.

\bibitem{esp09}
Massimiliano Esposito, Upendra Harbola, and Shaul Mukamel.
\newblock Nonequilibrium fluctuations, fluctuation theorems, and counting
  statistics in quantum systems.
\newblock {\em Rev. Mod. Phys.}, 81:1665--1702, Dec 2009.

\bibitem{goo16}
John Goold, Marcus Huber, Arnau Riera, Lidia del Rio, and Paul Skrzypczyk.
\newblock The role of quantum information in thermodynamics - a topical review.
\newblock {\em Journal of Physics A: Mathematical and Theoretical},
  49(14):143001, 2016.

\bibitem{dre16}
Justin Dressel, Areeya Chantasri, Andrew~N. Jordan, and Alexander~N. Korotkov.
\newblock Arrow of Time for Continuous Quantum Measurement.
\newblock {\em arXiv:1610.03818}, 2016.

\bibitem{murc13traj}
K.~W. Murch, S.~J. Weber, C.~Macklin, and I.~Siddiqi.
\newblock Observing single quantum trajectories of a superconducting qubit.
\newblock {\em Nature}, 502:211, 2013.

\bibitem{webe14}
S.~J. Weber, A.~Chantasri, J.~Dressel, A.~N. Jordan, K.~W. Murch, and
  I.~Siddiqi.
\newblock Mapping the optimal route between two quantum states.
\newblock {\em Nature}, 511:570--573, 2014.

\bibitem{cast08}
M.~A. Castellanos-Beltran, K.~D. Irwin, G.~C. Hilton, L.~R. Vale, and K.~W.
  Lehnert.
\newblock Amplification and squeezing of quantum noise with a tunable Josephson
  metamaterial.
\newblock {\em Nature Physics}, 4:929--931, 2008.

\bibitem{hatr11para}
M.~Hatridge, R.~Vijay, D.~H. Slichter, John Clarke, and I.~Siddiqi.
\newblock Dispersive magnetometry with a quantum limited SQUID parametric
  amplifier.
\newblock {\em Phys. Rev. B}, 83:134501, Apr 2011.

\bibitem{jord15}
Andrew~N Jordan, Areeya Chantasri, Pierre Rouchon, and Benjamin Huard.
\newblock Anatomy of fluorescence: quantum trajectory statistics from
  continuously measuring spontaneous emission.
\newblock {\em Quantum Studies: Mathematics and Foundations}, pages 1--27,
  2015.

\bibitem{nagh16caustic}
M.~Naghiloo, D.~Tan, P.~M. Harrington, P.~Lewalle, A.~N. Jordan, and K.~W.
  Murch.
\newblock Quantum caustics in resonance fluorescence trajectories.
\newblock {\em arXiv:1612.03189}, 2016.

\bibitem{camp13strob}
P.~Campagne-Ibarcq, E.~Flurin, N.~Roch, D.~Darson, P.~Morfin, M.~Mirrahimi,
  M.~H. Devoret, F.~Mallet, and B.~Huard.
\newblock Persistent Control of a Superconducting Qubit by Stroboscopic
  Measurement Feedback.
\newblock {\em Phys. Rev. X}, 3:021008, May 2013.

\bibitem{Rist12}
D.~Rist\`e, C.~C. Bultink, K.~W. Lehnert, and L.~DiCarlo.
\newblock Feedback Control of a Solid-State Qubit Using High-Fidelity
  Projective Measurement.
\newblock {\em Phys. Rev. Lett.}, 109:240502, Dec 2012.

\end{thebibliography}

 
 {\bf Acknowledgements:} We acknowledge research support from the NSF (grant PHY-1607156) the ONR  (grant No. 12114811), the John Templeton Foundation, the EU Collaborative Project TherMiQ (Grant Agreement 618074), the COST Action MP1209,  and the EPSRC (Grant No. EP/P030815/1). This research used facilities at the Institute of Materials Science and Engineering at Washington University. K.M. acknowledges support from the Sloan Foundation.

{\bf Author Contributions:} M.N., D.T. and K.M. performed the experiments and analyzed the data.  J.A, E.L, and A.R contributed the theory.  All authors contributed to experimental design and writing the manuscript.

{\bf Author Information:} %Reprints and permissions information is available at www.nature.com/reprints.\\
%The authors declare no competing financial interests.\\
Correspondence and requests for materials should be addressed to murch@physics.wustl.edu.



\end{document}




1703.05885.extracted_bib
{jar11 C.~Jarzynski. \newblock Equalities and Inequalities: Irreversibility and the Second Law of Thermodynamics at the Nanoscale. \newblock {\em C. Annu. Rev. Condens. Matter Phys., 2:329, 2011.
1703.05885.extracted_bib
{sei12 Udo Seifert. \newblock Thermodynamics, Fluctuation Theorems and Molecular Machines. \newblock {\em Rep. Prog. Phys., 75:126001, 2012.
1703.05885.extracted_bib
{cil13 S.~Ciliberto, R.~Gomez-Solano, and A.~Petrosyan. \newblock Fluctuations, Linear Response, and Currents in Out-of-Equilibrium Systems. \newblock {\em C. Annu. Rev. Condens. Matter Phys., 4:235, 2013.
1703.05885.extracted_bib
{lip02 Jan Liphardt, Sophie Dumont, Steven~B. Smith, Ignacio Tinoco, and Carlos Bustamante. \newblock Equilibrium Information from Nonequilibrium Measurements in an Experimental Test of Jarzynski's Equality. \newblock {\em Science, 296(5574):1832--1835, 2002.
1703.05885.extracted_bib
{wan02 G.~M. Wang, E.~M. Sevick, Emil Mittag, Debra~J. Searles, and Denis~J. Evans. \newblock Experimental Demonstration of Violations of the Second Law of Thermodynamics for Small Systems and Short Time Scales. \newblock {\em Phys. Rev. Lett., 89:050601, 2002.
1703.05885.extracted_bib
{bli06 V.~Blickle, T.~Speck, L.~Helden, U.~Seifert, and C.~Bechinger. \newblock Thermodynamics of a Colloidal Particle in a Time-Dependent Nonharmonic Potential. \newblock {\em Phys. Rev. Lett., 96:070603, 2006.
1703.05885.extracted_bib
{gal16 R~Gallego, J~Eisert, and H~Wilming. \newblock Thermodynamic work from operational principles. \newblock {\em New Journal of Physics, 18(10):103017, 2016.
1703.05885.extracted_bib
{alon16 Jose~Joaquin Alonso, Eric Lutz, and Alessandro Romito. \newblock Thermodynamics of Weakly Measured Quantum Systems. \newblock {\em Phys. Rev. Lett., 116:080403, Feb 2016.
1703.05885.extracted_bib
{elou17 Cyril Elouard, David~A. Herrera-Mart\`i, Maxime Clusel, and Alexia Auff\'eves. \newblock The role of quantum measurement in stochastic thermodynamics. \newblock {\em npj Quantum Information, 3:9, 2017.
1703.05885.extracted_bib
{deff16 Sebastian Deffner, Juan~Pablo Paz, and Wojciech~H. Zurek. \newblock Quantum work and the thermodynamic cost of quantum measurements. \newblock {\em Phys. Rev. E, 94:010103, Jul 2016.
1703.05885.extracted_bib
{kamm16 P.~Kammerlander and J.~Anders. \newblock Coherence and measurement in quantum thermodynamics. \newblock {\em Scientific Reports, 6:22174, Feb 2016.
1703.05885.extracted_bib
{cott17 Nathana{\"el Cottet, S{\'ebastien Jezouin, Landry Bretheau, Philippe Campagne-Ibarcq, Quentin Ficheux, Janet Anders, Alexia Auff{\`eves, R{\'emi Azouit, Pierre Rouchon, and Benjamin Huard. \newblock Observing a quantum Maxwell demon at work. \newblock {\em Proceedings of the National Academy of Sciences, 114(29):7561--7564, 2017.
1703.05885.extracted_bib
{jarz1997 C.~Jarzynski. \newblock Nonequilibrium Equality for Free Energy Differences. \newblock {\em Phys. Rev. Lett., 78:2690--2693, Apr 1997.
1703.05885.extracted_bib
{kafr12 Dvir Kafri and Sebastian Deffner. \newblock Holevo's bound from a general quantum fluctuation theorem. \newblock {\em Phys. Rev. A, 86:044302, Oct 2012.
1703.05885.extracted_bib
{pip66 A.~B. Pippard. \newblock {\em Elements of Classical Thermodynamics. \newblock Cambridge, 1966.
1703.05885.extracted_bib
{talk07 Peter Talkner, Eric Lutz, and Peter H\"anggi. \newblock Fluctuation theorems: Work is not an observable. \newblock {\em Phys. Rev. E, 75:050102, May 2007.
1703.05885.extracted_bib
{bata2014 Tiago~B. Batalh\~ao, Alexandre~M. Souza, Laura Mazzola, Ruben Auccaise, Roberto~S. Sarthour, Ivan~S. Oliveira, John Goold, Gabriele De~Chiara, Mauro Paternostro, and Roberto~M. Serra. \newblock Experimental Reconstruction of Work Distribution and Study of Fluctuation Relations in a Closed Quantum System. \newblock {\em Phys. Rev. Lett., 113:140601, Oct 2014.
1703.05885.extracted_bib
{shuo2015 Shuoming An, Jing-Ning Zhang, Mark Um, Dingshun Lv, Yao Lu, Junhua Zhang, Zhang-Qi Yin, H.~T. Quan, and Kihwan Kim. \newblock Experimental test of the quantum Jarzynski equality with a trapped-ion system. \newblock {\em Nature Physics, 11:193199, Dec 2015.
1703.05885.extracted_bib
{cam11 Michele Campisi, Peter H\"anggi, and Peter Talkner. \newblock Quantum fluctuation relations: Foundations and applications. \newblock {\em Rev. Mod. Phys., 83:771--791, 2011.
1703.05885.extracted_bib
{dere08 Jan Derezi{\'{nski, Wojciech De~Roeck, and Christian Maes. \newblock Fluctuations of Quantum Currents and Unravelings of�Master�Equations. \newblock {\em Journal of Statistical Physics, 131(2):341--356, Apr 2008.
1703.05885.extracted_bib
{horo12 Jordan~M. Horowitz. \newblock Quantum-trajectory approach to the stochastic thermodynamics of a forced harmonic oscillator. \newblock {\em Phys. Rev. E, 85:031110, Mar 2012.
1703.05885.extracted_bib
{koch07 Jens Koch, Terri~M. Yu, Jay Gambetta, A.~A. Houck, D.~I. Schuster, J.~Majer, Alexandre Blais, M.~H. Devoret, S.~M. Girvin, and R.~J. Schoelkopf. \newblock Charge-insensitive qubit design derived from the Cooper pair box. \newblock {\em Phys. Rev. A, 76:042319, Oct 2007.
1703.05885.extracted_bib
{paik113D Hanhee Paik, D.~I. Schuster, Lev~S. Bishop, G.~Kirchmair, G.~Catelani, A.~P. Sears, B.~R. Johnson, M.~J. Reagor, L.~Frunzio, L.~I. Glazman, S.~M. Girvin, M.~H. Devoret, and R.~J. Schoelkopf. \newblock Observation of High Coherence in Josephson Junction Qubits Measured in a Three-Dimensional Circuit QED Architecture. \newblock {\em Phys. Rev. Lett., 107:240501, Dec 2011.
1703.05885.extracted_bib
{murc13 K.~W. Murch, S.~J. Weber, K.~M. Beck, E.~Ginossar, and I.~Siddiqi. \newblock Reduction of the radiative decay of atomic coherence in squeezed vacuum. \newblock {\em Nature, 499:62--65, 2013.
1703.05885.extracted_bib
{nagh16 M.~Naghiloo, N.~Foroozani, D.~Tan, A.~Jadbabaie, and K.~W. Murch. \newblock Mapping quantum state dynamics in spontaneous emission. \newblock {\em Nature Communications, 7:11527, 2016.
1703.05885.extracted_bib
{camp16 P.~Campagne-Ibarcq, P.~Six, L.~Bretheau, A.~Sarlette, M.~Mirrahimi, P.~Rouchon, and B.~Huard. \newblock Observing Quantum State Diffusion by Heterodyne Detection of Fluorescence. \newblock {\em Phys. Rev. X, 6:011002, Jan 2016.
1703.05885.extracted_bib
{bolu14 Anders Bolund and Klaus M\o{lmer. \newblock Stochastic excitation during the decay of a two-level emitter subject to homodyne and heterodyne detection. \newblock {\em Phys. Rev. A, 89:023827, Feb 2014.
1703.05885.extracted_bib
{hekk13 F.~W.~J. Hekking and J.~P. Pekola. \newblock Quantum Jump Approach for Work and Dissipation in a Two-Level System. \newblock {\em Phys. Rev. Lett., 111:093602, Aug 2013.
1703.05885.extracted_bib
{reed10 M.~D. Reed, L.~DiCarlo, B.~R. Johnson, L.~Sun, D.~I. Schuster, L.~Frunzio, and R.~J. Schoelkopf. \newblock High-Fidelity Readout in Circuit Quantum Electrodynamics Using the Jaynes-Cummings Nonlinearity. \newblock {\em Phys. Rev. Lett., 105:173601, Oct 2010.
1703.05885.extracted_bib
{wis10 G.~Milburn H.~W~Wiseman. \newblock {\em Quantum Measurement and Control. \newblock Cambridge, 2010.
1703.05885.extracted_bib
{gong16 Zongping Gong, Yuto Ashida, and Masahito Ueda. \newblock Quantum-trajectory thermodynamics with discrete feedback control. \newblock {\em Phys. Rev. A, 94:012107, Jul 2016.
1703.05885.extracted_bib
{vija12 R.~Vijay, C.~Macklin, D.~H. Slichter, S.~J. Weber, K.~W. Murch, R.~Naik, A.~N. Korotkov, and I.~Siddiqi. \newblock Stabilizing Rabi oscillations in a superconducting qubit using quantum feedback. \newblock {\em Nature, 490:77, 2012.
1703.05885.extracted_bib
{par15 Juan M.~R. Parrondo, Jordan~M. Horowitz, and Takahiro Sagawa. \newblock Thermodynamics of information. \newblock {\em Nature Physics, 11:131, 2015.
1703.05885.extracted_bib
{gem04 G.~Mahler J.~Gemmer, M.~Michel. \newblock {\em Quantum Thermodynamics. \newblock Springer, 2004.
1703.05885.extracted_bib
{kos14 Ronnie Kosloff and Amikam Levy. \newblock Quantum Heat Engines and Refrigerators: Continuous Devices. \newblock {\em Annual Review of Physical Chemistry, 65(1):365--393, 2014.
1703.05885.extracted_bib
{raam15 Raam Uzdin, Amikam Levy, and Ronnie Kosloff. \newblock Equivalence of Quantum Heat Machines, and Quantum-Thermodynamic Signatures. \newblock {\em Phys. Rev. X, 5:031044, Sep 2015.
1703.05885.extracted_bib
{esp09 Massimiliano Esposito, Upendra Harbola, and Shaul Mukamel. \newblock Nonequilibrium fluctuations, fluctuation theorems, and counting statistics in quantum systems. \newblock {\em Rev. Mod. Phys., 81:1665--1702, Dec 2009.
1703.05885.extracted_bib
{goo16 John Goold, Marcus Huber, Arnau Riera, Lidia del Rio, and Paul Skrzypczyk. \newblock The role of quantum information in thermodynamics - a topical review. \newblock {\em Journal of Physics A: Mathematical and Theoretical, 49(14):143001, 2016.
1703.05885.extracted_bib
{dre16 Justin Dressel, Areeya Chantasri, Andrew~N. Jordan, and Alexander~N. Korotkov. \newblock Arrow of Time for Continuous Quantum Measurement. \newblock {\em arXiv:1610.03818, 2016.
1703.05885.extracted_bib
{murc13traj K.~W. Murch, S.~J. Weber, C.~Macklin, and I.~Siddiqi. \newblock Observing single quantum trajectories of a superconducting qubit. \newblock {\em Nature, 502:211, 2013.
1703.05885.extracted_bib
{webe14 S.~J. Weber, A.~Chantasri, J.~Dressel, A.~N. Jordan, K.~W. Murch, and I.~Siddiqi. \newblock Mapping the optimal route between two quantum states. \newblock {\em Nature, 511:570--573, 2014.
1703.05885.extracted_bib
{cast08 M.~A. Castellanos-Beltran, K.~D. Irwin, G.~C. Hilton, L.~R. Vale, and K.~W. Lehnert. \newblock Amplification and squeezing of quantum noise with a tunable Josephson metamaterial. \newblock {\em Nature Physics, 4:929--931, 2008.
1703.05885.extracted_bib
{hatr11para M.~Hatridge, R.~Vijay, D.~H. Slichter, John Clarke, and I.~Siddiqi. \newblock Dispersive magnetometry with a quantum limited SQUID parametric amplifier. \newblock {\em Phys. Rev. B, 83:134501, Apr 2011.
1703.05885.extracted_bib
{jord15 Andrew~N Jordan, Areeya Chantasri, Pierre Rouchon, and Benjamin Huard. \newblock Anatomy of fluorescence: quantum trajectory statistics from continuously measuring spontaneous emission. \newblock {\em Quantum Studies: Mathematics and Foundations, pages 1--27, 2015.
1703.05885.extracted_bib
{nagh16caustic M.~Naghiloo, D.~Tan, P.~M. Harrington, P.~Lewalle, A.~N. Jordan, and K.~W. Murch. \newblock Quantum caustics in resonance fluorescence trajectories. \newblock {\em arXiv:1612.03189, 2016.
1703.05885.extracted_bib
{camp13strob P.~Campagne-Ibarcq, E.~Flurin, N.~Roch, D.~Darson, P.~Morfin, M.~Mirrahimi, M.~H. Devoret, F.~Mallet, and B.~Huard. \newblock Persistent Control of a Superconducting Qubit by Stroboscopic Measurement Feedback. \newblock {\em Phys. Rev. X, 3:021008, May 2013.
1703.05885.extracted_bib
{Rist12 D.~Rist\`e, C.~C. Bultink, K.~W. Lehnert, and L.~DiCarlo. \newblock Feedback Control of a Solid-State Qubit Using High-Fidelity Projective Measurement. \newblock {\em Phys. Rev. Lett., 109:240502, Dec 2012.