% hw022.m
% John Burkardt
% The arithmetic-geometric mean.
%
x = input ( '  Enter value of X: ' );
y = input ( '  Enter value of Y: ' );

for i = 1 : 10
  x0 = x;
  y0 = y;
  x = ( x0 + y0 ) / 2.0;
  y = sqrt ( x0 * y0 );
end

fprintf ( '  AGM approximations are %20.16g and %20.16g\n', x, y );

