The formulas were derived by reading the following academic article here
In the multipoint protocol, we had a polynomial of the form:
In our context,
Simplifying the problem:
We have
In what follows, we re-derive all of the necessary formulas that will allows us to divide by a linear polynomial that vanishes on the domain in lagrange basis, where the domain can be arbitrary.
We briefly restate the formula for a lagrange polynomial:
The i'th lagrange polynomial evaluated at
is 1 and 0 everywhere else on the domain
We introduce the polynomial
We also introduce the derivative of
You can derive this yourself by generalising the product rule: https://en.wikipedia.org/wiki/Product_rule#Product_of_more_than_two_factors
In general this derivative does not have a succinct/sparse form. We do however have a succinct form if the domain is the roots of unity!
Now note that
If we plug in
into all the terms with will vanish, this is why the sum disappears into a single product.
We can use
Looking at the original lagrange formula,
is the denominator and is the numerator.
The first barycentric form for a polynomial
Note that our original problem was that the polynomial:
Had a
First we rewrite
We then note that:
I just re-arranged the formula for the first form to equal
for
We can hence plug this into our previous equation:
Simplifying since we have a
Note that when the elements in the domain are roots of unity;
The nice simplification here is due to two reasons: roots of unity form a cyclic group, and we can succinctly represent the d'th roots of unity in a sparse equation
which is nice to derivate.
We have now re-defined
We now summarise and state that:
When dealing with the point which vanishes on zero, the above formula becomes:
Note:
For the case that the evaluation does not vanish on the domain, we can use the original formula.
For all
We note that the terms of the sum are zero, except for when
If we use the formulas as shown above,
Note that if we multiply
We can now substite in
Note that
With the roots of unity, we were able to use the fact that they formed a group.
Again note that:
The expensive division occurs here
How would I lookup and store these values in practice?
First we imagine that we have stored the values in an array as such:
We first note that we can easily get from
Example
We want to compute
In practice, we can use an if statement to check whether 255 or 0 is larger, and subtract accordingly.
With the roots of unity, we did not need this optimisation as
equaled which was trivial to fetch from the domain due to the roots of unity forming a domain.
For our case, we will need to store precomputed values, if we want to efficiently compute
The strategy is that, we precompute
How would I lookup and store these values in practice?
Similar to the previous optimisation, we store
Example
We want to compute
In general:
Gotcha: You may produce an off by one error, by not realising that the second optimisation skips ahead 255 points for negative values, while the third optimisation skips ahead 256. This is because the second optimisation omits the value
.
Suppose
Optimising: