0
$\begingroup$

Is there a way to impose in mathematica an specific trigonometric expansion with TrigExpand?

I have various double-angle expressions for cosine and sine in my problem and i need to rewrite them in terms of cosines and sines functions. With this code you can get the same expressions than me.

ClearAll["Global`*"]
SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Condensed"]
$PrePrint = # /. {Csc[z_] :> 1/Defer@Sin[z], 
     Sec[z_] :> 1/Defer@Cos[z], 
     Cot[z_] :> Defer@Cos[z]/Defer@Sin[z]} &;
Derivative /: 
 MakeBoxes[Derivative[α__][f1_][vars__], TraditionalForm] := 
 Module[{bb, dd, sp}, 
  MakeBoxes[dd, _] ^= 
   If[Length[{α}] == 1, "\[DifferentialD]", "∂"];
  MakeBoxes[sp, _] ^= "\[ThinSpace]";
  bb /: MakeBoxes[bb[x__], _] := RowBox[Map[ToBoxes[#] &, {x}]];
  TemplateBox[{ToBoxes[bb[dd^Plus[α], f1]], 
    ToBoxes[Apply[bb, 
      Riffle[Map[bb[dd, #] &, 
        Select[({vars}^{α}), (# =!= 1 &)]], sp]]], 
    ToBoxes[Derivative[α][f1][vars]]}, "ShortFraction", 
   DisplayFunction :> (FractionBox[#1, #2] &), 
   InterpretationFunction :> (#3 &), Tooltip -> Automatic]]

Subscript[w, 1] = 
  f[Subscript[r, 1], Subscript[r, 2], α, β, γ, 
   Subscript[Θ, 12]];
Set[J, -(D[Subscript[w, 1], {β, 2}] + 
      1/Sin[β]^2 (D[Subscript[w, 1], {α, 2}] + 
         D[Subscript[w, 1], {γ, 2}]) + 
      Cot[β] D[Subscript[w, 1], β] - 
      2 Cot[β]/
       Sin[β] D[Subscript[w, 1], α, γ])] // 
  TraditionalForm ;
Set[Subscript[a, 1], 
   2 D[Subscript[w, 1], {β, 2}] + 
    D[Subscript[w, 1], {γ, 2}] + J] // TraditionalForm ;
Set[Subscript[a, 2], 
   2 Cot[β]/
     Sin[β] D[Subscript[w, 
      1], {α, 1}] - (1 + 2 Cot[β]^2) D[Subscript[w, 
      1], {γ, 1}] - 
    2/Sin[β] D[Subscript[w, 1], β, α] + 
    2 Cot[β] D[Subscript[w, 1], β, γ]] // 
  TraditionalForm ;
Set[Subscript[f, 1], 
    1/(2 Sin[Subscript[Θ, 12]]^2) (-J + 
        Cos[Subscript[Θ, 
          12]] (Sin[2 γ] Subscript[a, 2] - 
           Cos[2 γ] Subscript[a, 1]) + 
        Sin[Subscript[Θ, 
          12]] (Sin[2 γ] Subscript[a, 1] + 
           Cos[2 γ] Subscript[a, 2])) - 
     D[Subscript[w, 1], Subscript[Θ, 12], γ] - 
     1/2 Cot[Subscript[Θ, 12]] D[Subscript[w, 
       1], {γ, 1}] + (1/4 - 1/(
        2 Sin[Subscript[Θ, 12]]^2)) D[Subscript[w, 
       1], {γ, 2}] ] // ExpandAll // TraditionalForm ;
Set[lapla1, -(1/(
      2 Subscript[μ, 1])) (1/Subscript[r, 1]
        D[Subscript[w, 1] Subscript[r, 1], {Subscript[r, 1], 2}] - 
      1/Subscript[r, 
        1]^2 (D[Subscript[w, 
          1], {Subscript[Θ, 12], 2}] + 
         Cot[Subscript[Θ, 12]] D[Subscript[w, 
           1], {Subscript[Θ, 12], 1}]) - Subscript[f, 
      1]/Subscript[r, 1]^2)] // ExpandAll // TraditionalForm

In this specific case, when I use TrigExpand for lapla1, mathematica does not use a unique relation for doing the expansion of each of the terms and is quite difficult to follow it by hand. So, I would like to impose these two specific trigonometric expansions in order to check the results.

$$\sin(2x)= 2\cos x \sin x$$ $$\cos(2x)= \cos^2 x-\sin ^2x$$

Yo can check that those expressions above can be written in several ways:

enter image description here

enter image description here

$\endgroup$
3
  • $\begingroup$ Each question should be standalone, so please include the expression in your question that you would like to simplify. $\endgroup$
    – RunnyKine
    Mar 31, 2014 at 16:02
  • $\begingroup$ @RunnyKine I edited my question. Sorry for any caused trouble. $\endgroup$
    – shadraws
    Mar 31, 2014 at 16:21
  • $\begingroup$ I was using wrong the TrigExpand function, so what I did to solve the problem was lapla1 /. {Sin[2 \[Gamma]] -> 2 Sin[\[Gamma]] Cos[\[Gamma]] , Cos[2 \[Gamma]] -> Cos[\[Gamma]]^2 - Sin[\[Gamma]]^2} // ExpandAll // TraditionalForm. Sorry for any inconvenience $\endgroup$
    – shadraws
    Mar 31, 2014 at 17:53

1 Answer 1

1
$\begingroup$

One way would be like the following. Let us define the function rule as follows:

Clear[rule];
rule[expr_] := ReplaceAll[ expr, {Sin[2 γ_] -> 2*Sin[γ]*Cos[γ], 
                                  Cos[2 γ_] -> Cos[γ]^2 - Sin[γ]^2}];

and map this function on your expression. For the sake of shortness I take here only a small part of your otherwise a too long expression. The effect is, however, the same, I checked. So, let this:

 expr=(Cos[Subscript[Θ, 12]] Sin[2 γ] f[Subscript[r, 1], Subscript[r, 2], α, β, γ, 
  Subscript[Θ, 12]])/(2 Sin[β] Sin[ Subscript[Θ, 12]]^2 
\!\(\*SubsuperscriptBox[\(r\), \(1\), \(2\)]\) Subscript[μ, 1])

be your expression in the StandardForm. Then this

Map[rule, expr]//TraditionalForm

returning this:

(*  (sin(γ) cos(γ) cos(Subscript[Θ, 12]) f(Subscript[r, 1], Subscript[r, ],α,β,γ, 
  Subscript[Θ, 12]) )/(Subscript[μ, 1] Subsuperscript[r, 1, 2] sin(β) 
  sin(Subscript[Θ, 12])^2)  *)

Though it looks awfully here, this:

enter image description here

is what you see on the screen. And suchlike looks each term.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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