1
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ If you want a formula that is a linear combination of polynomials with coefficients $y_m$ or $y'_n$, you need to construct a base of polynomials such that both their values and derivatives vanish at the $x_m$ and $x_n$, except for the conditions $p(x_m)=1$ and $p'(x_n)=1$. Start by looking at $L^2(x)$ where $L(x)$ is a Lagrangian basis polynomial. $\endgroup$
    – user65203
    Jun 3, 2021 at 16:45
  • $\begingroup$ @YvesDaoust I was aware of Lagrangian base polynomial. The conditions of $p(x_m)=1$ were clear for me, but those of the derivatives were not. I finally realized what my mistake in my reasoning was respect to the old post. Thank you for your hint. Question: is there a way to do what I wanted without a linear combination of polynomials? $\endgroup$ Jun 3, 2021 at 18:54
  • $\begingroup$ No, a polynomial is a linear combination of polynomials. $\endgroup$
    – user65203
    Jun 3, 2021 at 18:57
  • $\begingroup$ Well, of course. I meant 'is there a different way of obtaining a polynomial $p(x) = A x^2 + Bx + C$, i.e. the coefficients $A, B, C$ directly, without having $p(x) = p_1(x) + p_2(x) + p_3(x)$ with each $p_i(x)$ satisfying certain conditions? There is always the solution of a system $\{p(x_1) = y_1, p'(x_2) = y'_2, p(x_3) = y_3\}$, though this way things get ugly quickly with $>3$ points. $\endgroup$ Jun 3, 2021 at 21:52
  • $\begingroup$ Same answer: no. $\endgroup$
    – user65203
    Jun 4, 2021 at 6:20

1 Answer 1

1
$\begingroup$

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$.

$\endgroup$
6
  • $\begingroup$ I thought Hermite interpolation requires having values and $n-th$ derivative for all points? I may not have $y_2$, but it cannot be chosen freely (data comes from some previous calculation). Minimal degree may not be necessary, it could be $n$ or $n+1$, with $n$ points. Does that change anything? $\endgroup$ Jun 3, 2021 at 17:13
  • 1
    $\begingroup$ I have to admit, the Wikipedia article makes it look that way. You can have any amount of derivatives for any point as long as the lower derivatives (for that point) are known. The calculation then proceeds as shown in the divided difference table. $\endgroup$
    – Schmuel
    Jun 3, 2021 at 21:29
  • 1
    $\begingroup$ You should not be afraid of choosing $y_2$ freely, or at least by some criteria. The decision to make the polynomial of degree n fixes y2 just as freely (it can be very off if I understand you correctly) as you do by some other criteria. $\endgroup$
    – Schmuel
    Jun 3, 2021 at 21:36
  • $\begingroup$ I think I read about needing derivatives for all points somewhere here in stackexchange. In any case, my first attempt with divided difference table failed. I'll give it another try. When each point has a derivative, things are much easier; getting the Hermite base is a matter of inverting a matrix, and the basis look much simpler and easier to operate with. The drawback is that it fixes the polynomial degree to odd numbers (3, 5, 7...), I think (not a big deal). $\endgroup$ Jun 3, 2021 at 21:50
  • 1
    $\begingroup$ If you have trouble with Hermite interpolation, you can also use Lagrange interpolation, as you suggested. Apply it to $(x_1,y_1), (x_2,y_2), (x_3,y_3)$ and choose $y_2$ at the end so that $y_2'$ matches the given. This is equivalent to the minimum degree Hermite interpolation I suggested. $\endgroup$
    – Schmuel
    Jun 3, 2021 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.