A Question about a trigonometric identity



Maybe something like trig_sin_cos_contract will work for you:

 (%i54) e : (3^(3/2)*sin(z)-3*cos(z))/4;
 (%o54) (3^(3/2)*sin(z)-3*cos(z))/4

 (%i55) trig_sin_cos_contract(e);
 (%o55) (3*sin(z-%pi/6))/2

Let's check:

 (%i56) trigrat(trigexpand(%-e));
 (%o56) 0

Another test:

 (%i63) e : sin(x) - (7* cos(35*z^2 - 1) - sin(35*z^2-1));
 (%o63) sin(35*z^2-1)-7*cos(35*z^2-1)+sin(x)

 (%i64) trig_sin_cos_contract(e);
 (%o64) 5*sqrt(2)*sin(35*z^2-atan(7)-1)+sin(x)

 (%i65) trigrat(trigexpand(% - e));
 (%o65) 0

Untested code--use with caution:

load("opsubst");

trig_sin_cos_contract(e) := block([trig_args,a,b,r,phi],
  trig_args : union(setify(gatherargs(e,'cos)), setify(gatherargs
  (e,'sin))),
  for z in trig_args do (
    z : first(z),
    a : ratcoeff(e, sin(z)),
    b : ratcoeff(e, cos(z)),
    if a # 0 and b # 0 then (
      r : sqrt(a^2 + b^2),
      phi : atan2(b,a),
      e : ratsubst(r * sin(z + phi), a * sin(z) + b * cos(z),e))),
  e);


Barton

-----maxima-bounces at math.utexas.edu wrote: -----


>My?problem?of?course,?is?that?I?had?to?guess?that?the?expression?was?a
>simple
phase?shift,?had?I?not?guessed?this,?I?would?never?have?got?there...