\chapterimage{head2.png} % Chapter heading image
\chapter{Langevin Dynamics}
\section{Basic Equations of Physical Space}
\begin{center}
        \includegraphics[scale=0.8]{ch1/protein_length_scale.pdf}
\end{center}
\begin{definition}[Langevin Equation in Physical Space]
\begin{align*}
        d \bar{x} &= \frac{\bar{D}}{k_B T} \bar{F}(\bar{x}) d\bar{t} + \sqrt{2\bar{D}}d{W}_{\bar{t}}
\end{align*}
The Wiener process
\begin{align*}
        \langle d{W}_{\bar{t}} \rangle  &=0 \\
        \langle d{W}_{\bar{t}} d{W}_{\bar{t'}}\rangle &=\delta (\bar{t}-\bar{t'}) d\bar{t}.
\end{align*}
\end{definition}

\begin{definition}[MD units]
\begin{center}
\begin{tabular}{lccc}
\toprule
Variable & Symbol & This work &  SI units \\
\midrule
Length                &  $\bar{x}$ &  1 Å               &   $1\times 10^{-10}$ m       \\
Force                 &  $\bar{F}$ &  1 kcal/(mol Å)    &   $6.95 \times 10^{-1}$ N    \\
Energy                &  $\bar{V}$ &  1 kcal/mol        &   4186 J/mol                 \\
Temperature           &  $T$       &  1 K               &   1 K                        \\
Thermal Energy        &  $k_B T$   &  0.593 kcal/mol (T=298K)  &   2482 J/mol          \\
Time                  &  $\bar{t}$ &  1 ps              &   $1\times 10^{-12}$ s       \\
Mass                  &  $\bar{m}$ &  1 Da              &   $1.661 \times 10^{-27}$ kg \\
Diffusion coefficient &  $\bar{D}$ &  1 $\text{\AA}^2/{\rm ps}$ &  $1\times 10^{-8}$ $\text{m}^2$/s \\
\bottomrule
\end{tabular}
\end{center}
\end{definition}

\begin{definition}[Water Diffusion coefficient and Stokes-Einstein relation]
\begin{align*}
        \bar{D} = \frac{k_B T}{6 \pi \eta a}
\end{align*}
The energy term in numerator, (T=298K)
\begin{align*}
        k_B T = 4.11 \times 10^{-21} ~\mathrm{J} = 4.11 \times 10^{-21}~\mathrm{\frac{kg \cdot m^2 }{s^2}}
\end{align*}
Viscosity $\eta$: solvent is Water
\begin{align*}
        \eta = 9 \times 10^{-4}~\mathrm{Pa \cdot s} = 9 \times 10^{-4} ~\mathrm{\frac{kg}{m \cdot s}}
\end{align*}
The radius of Brownian particle: $a$
\begin{align*}
        a = 1 \text{\AA}
\end{align*}
Therefore, the diffusion coefficient
\begin{align*}
        \bar{D} = \frac{4.11 \times 10^{-21}}{6 \pi \times 9 \times 10^{-4} \times 1 \times 10^{-10} }~\mathrm{\frac{m^2}{s}} = 2.423 \times 10^{-9} ~\mathrm{\frac{m^2}{s}} = 0.243 ~\mathrm{\frac{\text{\AA}^2}{\rm ps}}
\end{align*}
\end{definition}

\begin{definition}[Diffusion coefficient and the radius of Brownian partical]
\begin{align*}
        \bar{D} = \frac{\rm{constant}}{a}
