function s = square_any ( )

%*****************************************************************************80
%
%% square_any: expected length of line between random points in unit square.
%
%  Discussion:
%
%    The correct expected value is 0.5214...
%
%  Modified:
%
%    08 May 2019
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Will You Be Alive 10 Years From Now?,
%    Princeton, 2014,
%    ISBN: 978-0691156804,
%    LC: QA273.25.N344
%
%  Parameters:
%
%    Output, real s, an estimate for the expected length.
%    
  trial_num = 1000000;

  total = 0;
  for trials = 1 : trial_num
    x1 = rand ( );
    y1 = rand ( );
    x2 = rand ( );
    y2 = rand ( );
    r = sqrt ( ( x1 - x2 )^2 + ( y1 - y2 )^2 );
    total = total + r;
  end

  s = total / trial_num;

  return
end
