The trivial linear least squares problem

Frank Lanke Fu Tarimo
1 min readFeb 5, 2021

In this instance we are interested in solving a trivial problem with a very powerful tool. We have a target value for single variable x. Instead of directly setting the variable x to our desired target value, we are going to employ the Gauss-Newton algorithm which more generally solves non-linear least squares problems.

Following the Wikipedia definition https://en.wikipedia.org/wiki/Gauss%E2%80%93Newton_algorithm , we define a residual function for our variable x. In this case we want x to match our target value so we set the residual function to be the deviation between x and our target value.

The Gauss-Newton algorithm will minimise this residual in the least squares sense. To do so we will also need to evaluate the Jacobian of our residual with respect to our current value of the variable x. This gives information on which direction to iterate x into.

I illustrate this algorithm in a minimal example below, using the sympy library in Python.

Since the trivial problem I've set is linear, the algorithm converges to the optimal in just one step.

--

--

Frank Lanke Fu Tarimo

PhD Candidate in Perception for Robotics. University of Oxford