# N-States Continuous Maxwell Demon

Paul Raux  Université Paris-Saclay, CNRS/IN2P3, IJCLab, 91405 Orsay, France
Felix Ritort  Small Biosystems Lab, Condensed Matter Physics Department,
University of Barcelona, Barcelona, Spain and 2 Institut de Nanociència i
Nanotecnologia (IN2UB), Universitat de Barcelona, Barcelona, Spain

###### Abstract

Maxwell’s demon is a famous thought experiment and a paradigm of the
thermodynamics of information. It is related to Szilard’s engine, a two-state
information-to-work conversion device in which the demon performs single
measurements and extracts work depending on the state measurement outcome. A
variant of these models, the continuous Maxwell demon (CMD), was recently
introduced by Ribezzi-Crivellari and Ritort where work was extracted after
multiple repeated measurements every time that $\tau$ is in a two-state
system. The CMD was able to extract unbounded amounts of work at the cost of
an unbounded amount of information storage. In this work, we built a
generalization of the CMD to the N-state case. We obtained generalized
analytical expressions for the average work extracted and the information
content. We show that the second law inequality for information-to-work
conversion is fulfilled. We illustrate the results for N-states with uniform
transition rates and for the $N=3$ case.

Keywords— Maxwell demon, Information-to-Work Conversion, Correlated
Measurements

##  1 Introduction

In 1867, James Clerk Maxwell proposed a thought experiment for the better
understanding of the scope and limitations of the second law [1]. Known as the
Maxwell demon paradox, it has spurred strong research activity for many years,
setting the basis for the thermodynamics of information and information-to-
work conversion [2, 3, 4, 5, 6, 7, 8, 9, 10]. In 1929, Leo Szilard introduced
a simple physical model [11] in which a particle was free to move in a box of
volume V with two compartments (denoted with 0 and 1) of volumes $V_{0}$ and
$V_{1}$ and $V=V_{0}+V_{1}$ (Figure 1A). In Szilard’s engine (SZ), the “demon”
was an entity able to monitor the particle’s position and store the observed
compartment in a single-bit variable $\sigma=0,1$. Information-to-work
conversion is as follows: once the particle’s compartment is known, a movable
wall is inserted between the two compartments, and an isothermal process is
implemented to extract work. A work-extracting cycle concludes when the
movable wall reaches its far end, and the measurement-work extraction process
restarts. The average work extracted per cycle equals the equivalent heat
transferred from the isothermal reservoir to the system:
$W^{Sz}_{2}=-k_{B}T(P_{0}\log(P_{0})+P_{1}\log(P_{1}))$, with
$P_{0,1}=V_{0,1}/V$ the occupancy probabilities of each compartment. For equal
compartments $P_{0}=P_{1}=1/2$, Szilard’s engine can extract maximal work
determined by the Landauer bound, $W^{SZ}\leq k_{B}T\log(2)$ from the
reservoir without energy consumption, meaning that heat was fully converted
into work, apparently violating Kelvin’s postulate. In the 1960s and 1970s,
work by Landauer [12] and Bennett [13] found a solution to the paradox. The
solution to this paradox considers the information content of the measurement,
the work extraction, and the resetting processes of the demon [14, 15]. Most
importantly, to recover the initial state at the end of the thermodynamic
cycle, the demon must erase the information acquired on the system [2]. The
minimal erasure cost per bit of information equals $k_{B}T\log(2)$ for equally
probable outcomes. In the end, the information content stored in the demon is
always larger than or equal to the extracted work, in agreement with the
second law.

In a recent paper, a new variant of the Maxwell demon, the continuous Maxwell
demon (CMD), was introduced [16] (see also [17] for additional results),
analytically solved, and experimentally tested. In the CMD, the demon performs
repeated measurements of a particle’s location in a two-compartment box every
time $\tau$. The first time that the demon measures that the particle changed
compartments, a work extraction procedure is implemented. The main difference
with the SZ engine is that, in the CMD, a work extraction cycle contains
multiple measurements, whereas for the SZ, a single measurement is performed
at every work cycle. Compared to the SZ, the CMD can extract a more
significant amount of work $W$ because of the larger information content of
the multiple stored bits in a cycle. Interestingly, the average work per cycle
in the CMD satisfies $W^{CMD}\geq k_{B}T\log(2)$ being unbounded in the limits
$P_{0}\to 0$ ($P_{1}\to 1$) and $P_{0}\to 1$ ($P_{1}\to 0$). A model combining
the SZ and CMD work extraction protocols version showed the role of temporal
correlations in optimizing information-to-energy conversion [18]. In the CMD,
the time between measurements $\tau$ is arbitrary. In particular, it can be
made infinitesimal, $\tau\to 0$, leading to an infinite number of measurements
per cycle justifying the continuous adjective of the model.

Figure 1:  (A) The 2-CMD is represented as a two-compartment box in which a
work extraction protocol is implemented (see text). The cycle of measurement
is here $T_{0,1}^{3}=\underbrace{1,1,1}_{n=3},0$. The average work extracted
for this cycle is $-\log\frac{V_{1}}{V}$. (B) 4-CMD in circular geometry. Each
compartment had volume $V_{i}$. The cycle of measurement of the CMD reads:
$T_{0,2}^{4}=\underbrace{0,0,0,0}_{n=4},2$. The initial state $\sigma$ is $0$
and the final state $\sigma^{\prime}$ is $2$, the crossing of compartment $3$
remained unnoticed for measurements made at every time $\tau$. (C) In the work
extraction protocol, a pair of walls limiting the volume of the last
compartment, here $V_{2}$, are inserted. The wall between compartments $1$ and
$2$ is fixed, whereas the wall between compartments $2$ and $3$ was movable
and had no mass. To extract the work produced by the expansion of the particle
confined in $2$, the movable wall is connected to a pulley device. The average
work extracted for this cycle is $-k_{B}T\log\frac{V_{2}}{V}$.