\end{align*}
so
\begin{align*}
        \frac{\bar{D}}{\bar{D'}} &= \frac{a'}{a} \\
        \frac{0.243}{\bar{D'}} &= \frac{a'}{1}
\end{align*}
Therefore, given a diffusion coefficient $\bar{D'}$
\begin{align*}
        a' = \frac{0.243}{\bar{D'}}~~~\text{\AA}
\end{align*}
\end{definition}

\begin{definition}[Time scale]
\begin{align*}
        d\bar{t}=2~\text{fs} = 2 \times 10^{-3} ps
\end{align*}
$d\bar{t}$ is the integration time step in Langevin dynamics. And the total simulation time is $\bar{T}$, and the saving interval $\Delta \bar{t}$. Therefore, the number of data points $n$
\begin{align*}
        n = \frac{\bar{T}}{\Delta \bar{t}}
\end{align*}
For example, $\bar{T}=10$ ns and $\Delta \bar{t}=1$ ps
\begin{align*}
        n = \frac{\bar{T}}{\Delta \bar{t}} = \frac{10000~\text{ps}}{1~\text{ps}} = 10000
\end{align*}
Next, we can approximate the characteristic time $\tau$ for diffusion in water solvent for a given distance $\bar{r}$
\begin{align*}
        \tau = \frac{\bar{r}^2}{\bar{D}}
\end{align*}
Let $\bar{r}=100~\text{\AA}$
\begin{align*}
        \tau = \frac{\bar{r}^2}{\bar{D}} = \frac{10000}{0.243} = 41152~\text{ps} \approx 41~\text{ns}
\end{align*}
For $\bar{D}=3.052~\text{\AA}^2\text{ps}^{-1}$
\begin{align*}
        \tau = \frac{\bar{r}^2}{\bar{D}} = \frac{10000}{3.052} = 3276~\text{ps} \approx 3.3~\text{ns}
\end{align*}
\end{definition}

\section{Basic Equations of Reduced Units Space}
\begin{definition}[Langevin Equation in Reduced Units Space]
\begin{align*}
    dx_t=D F(x_t)dt  + \sqrt{2D}d{W}_t.
\end{align*}
The Wiener process $d{W}_t$
\begin{align*}
        \langle d{W}_t\rangle &= 0 \\
        \langle d{W}_t \cdot d{W}_{t'} \rangle &= \delta(t-t')dt
\end{align*}
\label{langevin}
\end{definition}

\begin{definition}[Reduced units]
\begin{center}
\begin{tabular}{lccc}
\toprule
Variable & Symbol & This work & Transformation \\
\midrule
Length                &  $x$       &     $L$              &   $x=f(\bar{x})$             \\
Energy                &  $V$       &     unitless         &   $V(x)=\bar{V}(f^{-1}(x))/(k_B T)$                 \\
Force                 &  $F$       &     $L^{-1}$        &    \\
Time                  &  $t$       &     T          &   $t=100\bar{t}$                \\
Diffusion coefficient &  $D$       &     $L^2 {\rm ps}^{-1}$ &  $D=d \bar{D} $    \\
\bottomrule
\end{tabular}
\end{center}
\end{definition}

\begin{definition}[Affine function for length]
\begin{align*}
       [0, 100] \rightarrow [-64, 64]
\end{align*}
Therfore, the affine function is
\begin{align*}
        x = f(\bar{x}) = \frac{128}{100}\bar{x} - 64
\end{align*}
The inverse affine is
\begin{align*}
        \bar{x} = f^{-1}(x) = \frac{100}{128}x + 50
\end{align*}
For convenience, I name the unit of $x$ is $L$
\end{definition}

\begin{definition}[Time Transformation]
For convenience, I name the unit of time is $T$
\begin{align*}
        1T = 100~\rm{ps}
\end{align*}
\end{definition}

\begin{definition}[Potential Energy and Force Transformation]
\begin{align*}
        V(x)=\frac{\bar{V}(f^{-1}(x))}{k_B T}
\end{align*}
and the force is
\begin{align*}
        F(x)= -\frac{d{V(x)}}{d{x}}
\end{align*}
\end{definition}

\begin{definition}[Diffusion Coefficient Transformation]
$\bar{D}$ has dimension
\begin{align*}
        \text{\AA}^2 {\rm ps}^{-1}.
\end{align*}
$D$ has dimension
\begin{align*}
        L^2 T^{-1}.
\end{align*}
We want to find $d$ for
\begin{align*}
        D = d \bar{D}
\end{align*}
and we know
\begin{align*}
        1 L &= \frac{100}{128}\text{\AA} \\
        1 \text{\AA} &= \frac{128}{100}L \\
        1 \rm{ps} &= \frac{1}{100} T \\
        1 \rm{ps}^{-1} &= 100 T^{-1}
\end{align*}
Therefore
\begin{align*}
        d = (\frac{128}{100})^2 \times 100
\end{align*}
\end{definition}

\section{Flowchart of PISL}
\begin{center}
        \includegraphics[scale=0.65]{ch1/flowchart_example.pdf}
\end{center}

\section{Possible Factors affect the result of EM}
\begin{itemize}
        \item Affine function: $f(x)$. After test, No effect.
        \item $\sigma_{\rm photon}$ for approximating delta function
        \item MD saving time: $\Delta \bar{t}$
        \item MD total simulation time: $\bar{T}$
        \item Initial guess: $p_0$
\end{itemize}

\section{Ito calculus}
\begin{definition}[Ito SDE]
A stochastic quantity $x(t)$ obeys an Ito SDE written as
\begin{equation}
        dx(t) = a[x(t), t]dt + b[x(t), t]d{W}(t)
\end{equation}
\end{definition}

\begin{definition}[Ito's Formula]
\begin{equation}
        df[x(t)] = \{a[x(t), t]f'[x(t)]+ \frac{1}{2}b[x(t),t]^2 f''[x(t)]\}dt + b[x(t),t]f'[x(t)]dW(t)
\end{equation}
\end{definition}

\begin{definition}[Connection between Fokker-Planck Equation and SDE]
Consider the time development of an arbitrary $f[x(t)]$.
\begin{align*}
        \frac{\langle df[x(t)]\rangle}{dt} = \langle\frac{ df[x(t)]}{dt}\rangle = \frac{d}{dt}\langle f[x(t)]\rangle
\end{align*}
From Ito's Formula, we also get
\begin{align*}
        \frac{\langle df[x(t)]\rangle}{dt} = \langle a[x(t), t] \frac{\partial f}{\partial x}+ \frac{1}{2}b[x(t),t]^2 \frac{\partial^2 f}{\partial x^2} \rangle
\end{align*}
On the other hand, $x(t)$ has a conditional probability density $p(x,t|x_0,t_0)$ and
\begin{align*}
        \frac{d}{dt}\langle f[x(t)]\rangle &= \int f(x) \frac{\partial p(x,t|x_0,t_0)}{\partial t} dx
\end{align*}
and
\begin{align*}
        \frac{d}{dt}\langle f[x(t)]\rangle &=  \langle a[x(t), t] \frac{\partial f}{\partial x}+ \frac{1}{2}b[x(t),t]^2 \frac{\partial^2 f}{\partial x^2} \rangle \\
        &= \int a[x(t), t] \frac{\partial f}{\partial x}+ \frac{1}{2}b[x(t),t]^2 \frac{\partial^2 f}{\partial x^2} p(x,t|x_0,t_0) dx
\end{align*}
Therefore,
\begin{align*}
        \int f(x) \frac{\partial p(x,t|x_0,t_0)}{\partial t} dx =  \int a[x(t), t] \frac{\partial f}{\partial x}+ \frac{1}{2}b[x(t),t]^2 \frac{\partial^2 f}{\partial x^2} p(x,t|x_0,t_0) dx
\end{align*}
We then integrate by parts and discard surface terms to obtain
\begin{align*}
        &\int f(x) \frac{\partial p(x,t|x_0,t_0)}{\partial t} dx = \\
        &\int f(x) \{  -\frac{\partial a[x(t), t] p(x,t|x_0,t_0)}{\partial x} + \frac{1}{2} \frac{\partial b[x(t),t]^2 p(x,t|x_0,t_0)}{\partial x^2} \}dx
\end{align*}
Since $f[x(t)]$ is arbitrary, we finally get the corresponding Fokker-Planck equation
\begin{equation}
        \frac{\partial p(x,t|x_0,t_0)}{\partial t} =  -\frac{\partial a[x(t), t] p(x,t|x_0,t_0)}{\partial x} + \frac{1}{2} \frac{\partial b[x(t),t]^2 p(x,t|x_0,t_0)}{\partial x^2}
\end{equation}
\end{definition}

\section{Constant D Langevin to Fokker-Planck: Ito SDE}
\begin{definition}[Constant D Langenvin Equation]
\begin{equation}
        dx(t) = a[x(t), t]dt + b[x(t), t]d{W}(t)
\end{equation}
where
\begin{align*}
        a[x(t), t] &= DF(x) \\
        b[x(t), t] &= \sqrt{2D}
\end{align*}
\end{definition}

\begin{definition}[Corresponding Fokker-Planck Equation(FPE)]
\begin{align*}
        \frac{\partial p(x,t|x_0,t_0)}{\partial t} =  -\frac{\partial a[x(t), t] p(x,t|x_0,t_0)}{\partial x} + \frac{1}{2} \frac{\partial b[x(t),t]^2 p(x,t|x_0,t_0)}{\partial x^2}
\end{align*}
The first term
\begin{align*}
        -\frac{\partial a[x(t), t] p(x,t|x_0,t_0)}{\partial x} = -D \frac{\partial F(x) p(x,t|x_0,t_0)}{\partial x}
\end{align*}
The second term
\begin{align*}
        \frac{1}{2} \frac{\partial b[x(t),t]^2 p(x,t|x_0,t_0)}{\partial x^2} = D \frac{\partial p(x,t|x_0,t_0)}{\partial x^2}
\end{align*}
Finally, we get
\begin{equation}
        \frac{\partial p(x,t|x_0,t_0)}{\partial t} =  -D \frac{\partial F(x) p(x,t|x_0,t_0)}{\partial x} + D \frac{\partial p(x,t|x_0,t_0)}{\partial x^2}
\end{equation}
\end{definition}

\begin{definition}[Continuous equation and probability current]
Now, $p(x,t)$ is a shorthand notation of $p(x,t|x_0,t_0)$. And from FPE, we get
\begin{align*}
        \frac{\partial p(x,t)}{\partial t} + \frac{\partial}{\partial x} [DF(x)p(x,t) - D\frac{\partial p(x,t)}{\partial x} ] = 0
\end{align*}
As a general continuity equation in a differential form:
\begin{align*}
        \frac{\partial p(x,t)}{\partial t} + \nabla \cdot j(x,t) = 0
\end{align*}
And $j(x,t)$ is the current associated with the probability density $p(x,t)$
\begin{equation}
        j(x,t) 	\equiv DF(x)p(x,t) - D\frac{\partial p(x,t)}{\partial x}
\end{equation}
\end{definition}

\begin{definition}[Natural boundary conditions]
We imposed
\begin{align*}
        \lim_{x\to\pm\infty} p(x,t) &= 0 \\
        \lim_{x\to\pm\infty} \frac{\partial p(x,t)}{\partial x}&= 0
\end{align*}
\end{definition}

\begin{definition}[The conservation of probability]
Define $\mathcal{N}(t)$ as the integral of the probability density throughout space:
\begin{align*}
        \mathcal{N}(t) \equiv \int p(x,t) dx
\end{align*}
We want to show the conservation of probability by the following equation
\begin{align*}
        \frac{d \mathcal{N}(t)}{dt} = 0
\end{align*}
We begin by computing the time derivative of $\mathcal{N}(t)$ by using FPE
\begin{align*}
\frac{d\mathcal{N}(t)}{dt} &= \int_{-\infty}^{\infty}\frac{\partial p(x,t)}{\partial t}dx \\
&= \int_{-\infty}^{\infty}-D\frac{\partial}{\partial x} [F(x)p(x,t) - \frac{\partial p(x,t)}{\partial x} ]dx \\
&= -D\int_{-\infty}^{\infty}\frac{\partial j(x,t)}{\partial x}dx
\end{align*}
By natrual boundary conditions, we can get
\begin{align*}
\frac{d\mathcal{N}(t)}{dt} &= -D\left [ j(\infty,t) - j(-\infty,t)\right ] \\
&= -D\{[F(\infty)p(\infty,t) - \frac{\partial p(\infty,t)}{\partial x}]-[F(-\infty)p(-\infty,t) - \frac{\partial p(-\infty,t)}{\partial x}]\} \\
&= -D\{0-0\} = 0
\end{align*}
As you can see, the natural boundary conditions gurantee us the conservation of probability.
\end{definition}

\begin{definition}[Transform FPE into an equation of Schrödinger type]
Starting with the transformation $p(x,t) \rightarrow \rho(x,t)$
\begin{equation}
        p(x,t) \equiv \exp{(\frac{-V(x)}{2})}\rho(x,t)
\label{ptorho}
\end{equation}
FPE is
\begin{equation}
\label{eq:FPE}
\begin{split}
        \frac{\partial p(x,t)}{\partial t} &= -D\frac{\partial}{\partial x}\left [ F(x)p(x,t) \right] + D \frac{\partial^2 p(x,t)}{\partial x^2} \\
        &= -D\frac{d F(x)}{dx}p(x,t) - DF(x)\frac{\partial p(x,t)}{\partial x} + D \frac{\partial^2 p(x,t)}{\partial x^2}
\end{split}
\end{equation}
Substitute the eq.(\ref{ptorho}) into eq.(\ref{eq:FPE})
\begin{align*}
        \exp{(\frac{-V(x)}{2})}\frac{\partial \rho(x,t)}{\partial t} &= D\frac{d^2 V(x)}{dx^2}\exp{(\frac{-V(x)}{2})}\rho(x,t) -\frac{1}{2}D(\frac{d V(x)}{dx})^{2}\exp{(\frac{-V(x)}{2})}\rho(x,t)\\
&+D\frac{dV(x)}{dx}\exp{(\frac{-V(x)}{2})} \frac{\partial \rho(x,t)}{\partial x} -\frac{1}{2}D\frac{d^2 V(x)}{dx^2}\exp{(\frac{-V(x)}{2})}\rho(x,t)\\
&+\frac{1}{4}D(\frac{d V(x)}{dx})^2\exp{(\frac{-V(x)}{2})}\rho(x,t) -D\frac{d V(x)}{dx}\exp{(\frac{-V(x)}{2})}\frac{\partial \rho(x,t)}{\partial x}\\
&+D\exp{(\frac{-V(x)}{2})} \frac{\partial^2 \rho(x,t)}{\partial x^2} \\
&= \frac{1}{2}D\frac{d^2 V(x)}{dx^2}\exp{(\frac{-V(x)}{2})}\rho(x,t) -\frac{1}{4}D(\frac{d V(x)}{dx})^{2}\exp{(\frac{-V(x)}{2})}\rho(x,t)\\
&+D\exp{(\frac{-V(x)}{2})} \frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
Multiply $\exp{(\frac{V(x)}{2})}$ on both sides,
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} = \frac{1}{2}D\frac{d^2 V(x)}{dx^2}\rho(x,t)-\frac{1}{4}D(\frac{d V(x)}{dx})^{2}\rho(x,t) +D\frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
and we know
\begin{align*}
        \frac{d^2 V(x)}{dx^2} &= -\frac{dF(x)}{dx}\\
        (\frac{d V(x)}{dx})^{2} &= F^2(x)
\end{align*}
Finally,
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} = -\frac{1}{2}D\frac{d F(x)}{dx}\rho(x,t)-\frac{1}{4} D F^{2}(x) \rho(x,t) +D\frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
\end{definition}

\begin{definition}[PDE with Hermitian operator]
\begin{align*}
        \frac{\partial}{\partial t} \rho(x,t) = -\textbf{H} \rho(x,t)
\end{align*}
where
\begin{align*}
        \textbf{H}^0 = -D \frac{\partial^2}{\partial x^2} + \frac{1}{2}D\frac{d F(x)}{dx} + \frac{1}{4} D F^{2}(x)
\end{align*}
\end{definition}

\begin{definition}[Change Variable for t]
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} = -\frac{1}{2}D\frac{d F(x)}{dx}\rho(x,t)-\frac{1}{4} D F^{2}(x) \rho(x,t) +D\frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
We divide $D$ on both sides:
\begin{align*}
        \frac{1}{D}\frac{\partial \rho(x,t)}{\partial t} = -\frac{1}{2}\frac{d F(x)}{dx}\rho(x,t)-\frac{1}{4} F^{2}(x) \rho(x,t) +\frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
