blob: 02d6b9e476df98c11d840843ba41526e82040a87 [file] [log] [blame]
Sameer Agarwal8ed29a72012-06-07 17:04:25 -07001%!TEX root = ceres-solver.tex
Sameer Agarwald3eaa482012-05-29 23:47:57 -07002\chapter{Non-linear Least Squares}
3\label{chapter:tutorial:nonlinsq}
4Let $x \in \reals^n$ be an $n$-dimensional vector of variables, and
5$F(x) = \left[f_1(x); \hdots ; f_k(x)\right]$ be a vector of residuals $f_i(x)$.
6The function $f_i(x)$ can be a scalar or a vector valued
7function. Then,
8\begin{equation}
9 \arg \min_x \frac{1}{2} \sum_{i=1}^k \|f_i(x)\|^2.
10\end{equation}
Sameer Agarwal97fb6d92012-06-17 10:08:19 -070011is a Non-linear least squares problem~\footnote{Ceres can solve a more general version of this problem, but for pedagogical reasons, we will restrict ourselves to this class of problems for now. See section~\ref{chapter:overview} for a full description of the problems that Ceres can solve}. Here $\|\cdot\|$ denotes the Euclidean norm of a vector.
Sameer Agarwald3eaa482012-05-29 23:47:57 -070012
13Such optimization problems arise in almost every area of science and engineering. Whenever there is data to be analyzed, curves to be fitted, there is usually a linear or a non-linear least squares problem lurking in there somewhere.
14
15Perhaps the simplest example of such a problem is the problem of Ordinary Linear Regression, where given observations $(x_1,y_1),\hdots, (x_k,y_k)$, we wish to find the line $y = mx + c$, that best explains $y$ as a function of $x$. One way to solve this problem is to find the solution to the following optimization problem
16\begin{equation}
17 \arg\min_{m,c} \sum_{i=1}^k (y_i - m x_i - c)^2.
18\end{equation}
19With a little bit of calculus, this problem can be solved easily by hand. But what if, instead of a line we were interested in a more complicated relationship between $x$ and $y$, say for example $y = e^{mx + c}$. Then the optimization problem becomes
20\begin{equation}
21 \arg\min_{m,c} \sum_{i=1}^k \left(y_i - e^{m x_i + c}\right)^2.
22\end{equation}
23This is a non-linear regression problem and solving it by hand is much more tedious. Ceres is designed to help you model and solve problems like this easily and efficiently.