Here, we generalize the CMD to the case of N-states ($N$-CMD). In a possible
realization of the $N$-CMD, a particle in a box of volume $V$ can occupy $N$
distinct compartments of volumes $V_{i}$ (Figure 1B). The demon measures in
which compartment the particle is at every time $\tau$ until a change in the
compartment is detected. Then, a work extraction process is implemented by
inserting one fixed wall at one side and one movable wall at the other side of
the compartment that can expand under the elastic collisions exerted by the
particle (Figure 1C). A pulley mechanism is attached to the movable wall to
extract an average work equal to $W=-k_{B}T\log P_{i}$ with $P_{i}=V_{i}/V$.
For _N_ = 2, we obtain the standard CMD (Figure 1A) (2-CMD), which corresponds
to transforming the Szilard box (Figure 1B) into a periodic torus (Figure 1C).

The outline of this work is as follows. In Section 2, we show how to
generalize the mathematical formalism of the 2-CMD to $N$ states ($N$-CMD). In
Section 3, we analyze the performance of the $N$-CMD by studying the
thermodynamic efficiency and power. In Section 4, we analyze several cases,
and in particular case $N=3$, to investigate the effect of topology on
information-to-work conversion (IWC). We end with some conclusions and future
directions.

##  2 General setting

Let $\sigma$ ($=1,\ldots,N$) denote the $N$ states of a system following
Markovian dynamics defined by transition rates that satisfy detailed balance,
ensuring that the system relaxes to an equilibrium state. Let $\tau$ be the
time between consecutive measurements. The conditional probability
$p_{\tau}(\sigma^{\prime}|\sigma)$ that the outcome of the measurement is
$\sigma^{\prime}$ after time $\tau$ conditioned that it starts in $\sigma$
satisfies the following master equation:

$\partial_{\tau}p_{\tau}(\sigma^{\prime}|\sigma)=\sum_{\sigma^{\prime\prime}=1}^{N}K_{\sigma^{\prime}\sigma^{\prime\prime}}p_{\tau}(\sigma^{\prime\prime}|\sigma)$
(1)

with initial condition $p_{\tau\rightarrow
0}(\sigma^{\prime}|\sigma)\rightarrow\delta_{\sigma^{{}^{\prime}},\sigma}$,
where $\delta$ is the Kronecker delta function. Markov matrix
$K_{\sigma^{\prime}\sigma^{\prime\prime}}$ satisfies
$\sum_{\sigma^{\prime}}K_{\sigma^{\prime}\sigma^{\prime\prime}}=0;\forall\sigma^{\prime\prime}$,
defining transitions rates from state $\sigma^{\prime\prime}$ to
$\sigma^{\prime}$:

