% hw002.m
% John Burkardt
% Square has area 4.
% Circles 1, 2 and 3 have radius 1.05, 1.10, 1.15
% Which circle has area closest to square?
%
a = 4.0

a1 = pi * 1.05^2
a2 = pi * 1.10^2
a3 = pi * 1.15^2

e1 = abs ( a1 - a )
e2 = abs ( a2 - a )
e3 = abs ( a3 - a )

if ( e1 < e2 && e1 < e3 )
  fprintf ( '  Circle 1 is closest.\n' );
elseif ( e2 < e1 && e2 < e3 )
  fprintf ( '  Circle 2 is closest.\n' );
elseif ( e3 < e1 && e3 < e2 )
  fprintf ( '  Circle 3 is closest.\n' );
end

