# Finding the equation of a cubic when given $4$ points

I am asked to find the equation of a cubic function that passes through the origin. It also passes through the points $(1, 3), (2, 6),$ and $(-1, 10)$.

I have walked through many answers for similar questions that suggest to use a substitution method by subbing in all the points and writing in terms of variables. I have tried that but I don't really know where to take it from there or what variables to write it as.

If anyone could provide their working out for this problem it would be extremely enlightening.

Given four points $(x_i,y_i)$ consider the functions $$f_1(x)=\frac {(x-x_2)(x-x_3)(x-x_4)}{(x_1-x_2)(x_1-x_3)(x_1-x_4)}$$ so that $f_1(x_1)=1$ and $f_1(x_i)=0, i\neq 1$, and similarly $f_2, f_3, f_4$. Note that the $f_i$ are cubic in $x$.

Then $p(x)=y_1f_1(x)+y_2f_2(x)+y_3f_3(x)+y_4f_4(x)$ is at most a cubic polynomial and passes through the four given points.

• See Lagrange Interpolation/Polynomials en.wikipedia.org/wiki/Lagrange_polynomial Note also that this is not the only place where a system with $f_i(x_j)=1(i=j) =0 (i\neq j)$ is useful. See for example (versions of) the Chinese Remainder Theorem. Feb 18, 2018 at 15:01

the general cubic equation is $$y=ax^3+bx^2+cx+d.$$Plug in the coordinates of the points for x and y, and you end up with a system of four equations in four variables, namely $a, b, c$ and $d$. Hope that helps!

• I have done as you said and I have ended up with an equation for a=, b=, c=, and d=0(given). Where should I go next? The there are two variables on the RHS of these equations and I don't know how to proceed further. Feb 18, 2018 at 7:13
• Use row operations to isolate the variables. For example, get an expression for a by isolating it and substitute it into another, until you get equations in one variable.(Or, if you know how, set up a matrix and row-reduce it.) Feb 18, 2018 at 7:17
• I've finally done it! Thank you very much Ranjeev Feb 18, 2018 at 7:55

Guide:

Let the equation be $y=ax^3+bx^2+cx+d$, since it passes through $(1,3)$, we have

$$a(1)^3+b(1)^2+c(1)+d=3$$

Do the same thing for the other $3$ points.

Hence you will obtain $4$ linear equation with $4$ variables.

You can then solve it using elementary row operations to recover $a,b,c,d$.

• Unfortunately, I have not learn elementary row operations yet. However I have obtained 4 linear equations with 4 variables. Is there a way to find the cubic equation without elementary row operations? Feb 18, 2018 at 7:16
• what about substitution? Feb 18, 2018 at 7:16

An equation of the cubic that passes through the four points $(x_1,y_1)$, $(x_2,y_2)$, $(x_3,y_3)$ and $(x_4,y_4)$ is $$\begin{vmatrix} x^3 & x^2 & x & y & 1 \\ x_1^3 & x_1^2 & x_1 & y_1 & 1 \\ x_2^3 & x_2^2 & x_2 & y_2 & 1 \\ x_3^3 & x_3^2 & x_3 & y_3 & 1 \\ x_4^3 & x_4^2 & x_4 & y_4 & 1 \end{vmatrix} = 0.$$ Plug in the coordinates of your points and simplify.

This problem is a special case in which all known values differ by fixed $$\Delta x$$ (here $$\Delta x = 1$$). This is a very common problem when you have discrete equispaced values and you want to interpolate to find the "exact" maximum or minimum value, between the endpoints. (You then assume that a cubic polynomial passes through these points, find the polynomial and then its extremum). It is also known as "cubic interpolation".

In this case, the cubic polynomial is $$f(x) = a_0 + a_1\epsilon(x) + a_2\epsilon^2(x) + a_3\epsilon^3(x)$$ where $$\epsilon = \frac{x-n\Delta x}{\Delta x},\quad n=-1,0,1,2$$. $$\epsilon$$ is actually shifting and scaling the polynomial, so that the known points are at $$-1, 0, 1, 3$$. In your case, $$\Delta x=1$$ and you can take $$n=0$$, therefore $$f(x) = a_0 + a_1 x + a_2x^2 + a_3x^3$$ and \begin{align} a_0 & = f(0),\\ a_1 & = \frac{-2f(-1) - 3f(0) + 6f(1)-f(2)}{6},\\ a_2 & = \frac{f(-1) -2f(0) + f(1)}{2},\\ a_3 & = \frac{-f(-1) + 3f(0) - 3f(1) + f(2)}{6}.\\ \end{align}

Note that in the case where the know points are not $$-1, 0, 1, 2$$, the formulas for $$a_0,\ldots a_2$$ are the similar, the only difference being that if the points are $$x_{-1}, x_0, x_1, x_2$$, then in the above equations, just use $$f(x_{-1})$$ instead of $$f(-1)$$, $$f(x_0)$$ instead of $$f(0)$$ and so on.

To determine a conic we need to solve 5 equations with 5 given points.

