In my studies of the Remez algorithm, I learned about the barycentric Lagrange interpolation formula.
Archived at: https://www.jeremykun.com/shortform/2024-06-21-1107/
The context is finding a polynomial of degree at most
I wrote a 2014 article (https://www.jeremykun.com/2014/06/23/the-mathematics-of-secret-sharing/) deriving this more gently, and implementing it in Haskell for secret sharing. An even gentler, Python-based version was the "pracitcal application" of chapter 2 of PIM (https://pimbook.org/).
I put practical application in quotes because the classical formula is numerically unstable. I acutally didn't know this at the time I wrote PIM, but for the application of secret sharing it doesn't really matter because you do the math over a finite field and numerical accuracy is irrelevant.
But now that I'm in my polynomial approximation era, I actually do care about numerical precision and stability. And for that purpose, the barycentric formula is much better.
The main observation here is that the terms of the classical formula can be thought of as divisors of a single polynomial
ℓ(𝑥)=∏ᵢ₌₀ⁿ(𝑥−𝑥ᵢ)
Then each term is
This is more efficient, but you can also avoid computing
When you divide, the
This is the barycentric formula. It is numerically stable for well-chosen point sets
The other nice thing about this formula is that the weights are trivial to compute for certain point sets. For uniform spaced points on
I wrote some Python code to implement this here (https://github.com/j2kun/remez/blob/main/lagrange.py), along with one extra tweak to improve numerical stability, which boils down to multiplying the numerator and denominator of each term in the sum by 2 to avoid underflow. The test includes an interpolation of degree 100,000 that runs in about a second in vanilla Python.
Popularizing barycentric Lagrange interpolation seems to be something of a passion project for Lloyd N. Trefethen (https://en.wikipedia.org/wiki/Nick_Trefethen). Trefethen, head of the numerical analysis group at Oxford, is an author on basically every paper I can find on this topic, in addition to the applications of this to Remez-like algorithms. In this paper (https://people.maths.ox.ac.uk/trefethen/barycentric.pdf), section 10 gives a history, of the curious obscurity of this formula. Among other interesting facts, Trefethen states that Richard Hamming included it in the first edition of Numerical Methods for Scientists and Engineers, and then dropped it in the second edition with no explanation.
@j2kun I assume you've read his ATAP book? It's excellent. Oh, and another of his popularization efforts: https://people.maths.ox.ac.uk/trefethen/sirev56-3_385.pdf
@pervognsen I have not! Thanks
@j2kun Oh wow, I can almost guarantee you'll love it based on your interests.
Nick was not 'head' of the numerical analysis group at Oxford. Rather, he was a member of the group.
Nick moved to Harvard starting in the fall 2023 academic year after retiring from Oxford (given UK rules on retirement).
@masonporter my bad!
@masonporter I pulled that word from Wikipedia, heh, should probably be updated
@j2kun Well, Wikipedia has its quality issues, of course.
In the case of these specific facts about Nick, I can readily just use my personal knowledge.
At least it didn't list a totally wrong institution. (A couple of times, I scrubbed my Wikipedia page to remove errors of commission that listed me with totally incorrect institutions. That is the only type of situation in which I am willing to edit my own page.)