So, I've got this polynomial: $$\prod_{i=1}^{n}\frac{x-b_i}{k_i}, k_i,b_i\in\mathbb{N}$$ I need to calculate its definite integral on some segment $[a;b], a\geq 0$ and it's guaranteed that every linear function takes values from $[0;1]$ on that segment.
Right now I'm just expanding the product and calculating the antiderivative as usual, but it gives me enormous precision errors when I try to calculate the antiderivative at $a$ and $b$.
It happens because the result should be a positive number not exceeding $1$, but all terms $a_ix^i$ of the expanded polynomial are huge numbers with strictly alternating signs (because of $b_i$ being positive).
Obviously, adding them up is a bad idea. Is there some cool math trick to overcome this?
Try doing the following
\begin{equation} \prod_{i=1}^{n}\frac{x-b_i}{k_i} = e^{\log\left(\prod_{i=1}^{n} \frac{x-b_i}{k_i} \right)} = e^{\sum_{i=1}^{n} \log\left(\frac{x-b_i}{k_i} \right)}. \end{equation}
Since every linear functional is between $[0,1]$ the logarithm is well defined. Depending on what program/library you're using, the numerical integration for special functions might be able to deal with the numerical precision errors you are having.