this is for holding javascript data
Antonio Coppola edited Examples.tex
over 9 years ago
Commit id: 425eaa0e26006443bb6dffdd646516f2ff4858ca
deletions | additions
diff --git a/Examples.tex b/Examples.tex
index d284d5d..6025018 100644
--- a/Examples.tex
+++ b/Examples.tex
...
\begin{itemize}
\item \textit{The Rosenbrock function:} We define the Rosenbrock function mapping $\mathbf{R}^2$ to $\mathbf{R}$ as $f(x,y) = 100 \cdot (y - x^2)^2 + (1 - x)^2$. The function has a global minimum at $(0,0)$ that lies within a a long, flat valley. We define the function and its gradient as R object, and then run the optimization routine:
\begin{lstlisting}
objective <- function(x) {
100 * (x[2] - x[1]^2)^2 + (1 - x[1])^2
}
gradient <- function(x) {
c(-400 * x[1] * (x[2] - x[1]^2) - 2 * (1 - x[1]),
200 * (x[2] - x[1]^2))
}
out <- lbfgs(objective, gradient, c(-1.2, 1))
\end{lstlisting}
\end{itemize}