function value = c8_sqrt ( c )

%*****************************************************************************80
%
%% c8_sqrt() returns the principal square root of a C8.
%
%  Discussion:
%
%    A C8 is a complex double precision value.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 April 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    Input, complex C, the number whose square root is desired.
%
%  Output:
%
%    complex VALUE, the square root of X.
%
  argument = c8_arg ( c );
  magnitude = c8_mag ( c );

  if ( magnitude == 0.0 )

    value = 0.0;

  else

    value = sqrt ( magnitude ) ...
      * ( cos ( argument / 2.0 ) + i * sin ( argument / 2.0 ) );

  end

  return
end