$K_{\sigma^{\prime}\sigma^{\prime\prime}}=\left\\{\begin{array}[]{ll}-\left(\sum_{\sigma(\neq\sigma^{\prime\prime})}k_{\sigma\leftarrow\sigma^{\prime\prime}}\right)&\;\mathrm{if}\;\sigma^{\prime}=\sigma^{\prime\prime}\\\
k_{\sigma^{\prime}\leftarrow\sigma^{\prime\prime}}&\mathrm{otherwise}\end{array}\right.$
(2)

with $k_{\sigma^{\prime}\leftarrow\sigma^{\prime\prime}}$ the probability to
jump from state $\sigma^{\prime\prime}$ to $\sigma^{\prime}$ during time
$d\tau$. Let us denote by $P_{\sigma}$ the stationary solutions of Equation
(1). The detailed balance condition reads:

$\forall\sigma,\sigma^{\prime}\;;K_{\sigma\sigma^{\prime}}P_{\sigma^{\prime}}=K_{\sigma^{\prime}\sigma}P_{\sigma}$
(3)

The solution of Equation (1) can be written using the Perron–Frobenius theorem
(see [19]) as a spectral expansion in terms of the eigenvalues and
eigenvectors of $K$:

$p_{\tau}(\sigma^{\prime}|\sigma)=P_{\sigma}\sum_{\alpha}l_{\sigma^{\prime}}^{\alpha}l_{\sigma}^{\alpha}\exp(\lambda^{\alpha}\tau)$
(4)

where $l^{\alpha}$ is the left eigenvector of $K$ associated with the
eigenvalue $\lambda^{\alpha}$. The sum over the $\alpha$ term in Equation (4)
is symmetric in $\sigma\leftrightarrow\sigma^{\prime}$. Therefore, the
conditional probabilities also fulfil a detailed balance:

$\frac{p_{\tau}(\sigma|\sigma^{\prime})}{p_{\tau}(\sigma^{\prime}|\sigma)}=\frac{P_{\sigma}}{P_{\sigma^{\prime}}}$
(5)

Remark: Detailed balance ensures that there exists a unique stationary state
$P_{\sigma}$ associated with the eigenvalue $\lambda^{0}=0$ and that the other
eigenvalues are real and negative, $\lambda^{\alpha\neq 0}<0$. Equation (4)
can be rewritten as follows:

$p_{\tau}(\sigma^{\prime}|\sigma)=P_{\sigma^{\prime}}\left(1+\sum_{\alpha\neq
0}l_{\sigma^{\prime}}^{\alpha}l_{\sigma}^{\alpha}\exp(\lambda^{\alpha}\tau)\right)$
(6)

which gives $p_{\tau}(\sigma^{\prime}|\sigma)=P_{\sigma^{\prime}}$ for
$\tau\to\infty$ as expected.

In the CMD, a work-extraction cycle is defined by a sequence of $n+1$
measurement outcomes $\sigma_{i}$ ($1\leq i\leq n+1$) repeatedly taken every
time $\tau$. In a cycle the first $n$ outcomes are equal ($\sigma$) ending
with $\sigma^{\prime}$ ($\neq\sigma$). We define the trajectory for a cycle as
follows:

$T_{\sigma\sigma^{\prime}}^{n}=\underbrace{\sigma,\ldots,\sigma,}_{n}\;\sigma^{\prime}$
(7)

The probability of a given trajectory $T_{\sigma\sigma^{\prime}}^{n}$ reads:

$P\left(T_{\sigma\sigma^{\prime}}^{n}\right)=p_{\tau}(\sigma|\sigma)^{n-1}p_{\tau}(\sigma^{\prime}|\sigma)$
(8)

This is normalized as follows:

$\sum_{\sigma^{\prime}(\neq\sigma)}\sum_{n=1}^{\infty}P\left(T_{\sigma\sigma^{\prime}}^{n}\right)=1\;\;,\forall\sigma$
(9)

###  2.1 Thermodynamic Work and Information-Content

Like in the SZ, the work extracted by the CMD in a given cycle
$T_{\sigma\sigma^{\prime}}^{n}$ equals $-\log(P_{\sigma^{\prime}})$. Averaging
over all the possible measurement cycles, we obtain the average extracted
work:

$\begin{split}W_{N}(\tau)&=<-\log
P_{\sigma^{\prime}}>=-\sum_{\sigma}\sum_{\sigma^{\prime}(\neq\sigma)}\sum_{n=1}^{\infty}P_{\sigma}P\left(T_{\sigma\sigma^{\prime}}^{n}\right)\log
P_{\sigma^{\prime}}\\\
&=-\sum_{\sigma=1}^{N}\frac{P_{\sigma}}{1-p_{\tau}(\sigma|\sigma)}\sum_{\sigma^{\prime}\neq\sigma}p_{\tau}(\sigma^{\prime}|\sigma)\log
P_{\sigma^{\prime}}\end{split}$ (10)

which is positive by definition. In the limit $\tau\to\infty$ we obtain the
following expression,

$W_{N}^{\infty}=-\sum_{\sigma=1}^{N}\frac{P_{\sigma}}{1-P_{\sigma}}\sum_{\sigma^{\prime}\neq\sigma}P_{\sigma^{\prime}}\log
P_{\sigma^{\prime}},$ (11)

which can be written as follows:

$W_{N}^{\infty}=\Bigl{(}\sum_{\sigma=1}^{N}\frac{P_{\sigma}}{1-P_{\sigma}}\Bigr{)}W_{N}^{\rm
SZ}+\sum_{\sigma=1}^{N}\frac{P_{\sigma}^{2}\log P_{\sigma}}{1-P_{\sigma}}$
(12)

where $W^{SZ}_{N}$ is the classical statistical entropy of the system, which
can also be interpreted as the average work extraction of the $N$-states
Szilard engine, denoted as $N$-SZ:

$\begin{split}W^{SZ}_{N}=<-\log(P_{\sigma})>=-\sum_{\sigma}P_{\sigma}\log
P_{\sigma}\end{split}$ (13)

This expression can be readily minimized in the space of $P_{\sigma}$ giving
the uniform solution, $P_{\sigma}=1/N$ for which $W_{N}^{\infty}=\log N$. In
contrast, $W_{N}^{\infty}\to-\log(1-P_{\sigma})$ if $P_{\sigma}\to 1$ for a
given $\sigma$ (and $P_{\sigma^{\prime}}\to 0$
$\forall\sigma^{\prime}\neq\sigma$) diverging in that limit.

We define the average information content per cycle as the statistical entropy
of the measurement-cycle probabilities [20]:

$\begin{split}I_{N}(\tau)&=<-\log\left(P_{\sigma}P\left(T_{\sigma\sigma^{\prime}}^{n}\right)\right)>\\\
&=-\sum_{\sigma}\sum_{\sigma^{\prime}(\neq\sigma)}\sum_{n=1}^{\infty}P_{\sigma}P\left(T_{\sigma\sigma^{\prime}}^{n}\right)\log\left(P_{\sigma}P\left(T_{\sigma\sigma^{\prime}}^{n}\right)\right)\\\
&=-\sum_{\sigma=1}^{N}\sum_{\sigma^{\prime}\neq\sigma}^{N}P_{\sigma}\left(p_{\tau}(\sigma^{\prime}|\sigma)\log(P_{\sigma})+p_{\tau}(\sigma^{\prime}|\sigma)\log(p_{\tau}(\sigma^{\prime}|\sigma))\right)\underbrace{\sum_{n=1}^{\infty}p_{\tau}(\sigma|\sigma)^{n-1}}_{\frac{1}{1-p_{\tau}(\sigma|\sigma)}}\\\
&-\sum_{\sigma=1}^{N}\sum_{\sigma^{\prime}\neq\sigma}^{N}P_{\sigma}p_{\tau}(\sigma^{\prime}|\sigma)\log(p_{\tau}(\sigma|\sigma))\underbrace{\sum_{n=1}^{\infty}(n-1)p_{\tau}(\sigma|\sigma)^{n-1}}_{\frac{p_{\tau}(\sigma|\sigma)}{(1-p_{\tau}(\sigma|\sigma))^{2}}}\\\
&=W_{N}^{SZ}-\sum_{\sigma}^{N}\frac{P_{\sigma}}{1-p_{\tau}(\sigma|\sigma)}\sum_{\sigma^{\prime}}p_{\tau}(\sigma^{\prime}|\sigma)\log
p_{\tau}(\sigma^{\prime}|\sigma)\end{split}$ (14)

The positivity of $I_{N}(\tau)$ follows from the fact that
$p_{\tau}(\sigma^{\prime}|\sigma),P_{\sigma}\leq 1$. The second term in
Equation (14) depends on $\tau$ and can be understood as the contribution of
correlations between measurements to $I_{N}(\tau)$.
Lastly, using Equation (5), we can rearrange Equation (14) as follows:

$I_{N}(\tau)=W_{N}(\tau)\underbrace{-\sum_{\sigma}^{N}\frac{P_{\sigma}}{1-p_{\tau}(\sigma|\sigma)}\sum_{\sigma^{\prime}}p_{\tau}(\sigma^{\prime}|\sigma)\log
p_{\tau}(\sigma|\sigma^{\prime})}_{=\Delta_{N}>0}$ (15)

where the second term $\Delta_{N}$ is positive since
$p_{\tau}(\sigma|\sigma^{\prime})\leq 1$. Equation (15) implies the second law
inequality:

$I_{N}(\tau)-W_{N}(\tau)>0\;\forall\tau$ (16)

meaning that the cost to erase the stored sequences information content is
always larger than the work extracted by the demon.

###  2.2 Comparison with the Szilard Engine

Equating Expressions (14) and (15) for $I_{N}(\tau)$, we obtain a relation
between $W_{N}(\tau)$ and $W^{SZ}$ that compares the average work extracted in
the $N$-CMD to the $N$-SZ engine as follows:

$\begin{split}W_{N}(\tau)-W_{N}^{SZ}&=<-\log\frac{P_{\sigma^{\prime}}}{P_{\sigma}}>\\\
&=-\sum_{\sigma}\frac{p_{\sigma}}{1-p_{\tau}(\sigma|\sigma)}\sum_{\sigma^{\prime}}p_{\tau}(\sigma^{\prime}|\sigma)\log\frac{p_{\tau}(\sigma^{\prime}|\sigma)}{p_{\tau}(\sigma|\sigma^{\prime})}\geq
0\end{split}$ (17)

where the first equality follows from the difference between the first right-
hand side of Equations (10) and (13). This shows that the CMD’s average work
per cycle is always larger or equal to SZ. The equality holds for the uniform
case $P_{\sigma}=1/N$ where $W_{N}(\tau)=W_{N}^{SZ}=\log N$.

##  3 Thermodynamic power and efficiency

###  3.1 Average Cycle Length

As a preliminary, we first compute the average time of a cycle of measurement.
This is similar to the mean first residence time of the system, except for the
fact that (unobserved) hopping events are permitted. We define it as follows:

$t_{N}^{c}\equiv\tau<n>$ (18)

and obtain the following expression:

$t_{N}^{c}=\tau\left(1+\sum_{\sigma}\frac{P_{\sigma}}{1-p_{\tau}(\sigma|\sigma)}\right)$
(19)

The following equalities are shown:

$\lim_{\tau\to 0^{+}}t_{N}^{c}=-\sum_{i}\frac{1}{\sum_{\alpha\neq
0}(l_{i}^{\alpha})^{2}\lambda^{\alpha}}>0$ (20)
$\lim_{\tau\to\infty}t_{N}^{c}=+\infty$ (21)

The average cycle time is the mean first passage time [21] of the discrete
time random walk defined by a cycle of measurements.

###  3.2 Thermodynamic Power

We define the thermodynamic power as the average work $W_{N}$ extracted per
cycle time $t_{N}^{c}$:

$\Phi_{N}(\tau)=\frac{W_{N}}{t_{N}^{c}}$ (22)

In the limit of uncorrelated measurements $\tau\rightarrow\infty$, we obtain
from Equations (11) and (19):

$\Phi_{N}^{\infty}=-\frac{1}{\tau}\frac{\sum_{\sigma=1}^{N}\frac{P_{\sigma}}{1-P_{\sigma}}\sum_{\sigma^{\prime}\neq\sigma}P_{\sigma^{\prime}}\log
P_{\sigma^{\prime}}}{1+\sum_{\sigma}\frac{P_{\sigma}}{1-P_{\sigma}}}$ (23)

For $N=2$, we recover the results in [16, 17].

###  3.3 Information-to-Work Efficiency

In the spirit of the efficiencies defined for thermal machines, we define the
information-to-work conversion (IWC) efficiency of the CMD as the ratio
between $W_{N}$, taken to be the objective function, and $I_{N}$, taken to be
the cost function, for the optimization of the CMD:

$\eta_{N}=\frac{W_{N}}{I_{N}}$ (24)

Using Equation (15), we can rewrite $\eta_{N}$ as follows:

$\eta_{N}=\frac{1}{1+\frac{\Delta_{N}}{W_{N}}}$ (25)

From Equation (16), $\eta_{N}<1$. In the limit $\tau\rightarrow\infty$, we
obtain:

$\lim_{\tau\to\infty}\eta_{N}=\frac{1}{1+\frac{\sum_{i}\frac{P_{i}}{1-P_{i}}\log
P_{i}}{\sum_{i}\frac{P_{i}}{1-P_{i}}\sum_{j\neq i}P_{j}\log P_{j}}}$ (26)

In limit $P_{\sigma}\rightarrow 1$ for a given state $\sigma$, one can check
that the $N$-CMD reaches maximal efficiency 1.

##  4 Particular cases

##  5 Particular Cases

Here, we analyze some specific examples.

###  5.1 Case N=2

We now turn to the $N=2$ case considered in [16] as an example of our
formulae. The kinetic rate matrix in this case reads:

$K=\begin{pmatrix}-k_{1\leftarrow 0}&k_{0\leftarrow 1}\\\ k_{1\leftarrow
0}&-k_{0\leftarrow 1}\end{pmatrix}$ (27)

Here, we do not need to make any particular choice of rates
$k_{\sigma^{{}^{\prime}}\sigma}$ to ensure detailed balance since, for two
states, a detailed balance unconditionally holds. Applying the procedure
sketched in Section 2, we solve the master equation:

$p_{\tau}=(p_{\tau}(\sigma|\sigma^{{}^{\prime}}))_{\sigma,\sigma^{{}^{\prime}}=0,1}\begin{pmatrix}P_{0}+P_{1}\exp(-R\tau)&P_{0}(1-\exp(-R\tau))\\\
P_{1}(1-\exp(-R\tau))&P_{1}+P_{0}\exp(-R\tau)\end{pmatrix}$ (28)

where $R=k_{1\leftarrow 0}+k_{0\leftarrow 1}$, $P_{0}=\frac{k_{0\leftarrow
1}}{R}$ and $P_{1}=\frac{k_{1\leftarrow 0}}{R}$ such that $P_{0}+P_{1}=1$.
$p_{\tau}$ is normalized per column:

$p_{\tau}(\sigma^{{}^{\prime}}|\sigma)+p_{\tau}(1-\sigma^{{}^{\prime}}|\sigma)=1\;,\;\;\forall\sigma=0,1$
(29)

First, let us consider $W_{2}$. Since $N=2$ and by normalization, there is
only one term in the sum $\sum_{\sigma^{{}^{\prime}}\neq\sigma}$ of Equation
(10). Thus, $W_{2}$ simplifies to:

$W_{2}=-P_{0}\log(1-P_{0})-(1-P_{0})\log(P_{0})$ (30)

We recover the result obtained in [16] and coincidently show that the $\tau$
independence of this result is a particular feature of the $N=2$ case.
Moreover, since $W_{2}$ had a simple expression, we obtained a tractable
expression for the comparison with the SZ average work extracted, c.f.
Equation (17):

$W_{2}-W_{2}^{SZ}=(1-2P_{0})\log\bigl{(}\frac{1-P_{0}}{P_{0}}\bigr{)}$ (31)

This quantity is positive and vanishes only for uniform probability,
$P_{\sigma}=\frac{1}{2}$, as shown in Section 3.1. Using normalization
Equation (29) again in the definition of $I_{N}$ Equation (14), we obtain
$I_{2}$ as follows:

$\begin{split}I_{2}&=-P_{0}\log P_{0}-(1-P_{0})\log(1-P_{0})\\\
&-P_{0}\left(\frac{p_{\tau}(0|0)}{p_{\tau}(1|0)}\log p_{\tau}(0|0)+\log
p_{\tau}(1|0)\right)\\\
&-(1-P_{0})\left(\frac{p_{\tau}(1|1)}{p_{\tau}(0|1)}\log p_{\tau}(1|1)+\log
p_{\tau}(0|1)\right)\end{split}$ (32)

which is the result obtained in [16]. The remaining results of [16] are
obtained by combining Equations (28), (30), and (32).

###  5.2 Uniform Transition Rates

In this subsection, we take the following particular case for the Markov
matrix $K$:

$K_{\sigma^{\prime}\sigma}=R\times\left\\{\begin{array}[]{ll}-(N-1)&\;\mathrm{if}\;\sigma^{\prime}=\sigma\\\
1&\mathrm{otherwise}\end{array}\right.$ (33)

In this case, there are only two independent conditional probabilities; we can
thus rewrite the master equation as follows:

$\partial_{\tau}p_{\tau}(\sigma|\sigma)=R(1-Np_{\tau}(\sigma|\sigma))$ (34)

Via normalization, we obtain $p_{\tau}(\sigma^{\prime}|\sigma)$ as follows:

$p_{\tau}(\sigma^{\prime}|\sigma)=\frac{1}{N-1}(1-p_{\tau}(\sigma|\sigma))\,\,\,;\,\,\,\sigma^{\prime}\neq\sigma$
(35)

In the remainder of this subsection, we define the dimensionless rescaled time
between two measurements as $\tilde{\tau}=R\tau$. The solution of Equation
(34) reads:

$p_{\tau}(\sigma|\sigma)=\frac{1}{N}\left(1+(N-1)\exp(-N\tilde{\tau})\right)$
(36)

This particular case allows for us to obtain a glimpse of the dependence of
the quantities introduced in Section 2 with N. The average work extracted is
as follows:

$W_{N}=\log N\,\,\,\,.$ (37)

We see that the work extracted does not depend on $\tau$. $I_{N}$ reads:

$I_{N}=\log
N-\frac{N}{N-1}\log\bigl{(}\frac{1}{N}(1-\exp(-N\tilde{\tau}))\bigr{)}$ (38)

The first remark is that in the limit $\tilde{\tau}\rightarrow\infty$,
$I_{N}^{\infty}=\frac{2N-1}{N-1}\underbrace{\log N}_{W_{N}}$.
One way to optimize the CMD is to maximize IWC efficiency, defined as follows:

$\eta_{N}\equiv\frac{W_{N}}{I_{N}}=\frac{\log N}{\log
N-\frac{N\log\left(\frac{1-e^{-N\tilde{\tau}}}{N}\right)}{N-1}}$ (39)

We find the asymptotic efficiency $\eta_{N}^{\infty}=\frac{N-1}{2N-1}$ for
$\tilde{\tau}\rightarrow\infty$ and $\eta_{N}=\frac{1}{2}$ for
$N\rightarrow\infty$. For the thermodynamic power, we obtain:

$\Phi_{N}\equiv\frac{W_{N}}{t_{N}^{c}}=\frac{\log
N}{\frac{N\tilde{\tau}e^{N\tilde{\tau}}}{(N-1)\left(e^{N\tilde{\tau}}-1\right)}+\tilde{\tau}}$
(40)

where $t_{N}^{c}$ is the average cycle time that we analyzed in Section 3.1.
One can show that the maximum thermodynamic power $\Phi_{N}=(N-1)\log(N)$ is
obtained in the limit $\tilde{\tau}\rightarrow 0$. This shows that the maximum
IWC efficiency Equation (39) and the efficiency at maximum power Equation (40)
are obtained in two different limits, a general result expected for
thermodynamic machines [22].

###  5.3 Case N = 3

The 3-CMD is the simplest case in which two different topologies of the state
space are available. They are defined in Figure 2 and are denoted as
triangular (Panel A) and linear (Panel B), respectively. We denote the energy
of state $\sigma(\sigma=0,1,2)$ by $\epsilon_{\sigma}$. Taking $\beta=1$, the
detailed balance assumption Equation (3) then reads:

$\frac{K_{\sigma\sigma^{\prime}}}{K_{\sigma^{\prime}\sigma}}=\exp(-(\epsilon_{\sigma}-\epsilon_{\sigma^{\prime}}))\;\;\;,\;\;\forall\sigma\neq\sigma^{\prime}$
(41)

Here we take $\epsilon_{0}=0$. This implies that the energies of states $1,2$
read:

$\epsilon_{1}=\log(\frac{P_{0}}{P_{1}})$ (42)
$\epsilon_{2}=\log(\frac{P_{0}}{P_{2}})$ (43)

In the linear case, taking as a particular case $k_{01}=1$ and $k_{21}=1$, we
obtain the following Markov matrix:

$K_{3}^{lin}=\begin{pmatrix}-1&\exp(\epsilon_{1})&0\\\
1&-(\exp(\epsilon_{1})+\exp(\epsilon_{1}-\epsilon_{2}))&1\\\
0&\exp(\epsilon_{1}-\epsilon_{2})&-1\end{pmatrix}=\begin{pmatrix}-1&\frac{P_{0}}{P_{1}}&0\\\
1&-\frac{P_{0}}{P_{1}}(1+\frac{P_{2}}{P_{0}})&1\\\
0&\frac{P_{2}}{P_{1}}&-1\end{pmatrix}$ (44)

where we used Equations (42) and (43) to give an expression of $K_{3}^{lin}$
depending only on $P_{0},P_{1},P_{2}$. In the triangular case, taking
$k_{01}=1$ and $k_{21}=1$ and $k_{02}=1$ as a particular case, we obtain
similarly the following Markov matrix:

$K_{3}^{tri}=\begin{pmatrix}-2&\exp(\epsilon_{1})&\exp(\epsilon_{2})\\\
1&-(\exp(\epsilon_{1})+\exp(\epsilon_{1}-\epsilon_{2}))&1\\\
1&\exp(\epsilon_{1}-\epsilon_{2})&-(1+\exp(\epsilon_{2}))\end{pmatrix}=\begin{pmatrix}-2&\frac{P_{0}}{P_{1}}&\frac{P_{0}}{P_{2}}\\\
1&-\frac{P_{0}}{P_{1}}(1+\frac{P_{2}}{P_{0}})&1\\\
1&\frac{P_{2}}{P_{1}}&-(1+\frac{P_{0}}{P_{2}})\end{pmatrix}$ (45)

The solution of Equation (1) with Markov matrix (44) in the linear case and
(45) in the triangular case, can be written using the Perron-Frobenius theorem
[19] as the following spectral expansion:

$P_{\sigma}(\tau)=\Psi_{0}+c_{1}^{\sigma}\Psi_{1}\exp(\lambda_{1}\tau)+c_{2}^{\sigma}\Psi_{2}\exp(\lambda_{2}\tau)$
(46)

where $\lambda_{1},\lambda_{2}<0$ and $c_{1}^{\sigma},c_{2}^{\sigma}$ are the
coefficients determined in the limit $\tau\rightarrow 0$, which depend on the
conditional state $\sigma$. These coefficients are gathered in table 5.3 for
both models.

Figure 2: Definition of the state spaces for the 2 topologies available for
the 3-CMD: (A) Triangular 3-CMD, (B) Linear 3-CMD.

| $c_{1}^{\sigma}$ | $c_{2}^{\sigma}$
---|---|---
$\sigma=0$ | $-(P_{2}+\frac{P_{2}^{2}+P_{2}(P_{0}+P_{1})}{P_{0}+P_{2}})$ | $\frac{P_{1}P_{2}}{P_{0}+P_{2}}$
$\sigma=1$ | 0 | $\frac{P_{2}(P_{1}-1)}{P_{0}+P_{2}}$
$\sigma=2$ | $\frac{P_{0}}{P_{0}+P_{2}}$ | $\frac{P_{1}P_{2}}{P_{0}+P_{2}}$

$\Psi_{0},\Psi_{1},\Psi_{2}$ are the eigenvectors of both
$K_{3}^{lin},K_{3}^{tri}$:

  * •

$\Psi_{0}$ is the eigenvector associated to the eigenvalue $0$ and it
corresponds to the stationary probability. Since the detailed balance
condition Equation (3) holds, the stationary probability is the Boltzmann
distribution. Thus,

$\Psi_{0}=\begin{pmatrix}P_{0}\\\ P_{1}\\\
P_{2}\end{pmatrix}=\frac{1}{Z}\begin{pmatrix}1\\\ \exp(-\epsilon_{1})\\\
\exp(-\epsilon_{2})\end{pmatrix}$ (47)

where $Z=1+\exp(-\epsilon_{1})+\exp(-\epsilon_{2})$

  * •

$\Psi_{1}$ is the eigenvector associated to the second eigenvalue, which reads
$\lambda_{1}^{lin}=-1$ in the linear case, and
$\lambda_{1}^{tri}=-(1+\frac{1-P_{1}}{P_{2}})$ in the triangular case.
$\Psi_{1}$ reads:

$\Psi_{1}=\begin{pmatrix}-1\\\ 0\\\ 1\end{pmatrix}$ (48)

  * •

$\Psi_{2}$ is the eigenvector associated in both models to the eigenvalue
$\lambda_{2}=-\frac{1}{P_{1}}$. It reads:

$\Psi_{2}=\begin{pmatrix}\frac{P_{0}}{P_{2}}\\\ -\frac{1-P_{1}}{P_{2}}\\\
1\end{pmatrix}$ (49)

####  5.3.1 Uncorrelated Measurements on the 3-CMD

We now turn to the limit $\tau\rightarrow\infty$. In this limit of
uncorrelated measurements, the time between consecutive measurements $\tau$ is
larger than the relaxation time of the system, the inverse of the lowest
eigenvalue, $\sim-1/\lambda_{1}$. In this limit, $P_{\sigma}(\tau)$ reduces to
Boltzmann distribution Equation (47) and
$p_{\tau}(\sigma^{\prime}|\sigma)=P_{\sigma^{\prime}}$. Therefore, the two
models (linear and triangular) are indistinguishable. Results for work and
information are shown in Figure 3.

Figure 3: $W_{2},I_{2},W_{3},I_{3}$ as a function of $P_{2}$ for $P_{1}$ fixed
in each panel. Large work extraction is obtained in the limit of rare events
$P_{1}\rightarrow 0$ and $P_{2}\rightarrow 0,1$.

First, it is clear that the second law Inequality (16) was satisfied. In the
limit $P_{1}\rightarrow 0$, we recovered the 2-CMD. Our generalized
expressions for work and information content reproduced well the trend
observed in Figure 1c of [16]. In the limit of rare events, where
$P_{1}\rightarrow 0$ and $P_{2}\rightarrow 0,1$, we recovered the infinite
average work extraction described for the 2-CMD. Large work extraction was
only obtained in the 2-CMD limit.

Efficiency $\eta_{3}$ is shown in Figure 4. For $P_{1}\to 0$ and $P_{2}\to 0$
or $P_{2}\to 1$, we recovered the limit of rare events and maximal efficiency
$\eta_{3}\to 1$. In the 3-CMD, we have $\eta_{3}\in\left[2/5,1\right]$.

Figure 4: $W_{2},I_{2},W_{3},I_{3}$ as a function of $P_{2}$ for $P_{1}$ fixed
in each panel.

###  5.4 Correlated Measurements in the 3-CMD

Correlated measurements are those where $\tau$ is lower than or comparable to
the equilibrium relaxation time. Equation (46) shows that the dynamics of the
linear and triangular topologies for the 3-CMD are very similar. Indeed, in
the limit of uncorrelated measurements, the two dynamics reduce to the same
Boltzmann distribution. They also collapse in the limit $P_{1}\rightarrow 1$
(with $P_{0},P_{2}\to 0$), indeed in this case
$\lambda_{1}^{lin}=\lambda_{1}^{tri}$. In between, the topology of the network
is relevant. For correlated measurements, we obtained the results shown in
Figure 5.

First, the average cycle time (upper-left panel in Figure 5) in the linear
case was generally larger than that in the triangular case. The direct
consequence, since the average work extraction was comparable in both cases,
was that the thermodynamic power (upper-right panel in Figure 5) extracted by
the linear 3-CMD was lower than the thermodynamic power extracted by the
triangular 3-CMD. Moreover, the thermodynamic power decreased logarithmically
to 0 when $\tau$ increases. Thus, 3-CMD had optimal power production in limit
$\tau\rightarrow 0$, i.e., in the limit of continuous measurements. The
efficiency of the 3-CMD as a function of $\tau$ is plotted in the lower-left
panel of Figure 5. The linear 3-CMD was generally less efficient than the
triangular 3-CMD. The reason for this is in the lower-right panel of Figure 5,
where $W_{3}$ and $I_{3}$ are plotted against $\tau$ for both models. For a
comparable work extraction, the linear 3-CMD needs to store more information.
Again, in the limit of uncorrelated measurements, the two models converge to
the same result.

Figure 5: The 3-CMD for correlated measurements for $P_{1}=P_{2}=0.001$.
(upper left) Average cycle length $t^{c}_{3}/\tau$ in both models, Equation
(19); (upper right) thermodynamic power; (lower left) efficiency; (lower
right) average information content and work extraction in $k_{B}T$ units
(orange and red lines collapse on top of each other).

##  6 Concluding Remarks

In this work, we generalized the 2-CMD of [16, 17] to N-states. We obtained
generalized expressions of the average extracted work, the average information
content stored in the demon’s memory, and of thermodynamical quantities such
as the thermodynamic power and the information-to-work efficiency of the
$N$-CMD. We proved that the second law inequality holds for the $N$-CMD, thus
giving bounds on the efficiency of the engine. Comparing the $N$-CMD to the
$N$-SZ engine, we also showed that the $N$-CMD could extract more work on
average than the $N$-SZ engine. The most efficient setting of the $N$-CMD was
in the limit of rare events already described in [16]. In the $N$-CMD case,
this limit was obtained by first taking the 2-CMD limit. Thus, no
configuration is more efficient in the $N$-CMD than the 2-CMD limit.

In future work on the $N$-CMD, it would be interesting to implement a graph
theoretic procedure to obtain, for instance, a more precise explanation of the
difference between the linear and triangular cases (connected graph versus
fully connected graph). It would also be interesting to determine the
distributions of the quantities computed here [23] and thus optimize the
fluctuations of the $N$-CMD.

##### Author contributions:

F. R. conceived the work, and P. R. did the calculations.

##### Acknowledgements:

FR is supported by the Spanish Research Council Grant PID2019-111148GB-100 and
the Icrea Academia Prize 2018.

## References

  * [1] JM Jauch and JG Baron.  Entropy, information and szilard’s paradox.  Maxwell’s Demon: Entropy, information, computing, pages 160–172, 1990.
  * [2] Martin B Plenio and Vincenzo Vitelli.  The physics of forgetting: Landauer’s erasure principle and information theory.  Contemporary Physics, 42(1):25–60, 2001.
  * [3] Felix Ritort.  The noisy and marvelous molecular world of biology.  Inventions, 4(2):24, 2019.
  * [4] Andrew Rex.  Maxwell’s demon—a historical review.  Entropy, 19(6):240, 2017.
  * [5] Sergio Ciliberto.  Experiments in stochastic thermodynamics: Short history and perspectives.  Physical Review X, 7(2):021051, 2017.
  * [6] AC Barato and U Seifert.  Unifying three perspectives on information processing in stochastic thermodynamics.  Physical review letters, 112(9):090601, 2014.
  * [7] Andre C Barato and Udo Seifert.  Stochastic thermodynamics with information reservoirs.  Physical Review E, 90(4):042150, 2014.
  * [8] Antoine Bérut, Artyom Petrosyan, and Sergio Ciliberto.  Detailed jarzynski equality applied to a logically irreversible procedure.  Europhysics Letters, 103(6):60002, 2013.
  * [9] Antoine Berut, Artyom Petrosyan, and Sergio Ciliberto.  Information and thermodynamics: experimental verification of landauer’s erasure principle.  Journal of Statistical Mechanics: Theory and Experiment, 2015(6):P06015, 2015.
  * [10] Eric Lutz and Sergio Ciliberto.  From maxwells demon to landauers eraser.  Phys. Today, 68(9):30, 2015.
  * [11] Leo Szilard.  Über die entropieverminderung in einem thermodynamischen system bei eingriffen intelligenter wesen.  Zeitschrift für Physik, 53(11-12):840–856, 1929.
  * [12] Rolf Landauer.  Irreversibility and heat generation in the computing process.  IBM journal of research and development, 5(3):183–191, 1961.
  * [13] Charles H Bennett.  The thermodynamics of computation—a review.  International Journal of Theoretical Physics, 21:905–940, 1982\.
  * [14] Takahiro Sagawa and Masahito Ueda.  Information thermodynamics: Maxwell’s demon in nonequilibrium dynamics.  Nonequilibrium statistical physics of small systems: fluctuation relations and beyond, pages 181–211, 2013.
  * [15] Juan MR Parrondo, Jordan M Horowitz, and Takahiro Sagawa.  Thermodynamics of information.  Nature physics, 11(2):131–139, 2015.
  * [16] Marco Ribezzi-Crivellari and Felix Ritort.  Large work extraction and the landauer limit in a continuous maxwell demon.  Nature Physics, 15(7):660–664, 2019.
  * [17] Marco Ribezzi-Crivellari and Felix Ritort.  Work extraction, information-content and the landauer bound in the continuous maxwell demon.  Journal of Statistical Mechanics: Theory and Experiment, 2019(8):084013, 2019.
  * [18] Juan P Garrahan and Felix Ritort.  Generalized continuous maxwell demons.  arXiv preprint arXiv:2104.12472, 2021.
  * [19] Nicolaas Godfried Van Kampen.  Stochastic processes in physics and chemistry, volume 1.  Elsevier, 1992.
  * [20] Thomas M. Cover and Joy A. Thomas.  Elements of Information Theory (Wiley Series in Telecommunications and Signal Processing).  Wiley-Interscience, USA, 2006.
  * [21] Olivier Benichou, Thomas Guérin, and Raphaël Voituriez.  Mean first-passage times in confined media: from markovian to non-markovian processes.  Journal of Physics A: Mathematical and Theoretical, 48(16):163001, 2015.
  * [22] Christophe Goupil and Eric Herbert.  Adapted or adaptable: How to manage entropy production?  Entropy, 22(1):29, 2019.
  * [23] Christian Van den Broeck and Massimiliano Esposito.  Ensemble and trajectory thermodynamics: A brief introduction.  Physica A: Statistical Mechanics and its Applications, 418:6–16, 2015.