A very long time ago, my math teacher told me that a quadratic could pass through any 3 points, a cubic any 4 points, etc. While this seemed intuitive to me, I could not think of a formula. About a year ago, I spent two hours deriving a general formula for the quadratic case, which I now see as a big waste of time, because it is more efficient to solve each specific case separately. Even more efficient is to use the power of linear algebra to do so.
A quadratic function has the form:
If we want it to pass through a point (x1,y1), that means that x1 will be the x-coordinate, and y1 will be the function output:
Because a quadratic can pass through three points, we can add two more equations to this system, corresponding to two more points:
This is a system of equations with three equations (1, 2, and 3) and three unknowns (a, b, and c). Therefore, the corresponding augmented matrix is:
The three main columns are for the variables a, b, and c. In reduced row echelon form, this matrix will reveal the coefficients for the quadratic that will pass through (x1,y1), (x2,y2), and (x3,y3).
For cubic equations, we can construct a similar matrix, with an extra column for the 4th variable and an extra row for a 4th equation:
This can be generalized to a degree n polynomial, a (n+1)x(n+2) augmented matrix:
When set to reduced row echelon form, the entries in the augmented column will be the coefficients of the polynomial which passes through all n+1 points. For anyone not familiar with linear algebra, reduced row echelon form just gives the solution for each variable in the system of equations. If no such solution exists, one of the rows will state 0=1, which is impossible.
Quadratic Example

Let’s say that we want a parabola that passes through these three points. The corresponding matrix is:
Setting to reduced row echelon form yields this matrix:
This means that the quadratic that passes through these three points has the form:
Sure enough, if we graph this function, it intersects with all three points:

Cubic Example

Now, let’s find a cubic that passes through these four points. This is the matrix we have to reduce:
Reduced, we get this matrix:
The number 17 appeared a lot in this matrix a lot for some reason. Also -17/4 was the constant term in the quadratic matrix, but 17/4 also appears here for some reason. Just a strange coincidence I want to point out. Anyway, the cubic which passes through these points is:

The cubic perfectly passes through the four points.
What happens if there are two points with the same y-coordinate?

The red and green point are on the same vertical line, which seems like it would be impossible for a function to pass through them both. The matrix describing this system is:
Reduced, it is:
First of all, the first rows don’t actually solve for any coefficients, but they relate them in a weird way:
Second of all, the third row literally is 0=1, which is impossible. In linear algebra, this is called an inconsistent system.

Even if we try to parametrize the system in terms of c, the function still misses all three points. ☹️

Leave a Reply