  We describe a Lanczos-based algorithm for approximating the product of a
rational matrix function with a vector. This algorithm, which we call the
Lanczos method for optimal rational matrix function approximation (Lanczos-OR),
returns the optimal approximation from a given Krylov subspace in a norm
depending on the rational function's denominator, and can be computed using the
information from a slightly larger Krylov subspace. We also provide a
low-memory implementation which only requires storing a number of vectors
proportional to the denominator degree of the rational function. Finally, we
show that Lanczos-OR can be used to derive algorithms for computing other
matrix functions, including the matrix sign function and quadrature based
rational function approximations. In many cases, it improves on the
approximation quality of prior approaches, including the standard Lanczos
method, with little additional computational overhead.
