# How to implement conjugate gradient method to minimize this nonlinear action?

Given a 2D stochastic differential equation: \begin{align} \dot{x}_{i}=f_{i}(\textbf{x})+g_{ij}\xi_{j}(t), \end{align} where $i=2$, $g_{ij}g_{jk}=2\epsilon\delta_{ik}$ and $f(\textbf{x})=-\nabla\phi(\textbf{x})+l(\textbf{x})$ with $\nabla\phi(\textbf{x})\cdot l(\textbf{x})=0$, we have its action functional for trajectories: \begin{align} S_{T}(x(t))&=\int_{0}^{T}dt\frac{1}{4\epsilon}(\dot{x}_{i}-f_{i})^{2}. \end{align}

Let us now consider a 2D potential function with double well in $x$-direction: $\phi=\frac{1}{2}(y-1)^{2}-\frac{1}{2}(x-1)^{2}+\frac{1}{4}(x-1)^{4}$, and a given $l(\textbf{x})$. I want to minimize the corresponding discretized action for the set of trajectories connecting the two lowest energy points: \begin{align} S_{T}(x(t))=\Delta t\sum_{k=1}^{M-1}\sum_{i=1}^{2}\Big[\frac{x_{i}^{k+1}-x_{i}^{k}}{\Delta t}-\frac{1}{2}(f_{i}^{k+1}+f_{i}^{k})\Big]^{2}, \end{align} where the trajectory $x(t)$ is divided into $M-1$ time segments.

How to implement the conjugate gradient method to minimize this nonlinear action?