We let $\tau$
\begin{align}
        \tau &= D t \\
        d{\tau} &= D d{t}
\end{align}
Therefore
\begin{align}
        \frac{\partial \rho(x,\frac{\tau}{D})}{\partial \tau} = -\frac{1}{2}\frac{d F(x)}{dx}\rho(x,\frac{\tau}{D})-\frac{1}{4} F^{2}(x) \rho(x,\frac{\tau}{D}) +\frac{\partial^2 \rho(x,\frac{\tau}{D})}{\partial x^2}
\end{align}
\end{definition}

\begin{definition}[Hermicity]
If $\textbf{H}^0$ is a Hermitian operator for functions $\psi(x)$ which satisfies natural boundary conditions mentioned above, the following equation should hold:
\begin{align*}
        \langle \psi_i | \textbf{H}^0 \psi_j \rangle &= \langle \textbf{H}^0 \psi_i | \psi_j \rangle \\
        &= \int_{-\infty}^{\infty}dx \psi^{*}_i \textbf{H}^0 \psi_j = \int_{-\infty}^{\infty}dx (\textbf{H}^0\psi_i)^* \psi_j
\end{align*}
Starting from the left hand side:
\begin{align*}
\int_{-\infty}^{\infty}dx \psi^{*}_i \textbf{H}^0 \psi_j &= \int_{-\infty}^{\infty}dx \psi^{*}_i [-D \frac{\partial^2 \psi_j}{\partial x^2} + \frac{1}{2}D F'(x)\psi_j + \frac{1}{4}DF^2(x)\psi_j] \\
&= -D\int_{-\infty}^{\infty}\psi^{*}_i \frac{\partial^2 \psi_j}{\partial x^2} dx +\frac{1}{2}D \int_{-\infty}^{\infty} F'(x) \psi^{*}_i \psi_j dx + \frac{1}{4}D\int_{-\infty}^{\infty} \psi^{*}_i F^2(x)\psi_j dx \\
& = D\int_{-\infty}^{\infty} \frac{\partial \psi^*_i}{\partial x} \frac{\partial \psi_j}{\partial x}dx +\frac{1}{2}D \int_{-\infty}^{\infty} F'(x) \psi^{*}_i \psi_j dx + \frac{1}{4}D\int_{-\infty}^{\infty} \psi^{*}_i F^2(x)\psi_j dx
\end{align*}
The right hand side:
\begin{align*}
\int_{-\infty}^{\infty}dx (\textbf{H}^0\psi_i)^* \psi_j &= \int_{-\infty}^{\infty}dx [-D \frac{\partial^2 \psi_i}{\partial x^2} + \frac{1}{2}D F'(x)\psi_i + \frac{1}{4}DF^2(x)\psi_i]^{*}\psi_j \\
&= -D\int_{-\infty}^{\infty}\frac{\partial^2 \psi^*_i}{\partial x^2}\psi_j dx + \frac{1}{2}D\int_{-\infty}^{\infty}F'(x)\psi^*_i \psi_j dx + \frac{1}{4}D\int_{-\infty}^{\infty} F^2(x)\psi^*_i \psi_j dx \\
&= -D\int_{-\infty}^{\infty}\frac{\partial \psi^*_i}{\partial x}\frac{\partial \psi_j}{\partial x} dx + \frac{1}{2}D\int_{-\infty}^{\infty}F'(x)\psi^*_i \psi_j dx + \frac{1}{4}D\int_{-\infty}^{\infty} F^2(x)\psi^*_i \psi_j dx \\
\end{align*}
As you can see, the two sides result in the two functional form, so $\textbf{H}^0$ is a Hermitian operator.
Here, we used integration by parts and boundary conditions:
\begin{align*}
\int_{-\infty}^{\infty}\psi^{*}_i \frac{\partial^2 \psi_j}{\partial x^2} dx &= \int_{-\infty}^{\infty}\psi^{*}_i \frac{\partial}{\partial x}(\frac{\partial \psi_j}{\partial x}) dx \\
& = [\psi^{*}_i \frac{\partial \psi_j}{\partial x}]_{-\infty}^{\infty} - \int_{-\infty}^{\infty} \frac{\partial \psi^*_i}{\partial x} \frac{\partial \psi_j}{\partial x}dx\\
& = - \int_{-\infty}^{\infty} \frac{\partial \psi^*_i}{\partial x} \frac{\partial \psi_j}{\partial x}dx
\end{align*}
\end{definition}

\section{From FPE to Ito SDE for position-dependent diffusity}
\begin{definition}[Flux]
\begin{align*}
        j(x) = D(x)\left( F(x)p(x,t) - \frac{\partial p(x,t)}{\partial x}\right)
\end{align*}
If $p(x,t) = p_{\rm eq}(x) = \exp{(-V(x))}$
\begin{align*}
        j(x) &= D(x)\left( F(x)\exp{(-V(x))} - \left(-\frac{dV(x)}{dx}\right)\exp{(-V(x))} \right) \\
        &= D(x) \left[ F(x)\exp{(-V(x))} - F(x)\exp{(-V(x))}\right] = 0
\end{align*}
\end{definition}

\begin{definition}[Continuous equation and FPE]
A general continuity equation in a differential form:
\begin{align*}
        \frac{\partial p(x,t)}{\partial t} &= - \nabla \cdot j(x,t) \\
        &= - \frac{\partial D(x)}{\partial x}\left( F(x)p(x,t) - \frac{\partial p(x,t)}{\partial x}\right) - D(x) \frac{\partial \left( F(x)p(x,t) - \frac{\partial p(x,t)}{\partial x}\right) }{\partial x}
\end{align*}
The first term in right hand side is:
\begin{align*}
        - \frac{\partial D(x)}{\partial x}F(x)p(x,t) + \frac{\partial D(x)}{\partial x}\frac{\partial p(x,t)}{\partial x}
\end{align*}
The second term in right hand side is:
\begin{align*}
        -D(x)\frac{\partial F(x)}{\partial x}p(x,t) -D(x)F(x)\frac{\partial p(x,t)}{\partial x} + D(x) \frac{\partial^2 p(x,t)}{\partial x^2}
\end{align*}
Collect together:
\begin{align*}
        -\left(\frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} \right)p(x,t) - \left( D(x)F(x) -\frac{\partial D(x)}{\partial x} \right)\frac{\partial p(x,t)}{\partial x} + D(x) \frac{\partial^2 p(x,t)}{\partial x^2}
\end{align*}
\end{definition}

\begin{definition}[Ito's SDE and FPE]
On the other hand, the form of FPE can be
\begin{align*}
        \frac{\partial p(x,t)}{\partial t} =  -\frac{\partial a(x) p(x,t)}{\partial x} + \frac{1}{2} \frac{\partial^2 b^2(x) p(x,t)}{\partial x^2}
\end{align*}
Expand the first term of the right hand side:
\begin{align*}
        -\frac{\partial a(x)}{\partial x}p(x,t) - a(x)\frac{\partial  p(x,t)}{\partial x}
\end{align*}
Expand the second term of the right hand side:
\begin{align*}
        &\frac{1}{2}\frac{\partial}{\partial x} \left( \frac{\partial b^2(x) p(x,t)}{\partial x}  \right) =
        \frac{1}{2}\frac{\partial}{\partial x} \left( \frac{\partial b^2(x)}{\partial x}p(x,t) + b^2(x) \frac{\partial p(x,t)}{\partial x} \right) =\\
        & \frac{1}{2}\left(
                \frac{\partial^2 b^2(x)}{\partial x^2} p(x,t) + 2\frac{\partial b^2(x)}{\partial x}\frac{\partial p(x,t)}{\partial x} + b^2(x) \frac{\partial^2 p(x,t)}{\partial x^2}
        \right)
\end{align*}
Collect together
\begin{align*}
        \left( -\frac{\partial a(x)}{\partial x} + \frac{1}{2}\frac{\partial^2 b^2(x)}{\partial x^2} \right) p(x,t)
        + \left( -a(x) +  \frac{\partial b^2(x)}{\partial x} \right) \frac{\partial p(x,t)}{\partial x}
        + \frac{1}{2}b^2(x) \frac{\partial^2 p(x,t)}{\partial x^2}
\end{align*}
\end{definition}

\begin{definition}[Try to find a(x) and b(x)]
From continuous equation, we get
\begin{align*}
        -\left(\frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} \right)p(x,t) - \left( D(x)F(x) -\frac{\partial D(x)}{\partial x} \right)\frac{\partial p(x,t)}{\partial x} + D(x) \frac{\partial^2 p(x,t)}{\partial x^2}
\end{align*}
From Ito's FPE, we get
\begin{align*}
        \left( -\frac{\partial a(x)}{\partial x} + \frac{1}{2}\frac{\partial^2 b^2(x)}{\partial x^2} \right) p(x,t)
        + \left( -a(x) +  \frac{\partial b^2(x)}{\partial x} \right) \frac{\partial p(x,t)}{\partial x}
        + \frac{1}{2}b^2(x) \frac{\partial^2 p(x,t)}{\partial x^2}
\end{align*}
Therefore,
\begin{align}
        -\left(\frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} \right) & = \left( -\frac{\partial a(x)}{\partial x} + \frac{1}{2}\frac{\partial^2 b^2(x)}{\partial x^2} \right) \label{eqab1} \\
        - \left( D(x)F(x) -\frac{\partial D(x)}{\partial x} \right) &= \left( -a(x) +  \frac{\partial b^2(x)}{\partial x} \right) \label{eqab2} \\
        D(x) &= \frac{1}{2}b^2(x) \label{eqab3}
