function [ estimate ] = ahs( E )
%AHS Estimate the value of the alternating harmonic series to an error of
% at most E. Do this by adding terms to a running sum until the maximum
% possible error, as measured by the next term in the series, is less than E.

estimate = 0;
i = 0;
while 3/(i+1) >= E
    i = i + 1;
    estimate = estimate + (-1)^(i+1) * 3 / i;
end

end

