Linear regression with quadratic equations

Oscar Nieves
4 min readApr 7, 2021

Linear regression is the technique by which we mathematically find a “line of best fit” (which is not necessarily a straight line) for a particular set of data. This technique is widely used in science, engineering, business, research, and more; in order to find relationships between different variables and make predictions about their future behaviour. In my previous article “Linear regression with straight lines”, we looked at the mathematics of fitting a straight line to a data set. The limitations of doing this are clear: not every relationship between a set of variables is linear (in fact, most relationships aren’t). For this reason, we will now extend our analysis to quadratic equations (e.g. parabolas).

Mathematical derivation of the optimum parameters

We now extend our analysis to perform a parabolic fit using

In this case, there are 3 parameters we must solve for, so as we might expect this will require us to solve a 3x3 matrix equation. First, we write the sum-squared error function as

To create 3 equations, we will take 3 partial derivatives, one with respect to each parameter b0, b1 and b2

and equating all of them to zero in order to find the turning points yields

--

--

Oscar Nieves
Oscar Nieves

Written by Oscar Nieves

I write stories about applied math, physics and engineering.