\end{align}
By eq.(\ref{eqab3}), we first get
\begin{align*}
        b(x) &= \sqrt{2D(x)} \\
        \frac{\partial b^2(x)}{\partial x} &= 2 \frac{\partial D(x)}{\partial x} \\
        \frac{1}{2}\frac{\partial^2 b^2(x)}{\partial x^2} &= \frac{\partial^2 D(x)}{\partial x^2}
\end{align*}
and we substitute the above into eq.(\ref{eqab2}),
\begin{align*}
        -D(x)F(x) + \frac{\partial D(x)}{\partial x} = -a(x) + 2 \frac{\partial D(x)}{\partial x}
\end{align*}
so
\begin{align*}
        a(x) &= D(x)F(x) + \frac{\partial D(x)}{\partial x} \\
        \frac{\partial a(x)}{\partial x} &= \frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} + \frac{\partial^2 D(x)}{\partial x^2}
\end{align*}
Finally, we substitute $\frac{\partial a(x)}{\partial x}$ and $\frac{\partial^2 b^2(x)}{\partial x^2}$ into eq.(\ref{eqab1}) try to check the consistency
\begin{align*}
        -\left(\frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} \right) = -\left( \frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} + \frac{\partial^2 D(x)}{\partial x^2} \right) + \frac{\partial^2 D(x)}{\partial x^2}
\end{align*}
and they are consistent.
\end{definition}

\begin{definition}[Ito SDE]
From the above, we get
\begin{align}
        a(x) &= D(x)F(x) + \frac{\partial D(x)}{\partial x} \\
        b(x) &= \sqrt{2D(x)}
\end{align}
Therefore, the langevin equation(SDE) for position-dependent diffusity is
\begin{equation}
\begin{split}
        dx(t) &= a(x)dt + b(x)dW(t) \\
        &= D(x)F(x)dt + \frac{\partial D(x)}{\partial x}dt + \sqrt{2D(x)}dW(t)
\end{split}
\label{posdepsde}
\end{equation}
\end{definition}

\begin{definition}[D(x)]
We express the position dependent diffusity as
\begin{equation}
        D(x) = D + \eta(x)
\label{dofx}
\end{equation}
The domain $x \in [a,b]$, and the integration of $\eta(x)$ over whole domain is 0
\begin{align*}
        \int_a^b \eta(x) dx = 0
\end{align*}
and
\begin{align*}
        \int_a^b D(x) dx &= \int_a^b D dx + \int_a^b \eta(x) dx \\
        &= D \int_a^b dx = (b-a)D
\end{align*}
\end{definition}

\begin{definition}[Rewrite Ito SDE]
Now, substitute eq.(\ref{dofx}) into eq.(\ref{posdepsde})
\begin{align*}
        dx(t) &= D(x)F(x)dt  + \sqrt{2D(x)}dW(t) \\
        &= DF(x)dt + \eta(x)F(x)dt + \sqrt{2D+2\eta(x)}dW(t)
\end{align*}
We introduced a new function $\epsilon(x)$
\begin{align*}
        \sqrt{2D+2\eta(x)}dW(t) = \sqrt{2D}dW(t) + \epsilon(x)dW(t)
\end{align*}
Therefore, SDE becomes
\begin{align*}
        dx(t) = \left(DF(x)dt + \sqrt{2D}dW(t)\right) + \left(\eta(x)F(x)dt + \epsilon(x)dW(t)\right)
\end{align*}
\end{definition}

\begin{definition}[Some convenient equations]
\begin{align*}
        \frac{\partial p(x,t)}{\partial x} &= \frac{1}{2}F(x)g(x)\rho(x,t) + g(x) \frac{\partial \rho(x,t)}{\partial x} \\
        \frac{\partial^2 p(x,t)}{\partial x^2} &= \frac{1}{2} \frac{d F(x)}{dx} g(x) \rho(x,t) + \frac{1}{4}F^2(x)g(x)\rho(x,t) + F(x)g(x)\frac{\partial \rho(x,t)}{\partial x} + g(x) \frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
\end{definition}

\begin{definition}[Transform FPE into an equation of Schrödinger type]
Starting with the transformation $p(x,t) \rightarrow \rho(x,t)$
\begin{equation}
\label{eq:transformFPE}
        p(x,t) \equiv \exp{(\frac{-V(x)}{2})}\rho(x,t) = g(x) \rho(x,t)
\end{equation}
FPE is
\begin{equation}
\label{eq:FPEexpand}
\begin{split}
        \frac{\partial p(x,t)}{\partial t} &= - \nabla \cdot j(x,t) = -\nabla \cdot D(x)\left( F(x)p(x,t) - \frac{\partial p(x,t)}{\partial x}\right) \\
        &= -\left(\frac{\partial D(x)}{\partial x}F(x) + D(x)\frac{\partial F(x)}{\partial x} \right)p(x,t) - \left( D(x)F(x) -\frac{\partial D(x)}{\partial x} \right)\frac{\partial p(x,t)}{\partial x} + D(x) \frac{\partial^2 p(x,t)}{\partial x^2}
