  We analyze the Lanczos method for matrix function approximation (Lanczos-FA),
an iterative algorithm for computing $f(\mathbf{A}) \mathbf{b}$ when
$\mathbf{A}$ is a Hermitian matrix and $\mathbf{b}$ is a given vector. Assuming
that $f : \mathbb{C} \rightarrow \mathbb{C}$ is piecewise analytic, we give a
framework, based on the Cauchy integral formula, which can be used to derive a
priori and a posteriori error bounds for Lanczos-FA in terms of the error of
Lanczos used to solve linear systems. Unlike many error bounds for Lanczos-FA,
these bounds account for fine-grained properties of the spectrum of
$\mathbf{A}$, such as clustered or isolated eigenvalues. Our results are
derived assuming exact arithmetic, but we show that they are easily extended to
finite precision computations using existing theory about the Lanczos algorithm
in finite precision. We also provide generalized bounds for the Lanczos method
used to approximate quadratic forms $\mathbf{b}^\textsf{H} f(\mathbf{A})
\mathbf{b}$, and demonstrate the effectiveness of our bounds with numerical
experiments.
