function area_average = disk_triangle_picking ( n )

%*****************************************************************************80
%
%% disk_triangle_picking(): estimate area of random triangle in unit disk.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    21 March 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n: the number of trials.
%
%  Output:
%
%    real area_average: the average area of a random triangle in the circle.
%
  area_average = 0.0;

  for test = 1 : n

    theta = 2.0 * pi * rand ( 3 );
    r = sqrt ( rand ( 3 ) );
    x1 = r(1) * cos ( theta(1) );
    y1 = r(1) * sin ( theta(1) );
    x2 = r(2) * cos ( theta(2) );
    y2 = r(2) * sin ( theta(2) );
    x3 = r(3) * cos ( theta(3) );
    y3 = r(3) * sin ( theta(3) );
    s1 = norm ( [ x1 - x2, y1 - y2 ] );
    s2 = norm ( [ x2 - x3, y2 - y3 ] );
    s3 = norm ( [ x3 - x1, y3 - y1 ] );
    s = 0.5 * ( s1 + s2 + s3 );
    area = sqrt ( s * ( s - s1 ) * ( s - s2 ) * ( s - s3 ) );
    area_average = area_average + area;

  end

  area_average = area_average / n;

  return
end

