I have four coordinates: $(0,135), (1,156), (2,115)$ and $(3,0)$
I got $-6x^3-x^2+28x+135$, but that doesn't make sense, according to a graphing utility.
I have four coordinates: $(0,135), (1,156), (2,115)$ and $(3,0)$
I got $-6x^3-x^2+28x+135$, but that doesn't make sense, according to a graphing utility.
On
Indeed, your answer is wrong, since it maps $3$ into $48$ instead of $0$.
The correct answer is $-2x^3-25x^2+48x+135$.
Note that your polynomial must be a multiple of $x-3$ and its constant term must be $135$. Therefore, it must be of the form $(x-3)(ax^2+bx-45)$. Now, plugging in $x=1$ and $x=2$, it is not hard to determine $a$ and $b$.
On
You can use Lagrange's polynomial
$$L(x) = {y_1}\cdot{x - x_2 \over x_1 - x_2}\cdot{x - x_3 \over x_1 - x_3}\cdot{x - x_4 \over x_1 - x_4} + {y_2}\cdot{x - x_1 \over x_2 - x_1}\cdot{x - x_3 \over x_2 - x_3}\cdot{x - x_4 \over x_2 - x_4}+ {y_3}\cdot{x - x_1 \over x_3 - x_1}\cdot{x - x_2 \over x_3 - x_2}\cdot{x - x_4 \over x_3 - x_4}+{y_4}\cdot{x - x_1 \over x_4 - x_1}\cdot{x - x_2 \over x_4 - x_2}\cdot{x - x_3 \over x_4 - x_3}$$
See some example of application here.
If you plug the coordinates of each of the given points into the generic cubic equation $Ax^2+Bx^2+Cx+D=y$, you will end up with a system of linear equations in the coefficients of this cubic. I presume that you know how to solve such a system of equations.
However, you can instead generate the cubic equation directly from these linear equations without solving the system first. The augmented matrix of the above system of linear equations is $$\begin{bmatrix}x_1^3&x_1^2&x_1&1&y_1 \\ x_2^3&x_2^2&x_2&1&y_2 \\ x_3^3&x_3^2&x_3&1&y_3 \\ x_4^3&x_4^2&x_4&1&y_4 \end{bmatrix}.$$ (The column of $1$s corresponds to the constant term $D$.) If you plug any other point $(x,y)$ that lies on the curve into the generic cubic equation, the resulting vector of coefficients $\small{\begin{bmatrix}x^3&x^2&x&1&y\end{bmatrix}}$ of the resulting linear equation must lie in the row space of the above matrix. This condition can be stated as $$\det\begin{bmatrix}x^3&x^2&x&1&y \\ x_1^3&x_1^2&x_1&1&y_1 \\ x_2^3&x_2^2&x_2&1&y_2 \\ x_3^3&x_3^2&x_3&1&y_3 \\ x_4^3&x_4^2&x_4&1&y_4 \end{bmatrix} = 0.$$ This and similar determinants are usually written with the column of $1$s last. If you expand this equation and solve for $y$, you’ll find that this is precisely the Lagrange polynomial in gimusi’s answer.