API Reference

API Reference#

diffaaable.aaa(Z, F, tol=1e-13, mmax=100, return_errors=False)[source]#

This is a wrapped version of aaa as provided by baryrat, providing a custom jvp to enable differentiability.

For detailed information on the usage of aaa please refer to the original documentation:

Compute a rational approximation of `F` over the points `Z` using the
AAA algorithm.

Arguments:
    Z (array): the sampling points of the function. Unlike for interpolation
        algorithms, where a small number of nodes is preferred, since the
        AAA algorithm chooses its support points adaptively, it is better
        to provide a finer mesh over the support.
    F: the function to be approximated; can be given as a function or as an
        array of function values over ``Z``.
    tol: the approximation tolerance
    mmax: the maximum number of iterations/degree of the resulting approximant
    return_errors: if `True`, also return the history of the errors over
        all iterations

Returns:
    BarycentricRational: an object which can be called to evaluate the
    rational function, and can be queried for the poles, residues, and
    zeros of the function.

For more information, see the paper

  | The AAA Algorithm for Rational Approximation
  | Yuji Nakatsukasa, Olivier Sete, and Lloyd N. Trefethen
  | SIAM Journal on Scientific Computing 2018 40:3, A1494-A1522
  | https://doi.org/10.1137/16M1106122

as well as the Chebfun package <http://www.chebfun.org>. This code is an
almost direct port of the Chebfun implementation of aaa to Python.

Attention

Returns nodes, values, weights and poles, in contrast to the baryrat implementation that returns the BarycentricRational ready to be evaluated. This is done to facilitate differentiability.

Parameters:
  • z_k (array (M,)) – the sampling points of the function. Unlike for interpolation algorithms, where a small number of nodes is preferred, since the AAA algorithm chooses its support points adaptively, it is better to provide a finer mesh over the support.

  • f_k (array (M,)) – the function to be approximated; can be given as a callable function or as an array of function values over z_k.

  • tol (float) – the approximation tolerance

  • mmax (int) – the maximum number of iterations/degree of the resulting approximant

Returns:

  • z_j (array (m,)) – nodes of the barycentric approximant

  • f_j (array (m,)) – values of the barycentric approximant

  • w_j (array (m,)) – weights of the barycentric approximant

  • z_n (array (m-1,)) – poles of the barycentric approximant (for convenience)

diffaaable - JAX-differentiable AAA algorithm

diffaaable.lorentz_aaa(z_k, f_k, tol=1e-09, mmax=100, return_errors=False)[source]#
diffaaable.vectorial_aaa(z_k, f_k, tol=1e-13, mmax=100, return_errors=False)[source]#

Find a rational approximation to \(\mathbf f(z)\) over the points \(z_k\) using a modified AAA algorithm, as presented in [^4]. Importantly the weights and thus also the poles are shared between all entries of \(\mathbf f(z)\).

Parameters:
  • z_k (array (M,):) – M sample points

  • f_k (array (M, V):) – vector valued function values

  • tol (float) – the approximation tolerance

  • mmax (int) – the maximum number of iterations/degree of the resulting approximant

Returns: