#### 96.2.4 Factor Sums of sin and cos Functions

Function: trigfactor (x)

  The function trigfactor factors expresions of form \(\pm \sin x \pm \cos y.\)

  Examples:

  1.     (%i2) trigfactor(sin(x)+cos(x));
                                                     %pi
         (%o2)                       sqrt(2) cos(x - ---)
                                                      4
         (%i3) trigrat(%);
         (%o3)                          sin(x) + cos(x)

  2.     (%i4) trigfactor(sin(x)+cos(y));
                                    y   x   %pi      y   x   %pi
         (%o4)                2 cos(- - - + ---) cos(- + - - ---)
                                    2   2    4       2   2    4

         (%i5) trigrat(%);
         (%o5)                          cos(y) + sin(x)

  3.     (%i6) trigfactor(sin(x)-cos(3*y));
                                  3 y   x   %pi      3 y   x   %pi
         (%o6)              2 sin(--- - - + ---) sin(--- + - - ---)
                                   2    2    4        2    2    4
         (%i7) trigrat(%);
         (%o7)                         sin(x) - cos(3 y)

  4.     (%i8) trigfactor(-sin(5*x)-cos(3*y));
                                 3 y   5 x   %pi      3 y   5 x   %pi
         (%o8)           - 2 cos(--- - --- + ---) cos(--- + --- - ---)
                                  2     2     4        2     2     4
         (%i9) trigrat(%);
         (%o9)                      (- cos(3 y)) - sin(5 x)

  5.     (%i10) sin(alpha)+sin(beta)=trigfactor(sin(alpha)+sin(beta));
                                                beta   alpha      beta   alpha
         (%o10)  sin(beta) + sin(alpha) = 2 cos(---- - -----) sin(---- + -----)
                                                 2       2         2       2

         (%i11) trigrat(%);
         (%o78)          sin(beta) + sin(alpha) = sin(beta) + sin(alpha)

  6.     (%i12) sin(alpha)-sin(beta)=trigfactor(sin(alpha)-sin(beta));
                                                 beta   alpha      beta   alpha
         (%o12) sin(alpha) - sin(beta) = - 2 sin(---- - -----) cos(---- + -----)
                                                  2       2         2       2

  7.     (%i13) cos(alpha)+cos(beta)=trigfactor(cos(alpha)+cos(beta));
                                                beta   alpha      beta   alpha
         (%o80)  cos(beta) + cos(alpha) = 2 cos(---- - -----) cos(---- + -----)
                                                 2       2         2       2

  8.     (%i14) cos(alpha)-cos(beta)=trigfactor(cos(alpha)-cos(beta));
                                                beta   alpha      beta   alpha
         (%o14)  cos(alpha) - cos(beta) = 2 sin(---- - -----) sin(---- + -----)
                                                 2       2         2       2

  9.     (%i15) trigfactor(3*sin(x)+7*cos(x));
         (%o15)                        3 sin(x) + 7 cos(x)

         (%i16) c2sin(%);
                                                          7
         (%o16)                     sqrt(58) sin(x + atan(-))
                                                          3

         (%i17) trigexpand(%),expand;
         (%o17)                        3 sin(x) + 7 cos(x)

     10.

         (%i18) trigfactor(sin(2*x));
         (%o18)                             sin(2 x)
         (%i19) trigexpand(%);
         (%o19)                          2 cos(x) sin(x)