\end{split}
\end{equation}
Substitute the eq.(\ref{eq:transformFPE}) into eq.(\ref{eq:FPEexpand}) and calculate all terms separately for the right terms
\begin{align*}
        -\frac{\partial D(x)}{\partial x}F(x)p(x,t) &= -\frac{\partial D(x)}{\partial x}g(x)F(x)\rho(x,t) \\
        -D(x)\frac{\partial F(x)}{\partial x}p(x,t) &= -g(x)D(x)\frac{\partial F(x)}{\partial x}\rho(x,t) \\
        - D(x)F(x)\frac{\partial p(x,t)}{\partial x} &= - \frac{1}{2}D(x)F^2(x)g(x)\rho(x,t) - D(x)F(x) g(x) \frac{\partial \rho(x,t)}{\partial x} \\
        \frac{\partial D(x)}{\partial x}\frac{\partial p(x,t)}{\partial x} &= \frac{1}{2}\frac{\partial D(x)}{\partial x}g(x)F(x) \rho(x,t) + g(x) \frac{\partial D(x)}{\partial x} \frac{\partial \rho(x,t)}{\partial x} \\
        D(x)\frac{\partial^2 p(x,t)}{\partial x^2} &= \frac{1}{2} D(x) \frac{\partial F(x)}{\partial x} g(x) \rho(x,t) + \frac{1}{4}D(x)F^2(x)g(x)\rho(x,t) \\
        &+ D(x)F(x)g(x)\frac{\partial \rho(x,t)}{\partial x} + D(x)g(x) \frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
Then,
\begin{align*}
        g(x) \frac{\partial \rho(x,t)}{\partial t} &= - \frac{1}{4}D(x)F^2(x)g(x)\rho(x,t) - \frac{1}{2}D(x)g(x) \frac{dF(x)}{dx} \rho(x,t) - \frac{1}{2}\frac{\partial D(x)}{\partial x}g(x)F(x) \rho(x,t) \\
        &+ g(x) \frac{\partial D(x)}{\partial x} \frac{\partial \rho(x,t)}{\partial x}  + D(x)g(x) \frac{\partial^2 \rho(x,t)}{\partial x^2}
\end{align*}
Multiply $\frac{1}{g(x)}$ on both sides, we get
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} &= - \frac{1}{2}D(x)\frac{dF(x)}{dx} \rho(x,t) - \frac{1}{4}D(x)F^2(x)\rho(x,t)   + D(x)\frac{\partial^2 \rho(x,t)}{\partial x^2} \\
        &+ \frac{\partial D(x)}{\partial x} \frac{\partial \rho(x,t)}{\partial x}  - \frac{1}{2}\frac{\partial D(x)}{\partial x}F(x) \rho(x,t)
\end{align*}
\end{definition}

\begin{definition}[Probability current]
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} &= D(x) \left(-\frac{1}{2}\frac{dF(x)}{dx} - \frac{1}{4}F^2(x) + \frac{\partial^2 }{\partial x^2}  \right) \rho(x,t) + \frac{\partial D(x)}{\partial x} \left( \frac{\partial }{\partial x} - \frac{1}{2} F(x) \right)\rho(x,t)
\end{align*}
\end{definition}

\begin{definition}[PDE and operator]
\begin{align*}
        \frac{\partial}{\partial t} \rho(x,t) = -\textbf{H} \rho(x,t)
\end{align*}
where
\begin{align*}
        \textbf{H} &= -D(x) \frac{\partial^2}{\partial x^2} + \frac{1}{2}D(x)\frac{d F(x)}{dx} + \frac{1}{4} D(x) F^{2}(x) -\frac{\partial D(x)}{\partial x}\frac{\partial }{\partial x} + \frac{1}{2} \frac{\partial D(x)}{\partial x} F(x)
\end{align*}
Recall that $D(x)=D+\eta(x)$, and substitute into each terms separately
\begin{align*}
        -D(x) \frac{\partial^2}{\partial x^2} &= -D\frac{\partial^2}{\partial x^2} - \eta(x)\frac{\partial^2}{\partial x^2} \\
        \frac{1}{2}D(x)\frac{d F(x)}{dx} &= \frac{1}{2}D\frac{d F(x)}{dx} + \frac{1}{2}\eta(x)\frac{d F(x)}{dx} \\
        \frac{1}{4} D(x) F^{2}(x)  &= \frac{1}{4} D F^{2}(x)  + \frac{1}{4} \eta(x) F^{2}(x)
\end{align*}
and we also know $\frac{\partial D(x)}{\partial x} = \frac{\partial \eta(x)}{\partial x} $, Therefore,
\begin{equation}
        \frac{\partial \rho(x,t)}{\partial t} = -\textbf{H} \rho(x,t) = -(\textbf{H}^0 +\textbf{H}^D) \rho(x,t)
\end{equation}
where
\begin{align*}
        \textbf{H}^0 &= -D\frac{\partial^2}{\partial x^2} + \frac{1}{2}D\frac{d F(x)}{dx} + \frac{1}{4} D F^{2}(x) \\
        \textbf{H}^D &= - \eta(x)\frac{\partial^2}{\partial x^2} + \frac{1}{2}\eta(x)\frac{d F(x)}{dx} + \frac{1}{4} \eta(x) F^{2}(x) -\frac{\partial \eta(x)}{\partial x}\frac{\partial }{\partial x} + \frac{1}{2} \frac{\partial \eta(x)}{\partial x} F(x)
\end{align*}
\end{definition}

\begin{definition}[Hermicity]
If $\textbf{H}$ is a Hermitian operator for functions $\psi(x)$ which satisfies natural boundary conditions mentioned above, the following equation should hold:
\begin{align*}
                \langle \psi_i | \textbf{H} \psi_j \rangle &= \langle \textbf{H} \psi_i | \psi_j \rangle \\
                &= \int_{-\infty}^{\infty}dx \psi_i \textbf{H} \psi_j = \int_{-\infty}^{\infty}dx (\textbf{H}\psi_i) \psi_j
\end{align*}
The left side:
\begin{align*}
        &\int_{-\infty}^{\infty} \psi_i(x) \textbf{H} \psi_j(x) dx = -D\int_{-\infty}^{\infty} \psi_i(x) \frac{\partial^2 \psi_j(x)}{\partial x^2} dx + \frac{1}{2}D\int_{-\infty}^{\infty} \psi_i(x) \frac{d F(x)}{dx} \psi_j(x) dx \\
        &+ \frac{1}{4}D\int_{-\infty}^{\infty} \psi_i(x) F^{2}(x) \psi_j(x) dx - \int_{-\infty}^{\infty} \psi_i(x) \eta(x)\frac{\partial^2 \psi_j(x)}{\partial x^2} dx \\
        &+ \frac{1}{2} \int_{-\infty}^{\infty} \psi_i(x) \eta(x)\frac{d F(x)}{dx} \psi_j(x) dx + \frac{1}{4}\int_{-\infty}^{\infty} \psi_i(x)  \eta(x) F^{2}(x) \psi_j(x) dx \\
        &- \int_{-\infty}^{\infty} \psi_i(x) \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_j(x)}{\partial x} dx + \frac{1}{2} \int_{-\infty}^{\infty} \psi_i(x)  \frac{\partial \eta(x)}{\partial x} F(x) \psi_j(x) dx
\end{align*}
The right side:
\begin{align*}
        &\int_{-\infty}^{\infty} (\textbf{H} \psi_i(x)) \psi_j(x) dx =  -D\int_{-\infty}^{\infty} \frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx + \frac{1}{2}D \int_{-\infty}^{\infty} \frac{d F(x)}{dx} \psi_i(x) \psi_j(x) dx \\
        &+ \frac{1}{4} D \int_{-\infty}^{\infty} F^{2}(x) \psi_i(x) \psi_j(x) dx - \int_{-\infty}^{\infty}  \eta(x)\frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx \\
        &+ \frac{1}{2} \int_{-\infty}^{\infty} \eta(x)\frac{d F(x)}{dx} \psi_i(x) \psi_j(x) dx + \frac{1}{4} \int_{-\infty}^{\infty} \eta(x) F^{2}(x) \psi_i(x) \psi_j(x) dx \\
        &- \int_{-\infty}^{\infty} \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_i(x)}{\partial x}  \psi_j(x) dx + \frac{1}{2} \int_{-\infty}^{\infty} \frac{\partial \eta(x)}{\partial x} F(x) \psi_i(x) \psi_j(x) dx
