1
$\begingroup$

I have a trigonometric function $Exp$ where $\{f,g,h,k\}$ are some parametric functions, and $a\in\mathbb{N}$ and $x>0$.

$$ Exp=f \cdot \sin \left(\frac{58 \pi a}{11}+x\right)+g\cdot \sin \left(\frac{30 \pi a}{11}+x\right)+h \cdot \sin \left(\frac{52 \pi a}{11}+x\right)+k\cdot \sin \left(\frac{40 \pi a}{11}\right) $$

Manually, I see that arguments of sine functions which are even multiples of $\frac{\pi a}{11}$ can be simplified as a smaller number which is multiple of $\frac{2\pi a}{11}$. For example (for $a\in\mathbb{N}$) $$\sin \left(\frac{58 \pi a}{11}+x\right)=\sin \left(\frac{14 \pi a}{11}+x\right) , \qquad\qquad \sin \left(\frac{30 \pi a}{11}+x\right)=\sin \left(\frac{8 \pi a}{11}+x\right) $$

$$ \sin \left(\frac{52 \pi a}{11}+x\right)=\sin \left(\frac{8 \pi a}{11}+x\right),\qquad\qquad\sin \left(\frac{40 \pi a}{11}\right)=\sin \frac{18 \pi a}{11} -\sin \frac{4 \pi a}{11} $$

How can I ask Mathematica to do this simplification in my expression?

expression:= f Sin[x + (58 \[Pi] a)/11] + g Sin[x + (30 \[Pi] a)/11] + h Sin[x + (52 \[Pi] a)/11] + k Sin[(40 \[Pi] a)/11] ;

verification

 {Sin[x + (58 \[Pi] a)/11] - Sin[x + (14 \[Pi] a)/11], 
  Sin[x + (30 \[Pi] a)/11] - Sin[x + (8 \[Pi] a)/11], 
  Sin[x + (52 \[Pi] a)/11] - Sin[x + (8 \[Pi] a)/11], 
  Sin[(40 \[Pi] a)/11] - 1/2 (-Sin[(4 \[Pi] a)/11] + Sin[(18 \[Pi] a)/11])} // 
 FullSimplify[#,  Assumptions ->  x > 0 && x \[Element] Reals  &&  a \[Element] Integers   ] & 

(* {0, 0, 0, 0} *)

$\endgroup$
1
  • $\begingroup$ Does this do exactly what you want? expression//.{Sin[x+Rational[n_,11]*Pi*a]/; IntegerQ[n/4]->Sin[x+n/2*Pi*a/11],Sin[Rational[n_,11]*Pi*a]/;IntegerQ[n/4]-> Sin[n/2*Pi*a/11]} Study that really carefully until you are sure you understand what it does and test that very very carefully before you depend on it. Give it lots of test cases where it should and where it should not do those divisions. $\endgroup$
    – Bill
    Nov 15, 2022 at 17:59

2 Answers 2

3
$\begingroup$
expression /. 
  Sin[u_ + v_] -> Cos[v] Sin[u] + Cos[u] Sin[v] /.
  {Sin[w_ a] -> Sin[Mod[w, 2π, -π] a], Cos[w_ a] -> Cos[Mod[w, 2π, -π] a]} // FullSimplify

(*    -k*Sin[4*a*π/11] - f*Sin[8*a*π/11 - x] + (g + h)*Sin[8*a*π/11 + x]    *)
$\endgroup$
1
  • $\begingroup$ Thanks. Does this code work for other functions similar to the given one? I guess so. $\endgroup$
    – charmin
    Nov 15, 2022 at 22:46
2
$\begingroup$

Input:

expression:

$$f \sin \left(\frac{58 \pi a}{11}+x\right)+g \sin \left(\frac{30 \pi a}{11}+x\right)+h \sin \left(\frac{52 \pi a}{11}+x\right)+k \sin \left(\frac{40 \pi a}{11}\right)$$

Output :

simplified…expression : (Note: = \[Ellipsis] here and below)

$$f \sin \left(\frac{14 \pi a}{11}+x\right)+(g+h) \sin \left(\frac{8 \pi a}{11}+x\right)+k \sin \left(\frac{18 \pi a}{11}\right)$$


expression = 
 k Sin[(40 a π)/11] + g Sin[(30 a π)/11 + x] + 
  h Sin[(52 a π)/11 + x] + f Sin[(58 a π)/11 + x] 

simplified…expression = 
 expression /. Sin[r_. + s_*a] :> Sin[r + a*Mod[s, 2*Pi]] // Simplify

Out:

(* k Sin[(18 a π)/11] + (g + h) Sin[(8 a π)/11 + x] + f Sin[(14 a π)/11 + x] *)

I used _. to handle both the cases where r is present and absent but one can do the same using two rules /. Sin[x + s_*a] :> Sin[x + a*Mod[s, 2*Pi]] /. Sin[a*s_] :> Sin[a*Mod[s, 2*Pi]]


Verification:

Norm@Simplify@
  Table[simplified…expression - expression, {a, 0, 10}]

0


Note:

Roman's solution of using Mod[angle,2*Pi,-Pi] is more general. In particular in the scenario below:

expression = Cos[a*(3*Pi)/2] - Cos[a*Pi/2]

and a is integer.

Then,

expression /. Cos[a*s_] -> Cos[a*Mod[s, 2*Pi]]

does not simplify but

expression /. Cos[a*s_] -> Cos[a*Mod[s, 2*Pi, -Pi]]

does simplify

$\endgroup$
1
  • 1
    $\begingroup$ Note _.+term means _. matches something or 0 which is the neutral element of addition but _.*term means _. matches something or 1 the neutral element of multiplication. One might possibly consider more exotic scenarios by checking the documentation on Default and OneIdentity $\endgroup$ Nov 15, 2022 at 23:39

Your Answer

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

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