Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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[\[Alpha]__][f1_][vars__], TraditionalForm] := 
 Module[{bb, dd, sp}, 
  MakeBoxes[dd, _] ^= 
   If[Length[{\[Alpha]}] == 1, "\[DifferentialD]", "\[PartialD]"];
  MakeBoxes[sp, _] ^= "\[ThinSpace]";
  bb /: MakeBoxes[bb[x__], _] := RowBox[Map[ToBoxes[#] &, {x}]];
  TemplateBox[{ToBoxes[bb[dd^Plus[\[Alpha]], f1]], 
    ToBoxes[Apply[bb, 
      Riffle[Map[bb[dd, #] &, 
        Select[({vars}^{\[Alpha]}), (# =!= 1 &)]], sp]]], 
    ToBoxes[Derivative[\[Alpha]][f1][vars]]}, "ShortFraction", 
   DisplayFunction :> (FractionBox[#1, #2] &), 
   InterpretationFunction :> (#3 &), Tooltip -> Automatic]]

Subscript[w, 1] = 
  f[Subscript[r, 1], Subscript[r, 2], \[Alpha], \[Beta], \[Gamma], 
   Subscript[\[CapitalTheta], 12]];
Set[J, -(D[Subscript[w, 1], {\[Beta], 2}] + 
      1/Sin[\[Beta]]^2 (D[Subscript[w, 1], {\[Alpha], 2}] + 
         D[Subscript[w, 1], {\[Gamma], 2}]) + 
      Cot[\[Beta]] D[Subscript[w, 1], \[Beta]] - 
      2 Cot[\[Beta]]/
       Sin[\[Beta]] D[Subscript[w, 1], \[Alpha], \[Gamma]])] // 
  TraditionalForm ;
Set[Subscript[a, 1], 
   2 D[Subscript[w, 1], {\[Beta], 2}] + 
    D[Subscript[w, 1], {\[Gamma], 2}] + J] // TraditionalForm ;
Set[Subscript[a, 2], 
   2 Cot[\[Beta]]/
     Sin[\[Beta]] D[Subscript[w, 
      1], {\[Alpha], 1}] - (1 + 2 Cot[\[Beta]]^2) D[Subscript[w, 
      1], {\[Gamma], 1}] - 
    2/Sin[\[Beta]] D[Subscript[w, 1], \[Beta], \[Alpha]] + 
    2 Cot[\[Beta]] D[Subscript[w, 1], \[Beta], \[Gamma]]] // 
  TraditionalForm ;
Set[Subscript[f, 1], 
    1/(2 Sin[Subscript[\[CapitalTheta], 12]]^2) (-J + 
        Cos[Subscript[\[CapitalTheta], 
          12]] (Sin[2 \[Gamma]] Subscript[a, 2] - 
           Cos[2 \[Gamma]] Subscript[a, 1]) + 
        Sin[Subscript[\[CapitalTheta], 
          12]] (Sin[2 \[Gamma]] Subscript[a, 1] + 
           Cos[2 \[Gamma]] Subscript[a, 2])) - 
     D[Subscript[w, 1], Subscript[\[CapitalTheta], 12], \[Gamma]] - 
     1/2 Cot[Subscript[\[CapitalTheta], 12]] D[Subscript[w, 
       1], {\[Gamma], 1}] + (1/4 - 1/(
        2 Sin[Subscript[\[CapitalTheta], 12]]^2)) D[Subscript[w, 
       1], {\[Gamma], 2}] ] // ExpandAll // TraditionalForm ;
Set[lapla1, -(1/(
      2 Subscript[\[Mu], 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[\[CapitalTheta], 12], 2}] + 
         Cot[Subscript[\[CapitalTheta], 12]] D[Subscript[w, 
           1], {Subscript[\[CapitalTheta], 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

share|improve this question
    
Each question should be standalone, so please include the expression in your question that you would like to simplify. –  RunnyKine Mar 31 at 16:02
    
@RunnyKine I edited my question. Sorry for any caused trouble. –  shadraws Mar 31 at 16:21
    
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 –  shadraws Mar 31 at 17:53

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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