Polynomial curve fit

508 Views Asked by At

Well I have a 2 (or 3) data points - and some extra limits - and a polynom needs to be fitted through those points (exactly).

The polynom needs to be of the smallest order, and not a least square, it needs to fit exactly.

$$(x_0, y_0) (x_1, y_1)$$ Where $x_0 < x_1, y_0 < y_1$;

Now a linear function is of course "best" however there are extra limits:

  1. It needs to go through the origin.
  2. The derivative at the origin needs to be 0
  3. The derivative between $[0, x_1]$ must always be larger than $0$.
  4. Second order derivative also needs to be larger than $0$ on the interval.

Using the first two parts is quite easy, it just adds 2 extra equations to the system, and means that the polynom needs to be of the third order.

However I am stuck on how to incorporate the latter expressions.

Some extra things I know: $$x_0, x_1, y_0, y_1 > 0$$ $$\frac{x_0}{y_0} \leq \frac{x_1 - x_0} {y_1 - y_0}$$

1

There are 1 best solutions below

3
On

We are looking for a polynomial $p(x)=\sum_{i=0}^{d} a_ix^i$ such that

$$p(0)=0$$ $$p'(0)=0$$ $$x\in(0,x_1]\implies p'(x)>0\text{ and }p''(x)>0$$

The two first constraints have the consequence that $a_0=a_1=0$

So if the polynomial is to be of second degree then there must be some constant $a_2$ such that

$$a_2x_0^{\,2}=y_0$$ $$a_2x_1^{\,2}=y_1$$

This is equivalent to saying that if

$$\frac{y_0}{x_0^{\,2}}=\frac{y_1}{x_1^{\,2}}$$ Then the smallest degree polynomial fitting the required options is

$$p(x)=\frac{y_0}{x_0^{\,2}}\cdot x^2=\frac{y_1}{x_1^{\,2}}\cdot x^2$$

Checking that this polynomial also fits the third constraint is quite easy.


However, if those two values are not equal then this can't be a second degree polynomial. Let's see what happens with third degree polynomials.

Now $p(x)=a_3x^3+a_2x^2$ this means we can set up a system of equations

$$ \begin{array}{} a_3x_0^3+a_2x_0^2=y_0\\ a_3x_1^3+a_2x_1^2=y_1\\ \end{array} $$

Do some manipulations on this system

$$ \begin{array}{} a_3=\frac{y_0-a_2x_0^2}{x_0^3}\\ \frac{x_1^3\left(y_0-a_2x_0^2\right)}{x_0^3}+a_2x_1^2=y_1\\ x_1^3\left(y_0-a_2x_0^2\right)+a_2x_1^2x_0^3=x_0^3y_1\\ a_2x_1^2x_0^3-x_1^3a_2x_0^2=x_0^3y_1-x_1^3y_0\\ a_2\left(x_1^2x_0^3-x_1^3x_0^2\right)=x_0^3y_1-x_1^3y_0\\ a_2=\frac{x_0^3y_1-x_1^3y_0}{x_1^2x_0^3-x_1^3x_0^2}\\ a_3=\frac{y_0}{x_0^3}-\frac{1}{x_0^3}\frac{x_0^3y_1-x_1^3y_0}{x_1^2x_0-x_1^3}\\ a_3=\frac{y_0}{x_0^3}-\frac{x_0^3y_1-x_1^3y_0}{x_1^2x_0^4-x_1^3x_0^3}\\ \end{array} $$

And therefore the final third degree polynomial becomes

$$p(x)=x^3\left(\frac{y_0}{x_0^3}-\frac{x_0^3y_1-x_1^3y_0}{x_1^2x_0^4-x_1^3x_0^3}\right)+x^2\left(\frac{x_0^3y_1-x_1^3y_0}{x_1^2x_0^3-x_1^3x_0^2}\right)$$

If you define $$\alpha=\frac{x_0^3y_1-x_1^3y_0}{x_1^2x_0^3-x_1^3x_0^2}$$

Then it can be written simpler as

$$p(x)=\left(\frac{y_0}{x_0^3}-\alpha\right)x^3+\alpha x^2$$


However with this solution does not always work with the constraint $$x\in(0,x_1]\implies p'(x)>0\text{ and }p''(x)>0$$ Proof: let $x_0=y_0=1$ and $x_1=y_1=2$ then

$$p(x)=-\frac12x^3+\frac32x^2$$ $$p''(x)=-3x+3$$

A requirement says that $p''(x)>0$ if $0<x<2$, however $p''\left(\frac43\right)=-1$

Since we proved earlier if there exists such a third degree polynomial it would in this case be $p(x)=-\frac12x^3+\frac32x^2$, we have now proved that it is not true that there always is a third degree polynomial satisfying all requirements.


For a fourth degree polynomial, we need to solve this

$$ \begin{array}{} a_4x_0^4+a_3x_0^3+a_2x_0^2=y_0\\ a_4x_1^4+a_3x_1^3+a_2x_1^2=y_1\\ \end{array} $$

At this point I will simply insert this into sagemath

var('x_0,y_0,x_1,y_1');assume(x_0>0);assume(x_1>x_0);assume(y_0>0);assume(y_1>y_0);var('a_2,a_3,a_4');
solve([a_4*x_0^4+a_3*x_0^3+a_2*x_0^2==y_0,a_4*x_1^4+a_3*x_1^3+a_2*x_1^2==y_1],[a_4,a_3,a_2])

$$ \begin{array}{} a_{4} = -\frac{c x_{0}^{2} x_{1}^{3} - {\left(c x_{1}^{2} - y_{1}\right)} x_{0}^{3} - x_{1}^{3} y_{0}}{x_{0}^{4} x_{1}^{3} - x_{0}^{3} x_{1}^{4}}\\ a_{3} = \frac{c x_{0}^{2} x_{1}^{4} - {\left(c x_{1}^{2} - y_{1}\right)} x_{0}^{4} - x_{1}^{4} y_{0}}{x_{0}^{4} x_{1}^{3} - x_{0}^{3} x_{1}^{4}}\\ a_{2} = c \end{array} $$

Where $c\in\mathbb R$ is an arbitrary constant.

Trying around with some values shows that this also fails the derivatives being larger than zero constraint for $x_0=y_0=1$ and $x_1=y_1=2$.

I'm beginning to suspect that there is no such polynomial, I will edit again when I have results on whether this is the case.