I recently saw this problem (and I should have paid more attention to my middle school maths classes).
Find a 3 degree polynomial of $x$ which is $0$ when $x=1$ and $x=-2$, $4$ on $x = -1$ and $28$ when $x = 2$. Thank you. Just need a guideline.
I recently saw this problem (and I should have paid more attention to my middle school maths classes).
Find a 3 degree polynomial of $x$ which is $0$ when $x=1$ and $x=-2$, $4$ on $x = -1$ and $28$ when $x = 2$. Thank you. Just need a guideline.
On
A polynomial of degree $3$ can be written as: $$p(x)=a(x-x_1)(x-x_2)(x-x_3)$$ where $x_1, x_2, x_3$ are the three zeros of the polynomial, $a$ a real number.
Since your polynomial is $0$ when $x=1$ and $x=-2$, you shall write: $$p(x)=a(x-1)(x+2)(x-x_3)$$ Now you should determine $a$ and $x_3$, if there is any. You plug into your polynomial: $$4=a(-1-1)(-1+2)(-1-x_3)$$ $$28=a(2-1)(2+2)(2-x_3)$$ and you should find $a$ and $x_3$, solving this system of two equations.
Use the Lagrangian interpolation formula.
It is based on the simple idea that the product $p_0(x):=(x-x_1)\cdots(x-x_n)$ [where there is no factor $(x-x_0)$] is zero for all $x_k$ except $x_0$.
Then if you normalize by dividing by $p_0(x_0)$, you have a polynomial which is $1$ at $x_0$ and $0$ at all other $x_i$, and you can write (generalizing $p_0(x)$)
$$p(x)=\sum_{k=0}^n y_k\frac{p_k(x)}{p_k(x_k)},$$ which equals $y_k$ at $x_k$.
In the given case, two of the $y_k$ are zero, which simplifies the computation. Your polynomial is
$$4\frac{(x-1)(x+2)(x-2)}{(-2)1(-3)}+28\frac{(x-1)(x+2)(x+1)}{1\cdot4\cdot3}=(x-1)(x+2)(3x+1)\\=3x^3+4x^2-5x-2.$$