0
$\begingroup$

I have following polynomial

1/16 + (3 Cos[β]^2)/16 - (3 Cos[γ]^2)/16 + 
 3/16 Cos[β]^2 Cos[γ]^2 - (3 Cos[χ])/16 - 
 9/16 Cos[β]^2 Cos[χ] - 3/16 Cos[γ]^2 Cos[χ] + 
 3/16 Cos[β]^2 Cos[γ]^2 Cos[χ] - (
 3 Sin[β]^2)/16 - 3/16 Cos[γ]^2 Sin[β]^2 + 
 9/16 Cos[χ] Sin[β]^2 - 
 3/16 Cos[γ]^2 Cos[χ] Sin[β]^2 + (
 3 Sin[γ]^2)/16 - 3/16 Cos[β]^2 Sin[γ]^2 + 
 3/16 Cos[χ] Sin[γ]^2 - 
 3/16 Cos[β]^2 Cos[χ] Sin[γ]^2 + 
 3/16 Sin[β]^2 Sin[γ]^2 + 
 3/16 Cos[χ] Sin[β]^2 Sin[γ]^2

and I want to simplify it with pattern matching i.e. each time (during simplify) following pattern

1/2 (-1 + 3 Cos[β]^2)

is found, it is onward substituted with expression "A".

$\endgroup$
2
$\begingroup$

Solve for Cos[β] to get it in terms of A, and then substitute Cos[β]

cosB = Solve[A == (1/2 (-1 + 3 Cos[β]^2)), Cos[β]][[1]];
expr /. {Sin[β] -> Sqrt[1 - Cos[β]^2]} /. cosB // Simplify
(*1/4 (A + 2 (-1 + A) Cos[2 γ] Cos[χ/2]^2 - 3 A Cos[χ])*)
$\endgroup$
  • 1
    $\begingroup$ You get a slightly simpler form with FullSimplify rather than Simplify $\endgroup$ – Bob Hanlon Apr 6 '17 at 1:07
1
$\begingroup$
poly = 1/16 + (3 Cos[β]^2)/16 - (3 Cos[γ]^2)/16 + 
   3/16 Cos[β]^2 Cos[γ]^2 - (3 Cos[χ])/16 - 
   9/16 Cos[β]^2 Cos[χ] - 
   3/16 Cos[γ]^2 Cos[χ] + 
   3/16 Cos[β]^2 Cos[γ]^2 Cos[χ] - (3 \
Sin[β]^2)/16 - 3/16 Cos[γ]^2 Sin[β]^2 + 
   9/16 Cos[χ] Sin[β]^2 - 
   3/16 Cos[γ]^2 Cos[χ] Sin[β]^2 + (3 \
Sin[γ]^2)/16 - 3/16 Cos[β]^2 Sin[γ]^2 + 
   3/16 Cos[χ] Sin[γ]^2 - 
   3/16 Cos[β]^2 Cos[χ] Sin[γ]^2 + 
   3/16 Sin[β]^2 Sin[γ]^2 + 
   3/16 Cos[χ] Sin[β]^2 Sin[γ]^2;

Using straightforward simplification

poly2 = poly // FullSimplify

(*  1/32 (2 + 3 Cos[2 (β - γ)] + 
   3 Cos[2 (β + γ)] + 
   Cos[2 β] (6 - 18 Cos[χ]) - 6 Cos[χ] - 
   6 Cos[2 γ] (1 + 2 Cos[χ] Sin[β]^2))  *)

Using variable substitution

poly3 = poly /. 
   Assuming[{-1/2 < A <= 1, C[1] == 0}, 
    Solve[A == 1/2 (-1 + 3 Cos[β]^2), β][[1]] // 
     Simplify] // FullSimplify

(*  1/4 (A - 3 A Cos[χ] + (-1 + A) Cos[2 γ] (1 + Cos[χ]))  *)

Verifying,

poly == poly2 == (poly3 /. 
    A -> 1/2 (-1 + 3 Cos[β]^2)) // Simplify

(*  True  *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.