c-f-h / baryrat

A Python package for barycentric rational and polynomial interpolation and approximation.
BSD 2-Clause "Simplified" License
44 stars 7 forks source link

AAA: Incorrect solution for complex functions #1

Closed Guschti42 closed 3 years ago

Guschti42 commented 3 years ago

If I want to calculate the AAA with complex numbers it gets a wrong solution. I think this is due to the fact, that scipys SVD does calculate U,S,V^H whereas Matlab calculates U,S,V.
This should be solved by editing line https://github.com/c-f-h/baryrat/blob/3b45fa91a661e84681dd8bde052275fc10dc3c8e/baryrat.py#L212

to wj = Vh[-1, :].conj()

c-f-h commented 3 years ago

Thank you, I haven't tested complex functions at all, I will have a look at it.

c-f-h commented 3 years ago

@Guschti42 Thanks for the report, I fixed it, and also pushed a new version 1.2.1 to PyPI, so you can upgrade it with pip.

If you are interested in getting even better rational approximations, try the brasil function (see docs) which computes best rational approximations. It's based on this preprint (should appear in a journal soon). Let me know if complex functions give you trouble there too.