Likewise here we are given 4 points and 4 simultaneous equations, not involving any $xy$ term.. so solve it by Cramer's determinants.

Hint:

It is proper to use the Lagrange function as following$$f(x)=\sum_{cyc}\dfrac{(x-x_2)(x-x_3)(x-x_4)}{(x_1-x_2)(x_1-x_3)(x_1-x_4)}$$

You can also use the method of forward differences. For a quadratic sequence $$f(x) = ax^2 + bx + c$$, the first difference, the difference between consecutive terms $$f(x + 1) - f(x)$$ is $$a(2x + 1) + b$$. Now for this new sequence, the difference between these consecutive terms called the second difference is $$2a$$, so we can recover the $$x^2$$ term by dividing by the second difference by $$2$$. It is not too hard to see that we need to divide by $$3! = 6$$ for a cubic polynomial.

We can just do that here since we have $$x$$-values which are all consecutive. Our $$f(x) = 10, 0, 3, 6$$, and so the first differences are $$-10, 3, 3$$, our second differences are $$13, 0$$, and our third difference is $$-13$$. Like we saw for our quadratic, the third differences must be constant for a cubic. Hence the coefficient in $$x^3$$ is $$-13/3! = -\frac{13}{6}$$.

Here is the trick: we take away $$-\frac{13}{6} x^3$$ from the $$y$$-value for each $$x$$, and we end up with a quadratic. This gives our new quadratic sequence as $$\frac{47}{6}, 0, \frac{31}{6}, \frac{140}{6}$$. Our first differences of this new sequence are $$\frac{-47}{6}, \frac{31}{6}, \frac{109}{6}$$ and our second differences as $$\frac{78}{6}, \frac{78}{6}$$. We observe these are the same as a sanity check. Hence the coefficient in $$x^2$$ is $$\frac{13}{2}$$.

We repeat this again by taking away $$\frac{13}{2}x^2$$ for each $$x$$, which gives us the sequence $$\frac{4}{3}, 0, \frac{-4}{3}, -\frac{8}{3}$$, where the common difference is just $$-\frac{4}{3}$$. Also, $$p(0) = 0$$ so the constant term is $$0$$.

Bringing this all together, our cubic equation is hence: $$y = \boxed{-\frac{13}{6}x^3 + \frac{13}{2}x^2 - \frac{4}{3}x}.$$

I know you waited 5 years, and here is the answer you were seeking all this time: I have written a polynomial, that is actually just the determinant of a matrix involving just all the coordinates for the points. And best of all, it is live on Desmos, so you can slide the points around and enjoy the resulting function. Click on derivative and second derivate also. Note that I divided the y-axis to make the view better, but you can modify that.

https://www.desmos.com/calculator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c^{3}*j*x^{2}+a^{3}*c*j*x^{2}+a*f^{3}*j*x^{2}-c*f^{3}*j*x^{2}-a^{3}*f*j*x^{2}+c^{3}*f*j*x^{2}-b*c^{2}*f^{3}*x+a^{2}*d*f^{3}*x+b*c^{3}*f^{2}*x-a^{3}*d*f^{2}*x-a^{2}*c^{3}*g*x+a^{3}*c^{2}*g*x+b*c^{2}*h^{3}*x-a^{2}*d*h^{3}*x-b*f^{2}*h^{3}*x+d*f^{2}*h^{3}*x+a^{2}*g*h^{3}*x-c^{2}*g*h^{3}*x-b*c^{3}*h^{2}*x+a^{3}*d*h^{2}*x+b*f^{3}*h^{2}*x-d*f^{3}*h^{2}*x-a^{3}*g*h^{2}*x+c^{3}*g*h^{2}*x+a^{2}*c^{3}*j*x-a^{3}*c^{2}*j*x-a^{2}*f^{3}*j*x+c^{2}*f^{3}*j*x+a^{3}*f^{2}*j*x-c^{3}*f^{2}*j*x}{-\left(a*c^{2}*f^{3}-a^{2}*c*f^{3}-a*c^{3}*f^{2}+a^{3}*c*f^{2}+a^{2}*c^{3}*f-a^{3}*c^{2}*f-a*c^{2}*h^{3}+a^{2}*c*h^{3}+a*f^{2}*h^{3}-c*f^{2}*h^{3}-a^{2}*f*h^{3}+c^{2}*f*h^{3}+a*c^{3}*h^{2}-a^{3}*c*h^{2}-a*f^{3}*h^{2}+c*f^{3}*h^{2}+a^{3}*f*h^{2}-c^{3}*f*h^{2}-a^{2}*c^{3}*h+a^{3}*c^{2}*h+a^{2}*f^{3}*h-c^{2}*f^{3}*h-a^{3}*f^{2}*h+c^{3}*f^{2}*h\right)}$$

• I can see that you put effort into writing this up, but you've tackled a general form of the problem by appealing to a software program (Desmos) and presenting without proof a lengthy formula. Clearly you know of the passage of time involved, but a glance at previous Answers tells us the original poster was able to accept one of them and carry out the standard calculations already. May 8, 2023 at 11:10