function s = square_adjacent ( )

%*****************************************************************************80
%
%% square_adjacent(): expected distance between random points on adjacent square sides.
%
%  Discussion:
%
%    We may take the two sides as unit intervals on the x and y axis,
%    both starting at the origin.
%
%    The correct expected value is 0.7652.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  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
%
%  Output:
%
%    real s, an estimate for the expected length.
%    
  trial_num = 100000;

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

  s = total / trial_num;

  return
end
