  In this work, we present a novel error analysis for recovering a spatially
dependent diffusion coefficient in an elliptic or parabolic problem. It is
based on the standard regularized output least-squares formulation with an
$H^1(\Omega)$ seminorm penalty, and then discretized using the Galerkin finite
element method with conforming piecewise linear finite elements for both state
and coefficient, and backward Euler in time in the parabolic case. We derive
\textit{a priori} weighted $L^2(\Omega)$ estimates where the constants depend
only on the given problem data for both elliptic and parabolic cases. Further,
these estimates also allow deriving standard $L^2(\Omega)$ error estimates,
under a positivity condition that can be verified for certain problem data.
Numerical experiments are provided to complement the error analysis.