\end{align*}
The only different terms in the left hand side:
\begin{equation}\label{eq:left}
        -D\int_{-\infty}^{\infty} \psi_i(x) \frac{\partial^2 \psi_j(x)}{\partial x^2} dx - \int_{-\infty}^{\infty} \psi_i(x) \eta(x)\frac{\partial^2 \psi_j(x)}{\partial x^2} dx - \int_{-\infty}^{\infty} \psi_i(x) \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_j(x)}{\partial x} dx
\end{equation}
and in the right hand side:
\begin{equation}\label{eq:right}
        -D\int_{-\infty}^{\infty} \frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx - \int_{-\infty}^{\infty}  \eta(x)\frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx - \int_{-\infty}^{\infty} \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_i(x)}{\partial x}  \psi_j(x) dx
\end{equation}
\end{definition}

\begin{definition}[Hermicity-Integral by part: 1]\label{def:hermicity1}
\begin{align*}
        -D\int_{-\infty}^{\infty} \psi_i(x) \frac{\partial^2 \psi_j(x)}{\partial x^2} dx &= [\psi_i(x) \frac{\partial \psi_j(x)}{\partial x}]_{-\infty}^{\infty} - \int_{-\infty}^{\infty} \frac{\partial \psi_i(x)}{\partial x} \frac{\partial \psi_j(x)}{\partial x}dx\\
        & = - \int_{-\infty}^{\infty} \frac{\partial \psi_i(x)}{\partial x} \frac{\partial \psi_j(x)}{\partial x}dx
\end{align*}
\begin{align*}
        -D\int_{-\infty}^{\infty} \frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx &= [\frac{\partial \psi_i(x)}{\partial x}\psi_j(x) ]_{-\infty}^{\infty} - \int_{-\infty}^{\infty} \frac{\partial \psi_j(x)}{\partial x} \frac{\partial \psi_i(x)}{\partial x}dx\\
        & = - \int_{-\infty}^{\infty} \frac{\partial \psi_j(x)}{\partial x} \frac{\partial \psi_i(x)}{\partial x}dx
\end{align*}
Therefore, the first terms in two sides are the same.
\end{definition}

\begin{definition}[Hermicity-Integral by part: 2-1]\label{def:hermicity2-1}
\begin{align*}
        u(x) &= \psi_i(x) \eta(x) ~~~~~ v'(x) = \frac{\partial^2 \psi_j(x)}{\partial x^2} \\
        u'(x) &= \frac{\partial \psi_i(x)}{\partial x} \eta(x) + \frac{\partial \eta(x)}{\partial x} \psi_i(x) ~~~~~ v(x) = \frac{\partial \psi_j(x)}{\partial x}
\end{align*}
\begin{align*}
        &-\int_{-\infty}^{\infty} \psi_i(x) \eta(x)\frac{\partial^2 \psi_j(x)}{\partial x^2} dx = -{\Big [} \psi_i(x) \eta(x) \frac{\partial \psi_j(x)}{\partial x}{\Big ]}_{-\infty}^{\infty} \\
        &+ \int_{-\infty}^{\infty} \eta(x) \frac{\partial \psi_i(x)}{\partial x}  \frac{\partial \psi_j(x)}{\partial x} dx + \int_{-\infty}^{\infty}  \frac{\partial \eta(x)}{\partial x} \psi_i(x)  \frac{\partial \psi_j(x)}{\partial x} dx
\end{align*}
Therefore,
\begin{align*}
        &-\int_{-\infty}^{\infty} \psi_i(x) \eta(x)\frac{\partial^2 \psi_j(x)}{\partial x^2} dx - \int_{-\infty}^{\infty} \psi_i(x) \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_j(x)}{\partial x} dx = \\
        &\int_{-\infty}^{\infty} \eta(x) \frac{\partial \psi_i(x)}{\partial x}  \frac{\partial \psi_j(x)}{\partial x} dx + \int_{-\infty}^{\infty}  \frac{\partial \eta(x)}{\partial x} \psi_i(x)  \frac{\partial \psi_j(x)}{\partial x} dx
        - \int_{-\infty}^{\infty} \psi_i(x) \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_j(x)}{\partial x} dx \\
        &= \int_{-\infty}^{\infty} \eta(x) \frac{\partial \psi_i(x)}{\partial x}  \frac{\partial \psi_j(x)}{\partial x} dx
\end{align*}
\end{definition}

\begin{definition}[Hermicity-Integral by part: 2-2]\label{def:hermicity2-2}
\begin{align*}
        u(x) &= \psi_j(x) \eta(x) ~~~~~ v'(x) = \frac{\partial^2 \psi_i(x)}{\partial x^2}\\
        u'(x) &= \frac{\partial \psi_j(x)}{\partial x} \eta(x) + \frac{\partial \eta(x)}{\partial x} \psi_j(x) ~~~~~ v(x) = \frac{\partial \psi_i(x)}{\partial x}
\end{align*}
\begin{align*}
        &- \int_{-\infty}^{\infty}  \eta(x)\frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx = -{\Big [} \psi_j(x) \eta(x) \frac{\partial \psi_i(x)}{\partial x}{\Big ]}_{-\infty}^{\infty} \\
        &+ \int_{-\infty}^{\infty} \eta(x) \frac{\partial \psi_j(x)}{\partial x}  \frac{\partial \psi_i(x)}{\partial x} dx + \int_{-\infty}^{\infty}  \frac{\partial \eta(x)}{\partial x} \psi_j(x)  \frac{\partial \psi_i(x)}{\partial x} dx
\end{align*}
Therefore,
\begin{align*}
        & - \int_{-\infty}^{\infty}  \eta(x)\frac{\partial^2 \psi_i(x)}{\partial x^2} \psi_j(x) dx - \int_{-\infty}^{\infty} \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_i(x)}{\partial x}  \psi_j(x) dx = \\
        & \int_{-\infty}^{\infty} \eta(x) \frac{\partial \psi_j(x)}{\partial x}  \frac{\partial \psi_i(x)}{\partial x} dx + \int_{-\infty}^{\infty}  \frac{\partial \eta(x)}{\partial x} \psi_j(x)  \frac{\partial \psi_i(x)}{\partial x} dx - \int_{-\infty}^{\infty} \frac{\partial \eta(x)}{\partial x}\frac{\partial \psi_i(x)}{\partial x}  \psi_j(x) dx\\
        &= \int_{-\infty}^{\infty} \eta(x) \frac{\partial \psi_j(x)}{\partial x}  \frac{\partial \psi_i(x)}{\partial x} dx
\end{align*}
\end{definition}

\begin{definition}[H is Hermitian]
From def.(\ref{def:hermicity1})(\ref{def:hermicity2-1})(\ref{def:hermicity2-2}) and eq.(\ref{eq:left})(\ref{eq:right}),
we prove $\textbf{H}$ is Hermitian. Therefore, we can find a set of orthonormal basis $\{\psi_i(x)\}$
\begin{equation}
        \textbf{H}\psi_i(x) = \lambda_i \psi_i(x)
\end{equation}
And for PDE
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} = - \textbf{H} \rho(x,t)
\end{align*}
We can have the solution
\begin{equation}
        \rho(x,t) = \sum_i c_i \text{e}^{-\lambda_i t} \psi_i(x)
\end{equation}
\end{definition}

\section{Find the eigenfunction like dark operator}
\begin{definition}[The first set of orthonormal basis]
Because $\textbf{H}^0$ is Hermitian, we can get a set of orthonormal basis $\{\psi^0_i(x)\}$
\begin{align*}
        \textbf{H}^0 \psi^0_i(x) = \lambda^0_i \psi^0_i(x)
\end{align*}
\end{definition}

\begin{definition}[Construct another eigenbasis]
Recall that
\begin{align*}
        \frac{\partial \rho(x,t)}{\partial t} = -\textbf{H} \rho(x,t) = -(\textbf{H}^0 +\textbf{H}^D) \rho(x,t)
\end{align*}
Because $\textbf{H}$ is Hermitian, we can find a set of eigenfunctions $\{\psi_i(x)\}$
\begin{equation}
        \textbf{H} \left | \psi_i \right> =  \lambda_i \left | \psi_i \right>
\end{equation}
And the new eigenfunction is then constructed as a linear combination of $\left| \psi_j^0\right>$
\begin{align*}
        \left| \psi_i \right> = \sum_j c_{ij}  \left| \psi_j^0\right>
\end{align*}
so the question now is to find $c_{ij}$ and get a correct linear combination.
\end{definition}

