I need to write an algorithm that constructs a function of the form
$f(x) = \sum_i^n q_i x^i$ that exactly goes through the points $p_i = (a_i, b_i)$.
In general building such a function is not the problem since the Lagrange Interpolation can be used. However the form is not correct and it still needs to be rearranged. While it is possible to throw a equation simplifier on the Lagrange Interpolation form, this is no elegant solution :)
TLDR; How would one compute the $q_i$ (something othen then Lagrange would also work fine, it just needs to be in polynomal form)
The principle is to write a sum with coefficients the values $a_k = f(x_k)$ multiplied by rationals of products of linear factors such that $r_k(x_k)=1$ and zero on all other points.
$$P(x) =\sum_{k=1}^n f(x_k) \frac{\prod_{l=1}^n (x-x_l)}{\prod_{l=1}^n (x_k-x_l)}$$