function y = erfbyed(x)
% ERFBYED  Compute approximation to
%
%                2      /x
%   erf(x) = ---------  | exp(-t^2) dt
%             sqrt{pi}  /0
%
% using the antiderivative of the degree 8 polynomial P(t) found by
% equally-spaced polynomial interpolation of f(t) = exp(-t^2)
% on the interval [0.0,0.8].  Therefore this should only be used for
% inputs  0 <= x <= 0.8.
%
% Example.  Compare to the built-in "erf"; relative error:
%   >> erfbyed(0.8)
%   >> abs( erfbyed(0.8) - erf(0.8) )

P = erfintegrand(0:0.1:0.8);        % coefficients of  P(t)
Q = [0 P./(1:9)];                   % coefficients of  Q(t) = \int P(t) dt
y = (2 / sqrt(pi)) * fasteval(Q,x);