\begin{definition}[Find c]
First, assume $i=1~\textrm{to}~n$,
\begin{equation}
\label{psi0psi}
\begin{split}
        | \psi_1 \rangle = c_{11}| \psi_1^0 \rangle + c_{12}| \psi_2^0 \rangle +  c_{13}| \psi_3^0 \rangle+\cdots + c_{1n}| \psi_n^0 \rangle\\
        | \psi_2 \rangle = c_{21}| \psi_1^0 \rangle + c_{22}| \psi_2^0 \rangle +  c_{23}| \psi_3^0 \rangle+\cdots + c_{2n}| \psi_n^0 \rangle\\
        | \psi_3 \rangle = c_{31}| \psi_1^0 \rangle + c_{32}| \psi_2^0 \rangle +  c_{33}| \psi_3^0 \rangle+\cdots + c_{3n}| \psi_n^0 \rangle\\
        \vdots \\
        | \psi_n \rangle = c_{n1}| \psi_1^0 \rangle + c_{n2}| \psi_2^0 \rangle +  c_{n3}| \psi_3^0 \rangle+\cdots + c_{nn}| \psi_n^0 \rangle
\end{split}
\end{equation}
Now, we focus on the case of $i=1$
\begin{equation}
\label{eg1}
        \textbf{H} | \psi_1 \rangle = \lambda_1 | \psi_1 \rangle
\end{equation}
Then, substitute eq.(\ref{psi0psi}) into eq.(\ref{eg1})
\begin{equation}
\label{egextend}
\begin{split}
        c_{11}\textbf{H}| \psi_1^0 \rangle + c_{12}\textbf{H}| \psi_2^0\rangle +  c_{13}\textbf{H}| \psi_3^0\rangle + \cdots +  c_{1n}\textbf{H}| \psi_n^0\rangle =\\ \lambda_1 \left( c_{11}| \psi_1^0 \rangle + c_{12}| \psi_2^0 \rangle +  c_{13    }| \psi_3^0 \rangle+\cdots + c_{1n}| \psi_n^0 \rangle\right)
\end{split}
\end{equation}
And we multiply $\langle\psi_1^0|$ on the left-hand side of eq.(\ref{eg1})
\begin{equation}
\label{eg1multipleft}
\langle\psi_1^0|\textbf{H} | \psi_1 \rangle = \langle\psi_1^0|\lambda_1 | \psi_1 \rangle
\end{equation}
Eq.(\ref{egextend}) becomes
\begin{equation}
\begin{split}
c_{11}\langle\psi_1^0|\textbf{H}| \psi_1^0 \rangle + c_{12}\langle\psi_1^0|\textbf{H}| \psi_2^0\rangle +  c_{13}\langle\psi_1^0|\textbf{H}| \psi_3^0\rangle + \cdots +  c_{1n}\langle\psi_1^0|\textbf{H}| \psi_n^0\rangle =\\ \lambda_1 \left( c_{11}\langle\psi_1^0| \psi_1^0 \rangle + c_{12}\langle\psi_1^0| \psi_2^0 \rangle +  c_{13}\langle\psi_1^0| \psi_3^0 \rangle+\cdots + c_{1n}\langle\psi_1^0| \psi_n^0 \rangle\right)
\end{split}
\end{equation}
The eigenbasis $\{|\psi_i^0 \rangle\}$ is orthonormal, so
\begin{equation}
\label{eg1lastform}
\begin{split}
c_{11}\langle\psi_1^0|\textbf{H}| \psi_1^0 \rangle + c_{12}\langle\psi_1^0|\textbf{H}| \psi_2^0\rangle +  c_{13}\langle\psi_1^0|\textbf{H}| \psi_3^0\rangle + \cdots +  c_{1n}\langle\psi_1^0|\textbf{H}| \psi_n^0\rangle =\lambda_1 c_{11}
\end{split}
\end{equation}
\end{definition}

\begin{definition}[Matrix K]
We also can generate more equations by
\begin{equation}
\label{eg1gen}
\begin{split}
        \langle\psi_2^0|\bm{H} | \psi_1 \rangle &= \langle\psi_2^0|\lambda_1 | \psi_1 \rangle\\
        \langle\psi_3^0|\bm{H} | \psi_1 \rangle &= \langle\psi_3^0|\lambda_1 | \psi_1 \rangle\\
        &\vdots \\
        \langle\psi_n^0|\bm{H} | \psi_1 \rangle &= \langle\psi_n^0|\lambda_1 | \psi_1 \rangle
\end{split}
\end{equation}
By collecting equation (\ref{eg1}) and (\ref{eg1gen}), and express as equation (\ref{eg1lastform}), we can get the following matrix expression
\begin{equation}
\begin{bmatrix}
\langle\psi_1^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_1^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_1^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_1^0|\bm{H}| \psi_n^0 \rangle \\
\langle\psi_2^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_2^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_2^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_2^0|\bm{H}| \psi_n^0 \rangle \\
\vdots \\
\langle\psi_n^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_n^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_n^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_n^0|\bm{H}| \psi_n^0 \rangle
\end{bmatrix}
\begin{bmatrix}
c_{11} \\ c_{12} \\ \vdots \\ c_{1n}
\end{bmatrix}
= \lambda_1
\begin{bmatrix}
c_{11} \\ c_{12} \\ \vdots \\ c_{1n}
\end{bmatrix}
\end{equation}
Define
\begin{equation}
        K=
\begin{bmatrix}
        \langle\psi_1^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_1^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_1^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_1^0|\bm{H}| \psi_n^0 \rangle \\
        \langle\psi_2^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_2^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_2^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_2^0|\bm{H}| \psi_n^0 \rangle \\
        \vdots \\
        \langle\psi_n^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_n^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_n^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_n^0|\bm{H}| \psi_n^0 \rangle
\end{bmatrix}
\end{equation}
\end{definition}

\begin{definition}[The new eigen-problem for solving c]
\begin{equation}
        K\textbf{c}_{i} =
        \begin{bmatrix}
        \langle\psi_1^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_1^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_1^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_1^0|\bm{H}| \psi_n^0 \rangle \\
        \langle\psi_2^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_2^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_2^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_2^0|\bm{H}| \psi_n^0 \rangle \\
        \vdots \\
        \langle\psi_n^0|\bm{H}| \psi_1^0 \rangle & \langle\psi_n^0|\bm{H}| \psi_2^0 \rangle &\langle\psi_n^0|\bm{H}| \psi_3^0 \rangle & \cdots & \langle\psi_n^0|\bm{H}| \psi_n^0 \rangle
        \end{bmatrix}
        \begin{bmatrix}
        c_{i1} \\ c_{i2} \\ \vdots \\ c_{in}
        \end{bmatrix}
        = \lambda_{i}
        \begin{bmatrix}
        c_{i1} \\ c_{i2} \\ \vdots \\ c_{in}
        \end{bmatrix}
\end{equation}
Simply written as
\begin{equation}
\label{eigprob}
        K\textbf{c}_{i} = \lambda_{i}\textbf{c}_{i}
\end{equation}
Therefore, to find $c_{ij}$, which can assemble $\{| \psi_i\rangle\}$ by $\{| \psi_i^0\rangle\}$, turns out to be a eigenvalue problem as shown in equation (\ref{eigprob}).
\end{definition}

\begin{definition}[Matrix elements of K]
\begin{equation}
        K_{ij} = \langle \psi_i^0 | \textbf{H}^0 + \textbf{H}^D | \psi^0_j \rangle = \lambda_i^0 \delta_{ij} + \langle \psi_i^0 | \textbf{H}^D |\psi^0_j \rangle
\end{equation}
Recall that
\begin{align*}
        \textbf{H}^D = - \eta(x)\frac{\partial^2}{\partial x^2} + \frac{1}{2}\eta(x)\frac{d F(x)}{dx} + \frac{1}{4} \eta(x) F^{2}(x) - \frac{\partial \eta(x)}{\partial x} \frac{\partial}{\partial x} + \frac{1}{2} \frac{\partial \eta(x)}{\partial x} F(x)
\end{align*}
$\langle \psi_i^0 | \textbf{H}^D |\psi^0_j \rangle$ would becomes five terms
\begin{align}
        &-\int \psi_i^0(x) \eta(x)\frac{\partial^2 \psi^0_j(x)}{\partial x^2} dx \\
        &\frac{1}{2} \int \eta(x)\frac{d F(x)}{dx} \psi_i^0(x) \psi^0_j(x) dx \\
        &\frac{1}{4} \int \eta(x) F^{2}(x) \psi_i^0(x) \psi^0_j(x) dx \\
        &-\int \psi_i^0(x) \frac{\partial \eta(x)}{\partial x} \frac{\partial \psi^0_j(x)}{\partial x} dx \\
        &\frac{1}{2} \int \frac{\partial \eta(x)}{\partial x} F(x) \psi_i^0(x) \psi^0_j(x) dx
\end{align}
\end{definition}

