function [ d, e, f ] = r8_sincos_sum ( a, b )

%*****************************************************************************80
%
%% R8_SINCOS_SUM simplifies a*sin(cx)+b*cos(cx).
%
%  Discussion:
%
%    The expression
%      a * sin ( c * x ) + b * cos ( c * x )
%    can be rewritten as
%      d * sin ( c * x + e )
%    or
%      d * cos ( c * x + f ) 
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    18 January 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real A, B, the coefficients in the linear combination.
%
%    Output, real D, E, F, the new coefficient, and the shift for
%    sine or for cosine.
%
  d = sqrt ( a * a + b * b );
  e = atan2 ( b, a );
  f = atan2 ( b, a ) - pi / 2.0;
  if ( f < - pi )
    f = f + 2.0 * pi
  end

  return
end
  
