I am looking for some open source implementation (any of Python, C, C++, Fortran is fine) of rational approximation to a function. Something along the article [1]. I give it a function and it gives me back two polynomials, whose ratio is the approximation on the given interval and the error is oscillating with the same amplitude and it is an optimal approximation, or close to it.
Here is what I found:
It looks like chebfun can do that, but I don't have access to Matlab *.
There is a simple program in the section 5-13 "Rational Chebyshev Approximation" in Numerical Recipes (NR).
Mathematica has EconomizedRationalApproximation and MiniMaxApproximation
I was wondering whether there is something newer (possibly better tested) than the NR code.
My application is that I have a set of special functions, about 10, which are given either as hypergeometric series, or some formula which has numerical cancellations, and I want to have a robust, fast and accurate evaluation function, that is being called in the inner most loop of calculating two particle matrix elements in Hartree Fock calculations. I put a simple example of a function that works for me at [2]. As you can see, it's either using a direct formula, or a series around x=0, that I calculated using SymPy. It sort of works, but the accuracy is not great, around x=1 about half of the significant digits are lost (but for x=0.1 as well as x=1e5 it is accurate to almost all significant digits). I am looking for a better approximation.
[1] Deun, J., & Trefethen, L. N. (2011). A robust implementation of the Carathéodory-Fejér method for rational approximation. BIT Numerical Mathematics, 51(4), 1039–1050. doi:10.1007/s10543-011-0331-7 (June 2010 e-print)
[2] https://gist.github.com/3831580
(*) Nor to the chebfun website, which gives me 404, but Pedro suggested that must be my provider issue.