\begin{definition}[Integration by parts]
If $u=u(x)$ and $du=u'(x)dx$, while $v=v(x)$ and $dv=v'(x)dx$
\begin{align*}
        \int _{a}^{b}u(x)v'(x) dx = {\Big [}u(x)v(x){\Big ]}_{a}^{b}-\int _{a}^{b}u'(x)v(x)dx
\end{align*}
\end{definition}

\begin{definition}[Term 1]
\begin{align*}
        u(x) &= \psi_i^0(x) \eta(x)  \\
        v'(x) &= \frac{\partial^2 \psi^0_j(x)}{\partial x^2}
\end{align*}
so
\begin{align*}
        u'(x) &= \frac{\partial \psi_i^0(x)}{\partial x} \eta(x) + \psi_i^0(x) \frac{\partial \eta(x)}{\partial x} \\
        v(x) &= \frac{\partial \psi^0_j(x)}{\partial x}
\end{align*}
Therefore
\begin{align*}
        -\int_a^b \psi_i^0(x) \eta(x)\frac{\partial^2 \psi^0_j(x)}{\partial x^2} dx &=  -{\Big [}  \eta(x) \psi_i^0(x) \frac{\partial \psi^0_j(x)}{\partial x} {\Big ]}_{a}^{b} \\
        &+ \int_a^b  \eta(x) \frac{\partial \psi_i^0(x)}{\partial x} \frac{\partial \psi^0_j(x)}{\partial x} dx + \int_a^b \frac{\partial \eta(x)}{\partial x} \psi_i^0(x)   \frac{\partial \psi^0_j(x)}{\partial x} dx
\end{align*}
and because $\frac{\partial \psi^0_j(a)}{\partial x}=0$ and $\frac{\partial \psi^0_j(b)}{\partial x}=0$, we get
\begin{equation}
        -\int_a^b \psi_i^0(x) \eta(x)\frac{\partial^2 \psi^0_j(x)}{\partial x^2} dx =  \int_a^{b} \eta(x) \frac{\partial \psi_i^0(x)}{\partial x} \frac{\partial \psi^0_j(x)}{\partial x} dx + \int_a^b \frac{\partial \eta(x)}{\partial x} \psi_i^0(x)   \frac{\partial \psi^0_j(x)}{\partial x} dx
\end{equation}
\end{definition}

\begin{definition}[Collecting Together]
Collecting the first term in the above and the other terms together, we get
\begin{align*}
        \langle \psi_i^0 | \textbf{H}^D |\psi^0_j \rangle &=  \int  \eta(x) \frac{\partial \psi_i^0(x)}{\partial x} \frac{\partial \psi^0_j(x)}{\partial x} dx + \int \frac{\partial \eta(x)}{\partial x} \psi_i^0(x) \frac{\partial \psi^0_j(x)}{\partial x} dx \\
        &+\frac{1}{2} \int \eta(x)\frac{d F(x)}{dx} \psi_i^0(x) \psi^0_j(x) dx + \frac{1}{4} \int \eta(x) F^{2}(x) \psi_i^0(x) \psi^0_j(x) dx \\
        &-\int \frac{\partial \eta(x)}{\partial x} \psi_i^0(x)  \frac{\partial \psi^0_j(x)}{\partial x} dx + \frac{1}{2} \int \frac{\partial \eta(x)}{\partial x} F(x) \psi_i^0(x) \psi^0_j(x) dx
\end{align*}
The final form is
\begin{equation}
\begin{split}
        \langle \psi_i^0 | \textbf{H}^D |\psi^0_j \rangle &= \int  \eta(x) \frac{\partial \psi_i^0(x)}{\partial x} \frac{\partial \psi^0_j(x)}{\partial x} dx + \frac{1}{2} \int \eta(x)\frac{d F(x)}{dx} \psi_i^0(x) \psi^0_j(x) dx \\
        &+ \frac{1}{4} \int \eta(x) F^{2}(x) \psi_i^0(x) \psi^0_j(x) dx + \frac{1}{2} \int \frac{\partial \eta(x)}{\partial x} F(x) \psi_i^0(x) \psi^0_j(x) dx
\end{split}
\end{equation}
\end{definition}
\begin{center}
        \includegraphics[scale=0.5]{ch1/H0_H_eigenbasis_test.pdf}
\end{center}


% !TeX spellcheck = en_US
\section{SAT into CSP encodings}\label{sec:sat_to_csp}
In this section, we discuss the opposite direction by introducing several ways for encoding SAT into CSP and briefly summarize the pros and cons of each encoding.

\subsection{Dual encoding}
For each clause in the CNF-formatted SAT a CSP variable is generated. The domain of each variable consists of the possible truth assignments that satisfies the corresponding clause expressed as a tuple. Any two clauses sharing the same propositional variable must also have a binary constraint between their respective dual variables. These constraints assure consistent assignment of the common propositional variable such that no variable is assigned two different values at the same time.

The following example shows how we could encode a SAT problem with two clauses and one common propositional variable. Considering the clauses: $x_1 \vee x_2$ and $x_3 \vee \neg x_2$. The first clause results in the dual variable $D_1$ with the domain $\{(T,T),(T,F),(F,T)\}$ where $T$ and $F$ represent the truth value of the corresponding Boolean variable at the respective position within the tuple. The second clause results in $D_2 \in \{(T,F),(T,T),(F,F)\}$. Since $x_2$ appears in both clauses, we must ensure that it will not have different values in each variable through the binary constraint: $D_1[2] = \neg D_2[2]$ which assures that the second element of the tuple assigned to $D_1$ is the inverse of the second element of the $D_2$ tuple.

\subsubsection{Theoretical comparison}
It has been proven \cite{walsh2000sat} that FC on the dual encoded SAT instance does more work than DPLL on the original problem. The proof is based on the fact that a truth assignment under unit propagation in DPLL implies an elimination of contradictory values on the CSP side. By induction, we can see that generating the empty clause in DPLL (which indicates that the problem is unsatisfiable regarding the current branch) implies a domain wipe out after applying arc-consistency by FC.

\subsection{Hidden variable encoding}
Just like dual encoding, the hidden variable encdoing assign a dual variable for each SAT clause. Furthermore, each propositional variable $x_i$ is simulated on the CSP side with a binary variable $X_i \in \{T,F\}$. This encoding allows constraints to be easily formulated in terms of thier binary variables. For example the clause $x_1 \vee \neg x_2$ results in one dual variable $D_1 \in \{(T,F),(F,F),(T,T)\}$ and two binary CSP variables $X_1, X_2$ and additionally the coupling constraints $D_1[1] = x_1$ and $D_1[2] = \neg x_2$ which constraints any assignment of the elements of the tuple assigned to $D_1$ to be consistent with the propositional variables $x_1,x_2$ represented by their CSP counterparts $X_1,X_2$.

\subsubsection{Theoretical comparison}
The hidden variable encoding maintain equivalent relation between assigning truth values committed by one literal rule on the DPLL side and eliminating contradictory values by enforcing arc-consistency by FC/MAC on the node level. This translates to equivalence relation between generating empty clauses and empty domain \cite{walsh2000sat}. This in turn means that DPLL will essentially branch in general as much as FC/MAC applied to the encoded version of the same problem, and the same amount of work is expected by each algorithm.

\subsection{Literal encoding}
The literal encoding express each clause as a variable with a domain consisting of propositional variables' values that satisfy the corresponding clause. Constraints are required between any CSP variables if and only if their domains contain contradictory propositional variables. For example the clauses $x_1 \vee x_2$ and $x_3 \vee \neg x_2$ can be expressed as the following variables $D_1 \in \{x_1, x_2\}, D_2 \in \{x_3, \neg x_2\}$ and the constraint $\neg (D_1 = x_2 \wedge D_2 = \neg x_2)$ which rules out the inconsistent assignment for $x_2$.

\subsubsection{Theoretical comparison}
This encoding shows similar results as the hidden variable encoding regarding the relation between generating the empty clause and empty domains as a result of enforcing arc-consistency. Anyway MAC is \textit{strictly} dominated by DPLL applied to the original problem. Strictness can be proved easily by contradiction. Consider any unsatisfiable $k-$SAT instance (i.e. a SAT problem with $k$ propositional variable) with $2^k$ clauses where $k > 2$. DPLL needs $2^{k-1}$ branch to arrive at the empty clause while MAC takes $k!$ branches regardless of the used heuristics \cite{walsh2000sat}.

\subsubsection{Advantage of literal encoding}
CSP domain size can have great impact on the performance of any arc-consistency based algorithm (like MAC or FC) and must be taken into consideration. Let $n$ be the number of SAT clauses. Dual and hidden variable encodings generate CSP instance with domain size in the order of $\mathcal{O}(2^n)$ while the literal encoding generate CSP instances with domain size of $\mathcal{O}(n)$ which means general performance improvement over dual and hidden variable encodings.