We have $2$ lists of $N$ real numbers $xl$ and $yl$ for which $f(xl[i])=yl[i]$ is true. The idea of curve fitting is to find a function which fulfills these restrictions. I know there are well defined procedures to do that but this is about my own attempt
My intuition was that the problem could be expressed as a function $q(x)$ which is the sum of $N$ products. When $p$ is applied to and $x=xl[u]$ it should by definition return $yl[u]$. In my scheme all products should be 0 except the $u$th which is $yl[u]$. I think i can archive that property by the following product:
$$1) \Pi^n_{k=1}(xl[l]-x)/(xl[u]-x) $$ This formula should yield $0$ for all values of $xl[n]$ except where $n=u$ under $x=xl[u]$ in which case the result should be $$2) \Pi^{u-1}_{k=1}(xl[l]-x) + \Pi^n_{k=u+1}(xl[l]-x)$$ However i do want that expression to yield $yl[u]$ which $3)$ does $$3) \frac{yl[u]*\Pi^n_{k=1}(xl[l]-x)/(xl[u]-x) }{\Pi^{u-1}_{k=1}(xl[l]-x) + \Pi^n_{k=u+1}(xl[l]-x)}$$ If i construct a sum of $N$ of terms as in $3)$ where $u$ has a value between $1$ and $N$ i should get an universal construction which produces (after simplyfication) a polynomial of ($N$-1)th degree for which every point P(xl[t],yl[t]) is on $q(x)$ and where $q(x)$ is an approximation of $f(x)$. However the following $4)$ constructed as a sum of $3)$ does evaluate as as i expect it to. $$4) q(x) = \sum^N_{i=1}(\frac{yl[i]*\Pi^n_{k=1}(xl[l]-x)/(xl[u]-x) }{\Pi^{u-1}_{k=1}(xl[l]-x) + \Pi^n_{k=u+1}(xl[l]-x)})$$
3) should be identical in function to $l_j(x)$ Questions:
- Does that work? (It does not when i do it. for $yl={98,6}$, $N=2$ and $xl={98,6} where it does not yield q(x)=x but q(x)=\frac{26*(x-98)*(x-6)}{147})
- What am i doing wrong?
- Is there a curve fitting scheme based on a similar approach? - The similar approach is Lagrange Polynomial