My question is similar to the one found here. There is an answer which does seem to provide what I am looking for. However either I am missing something or such answer is not complete, and since that post is 7 years old I thought it'd be better not to revive it.
In short, the question is to create an interpolating polynomial $f(x)$ given e.g. $(x_1, y_1)$, $(x_2, y'_2=f'(x_2))$, $(x_3, y_3)$. According to the linked answer, a Lagrange-like method is to construct $n$ (here, $3$) polynomials $f_i$ (I assume the final answer would be the sum $f_1 + f_2 + ... $), with certain conditions. The one pertaining to $y'_2$ would be $f_2 = C_2(x-x_1)(x-x_3)$, where $C_2$ is chosen such that $f'(x_2) = 1$.
- Am I understanding something wrong so far?
- If $f(x)=A x^2+B x+C$, then $f'(x_2) = 1$ depends on $A$ and $B$, and so would the constant $C_2$ (thus $f_2$ would not be completely defined?).
I believe such a polynomial may not always exist (and/or be unique). As a working example, $x=\{-1,0,1\}$ and $y=\{-1,1=y'_2,1\}$ would produce the polynomial $p(x) = -4x^2+x+4$.
There is also mention of Birkhoff method. I looked that up but it sent me on a rabbit hole. If anyone knows about a good source on that topic (assuming that's the way to go), I would appreciate some information.
Thank you.
PS: Hermite interpolation cannot be used, since not all points $x_i$ have a function + derivative values. (see comment by @Schmuel)
EDIT. Method 1: See answer by @Schmuel, using a divided difference table.
Method 2 Directo solution solving a system of equations. Given $p(x) = Ax^2+Bx+C$, solve the three equations $p(-1)=1,p'(0)=1,p(1)=1$, which gives $B=!, C=-A$. Using generic values $x_1,x_2,x_3$,$y_1,y'_2,y_3$ is also possible; however, the denominator of the coefficients have the term $(x_1-2x_2+x_3)$ which for the given example is equal to zero, so a different set of values would be needed.
Method 3 Lagrangian polynomials, as suggested by @YvesDaoust in the comments. The solution is $p(x)=p_1(x)+p_2(x)+p_3(x)$, where:
- $p_1(x)=C_1(x-s_2)(x-x_3)$, with $p(x_1)=1$ and $C_2$ s.t. $p'_1(x_1) = 0$
- $p_3(x)=C_3(x-x_1)(x-s_2)$, with $p(x_3)=1$ and $C_2$ s.t. $p'_3(x_3) = 0$
- $p_2(x)=C_2(x-x_1)(x-x_3), p'_2(x_2)=1$
This is the method suggested in the linked post. There is a similar problem as in Method 2, since $p_2(x)=(x-x_1)(x-x_3)/(2x_2-x_1-x_3)$, and the denominator becomes zero for the given values.
I noticed your PS, but there is nothing wrong with using Hermite interpolation with an extra point $(x_2,y_2)$ for unknown $y_2$. If your polynomial has to be of minimum degree, choose $y_2$ so that the leading coefficient disappears.
EDIT: I think working on your example will make it clearer. I use the notation from Wikipedia:
$$\begin{array}{lllll} z_0 = -1 & f[z_0] = -1\\ &&f[z_1,z_0] = y_2+1\\ z_1 = 0 & f[z_1] = y_2&&f[z_2,z_1,z_0] = -y_2\\ &&\frac{f'(z_1)}{1} = 1&&f[z_4,\ldots,z_1] = 0\\ z_2 = 0 & f[z_1] = y_2&&f[z_3,z_2,z_1] = -y_2\\ &&f[z_3,z_2] = 1-y_2\\ z_3 = 1 & f[z_2] = 1\\ \end{array}$$
The Base is $$1,(x+1),(x+1)x,(x+1)x^2$$
and thus the polynomial $P$ is: $$\begin{array}{rcl} P(x) &=& (-1)\cdot 1 + (y_2+1)(x+1) + (-y_2)(x+1)x + 0\cdot(x+1)^2x\\ &=& -y_2x^2+x+y_2 \end{array}$$
You get the minimum degree for $y_2 = 0$, but $P$ satisfies the conditions for any $y_2$.