function q = quad_parfor ( a, b, n, f )

%% quad_parfor.m

  q = 0.0;
  parfor i = 1 : n
    ai = ( ( n - i + 1 ) * a + ( i - 1 ) * b ) / n;
    bi = ( ( n - i     ) * a +   i       * b ) / n;
    xi = ( ai + bi ) / 2.0;
    q = q + f ( xi );
  end 
  q = q * ( b - a ) / n; 

  return
end
