My problem is that, I have a big matrix with $6\times 6$ elements, with each term of the matrix is a big function of sum of cosines where I need to work only with the arguments and the amplitudes separately.
Simplifying the task is, I have a function like:
$$f(\phi) = A_{1} \cos \left(\phi -\frac{2 \pi }{3}\right)+ A_{2} \cos \left(2 \phi +\frac{\pi }{3}\right)+ A_{3} \cos \left(3 \phi -\frac{\pi }{2}\right);$$
and with any software like Matlab, Maple, Mathematica or any software. Input the matrix $f(\phi)$ and have the output a vector of amplitudes and a vector of arguments:
$$A=\left[ \begin{array}{ccc} A1 & A2 & A3 \end{array} \right] \text{and} \arg= \left[ \begin{array}{ccc} \phi -\frac{2 \pi }{3} & 2 \phi +\frac{\pi }{3} & 3 \phi -\frac{\pi }{2} \end{array} \right]$$
I have tried with Regexp of MatLab but it is not possible to choose only the argument of the cosine.
If anyone can help me please, Thank you very much
Mathematica handles automatically provides these reductions $$ \begin{align} % \cos \left(\phi -\frac{2 \pi }{3}\right) &= -\sin \left(\frac{\pi }{6}-\phi \right) \\ % \cos \left(2 \phi +\frac{\pi }{3}\right) &= \sin \left(\frac{\pi }{6}-2 \phi \right) \\ % \cos \left(3 \phi -\frac{\pi }{2}\right) &= \sin (3 \phi ) % \end{align} $$
The
TrigReduceexpression will yield $$ \text{TrigReduce}\left[A_{1} \cos \left(\phi -\frac{2 \pi }{3}\right)+A_{2} \cos \left(2 \phi +\frac{\pi }{3}\right)+A_{3} \cos \left(3 \phi -\frac{\pi }{2}\right)\right] = -A_{1} \sin \left(\frac{\pi }{6}-\phi \right)+A_{2} \sin \left(\frac{\pi }{6}-2 \phi \right)+A_{3} \sin (3 \phi ) $$Using
TrigExpand$$ \text{TrigExpand}\left[A_{1} \cos \left(\phi -\frac{2 \pi }{3}\right)+A_{2} \cos \left(2 \phi +\frac{\pi }{3}\right)+A_{3} \cos \left(3 \phi -\frac{\pi }{2}\right)\right] = \frac{1}{2} \sqrt{3} A_{1} \sin \phi -\frac{1}{2} A_{1} \cos \phi -\frac{1}{2} A_{2} \sin ^2(\phi )+\frac{1}{2} A_{2} \cos^{2}\phi -\sqrt{3} A_{2} \sin \phi \cos \phi -A_{3} \sin ^3(\phi )+3 A_{3} \sin \phi \cos^{2}\phi $$Using
SimplifyorFullSimplify: $$ \text{Simplify}\left[A_{1} \cos \left(\phi -\frac{2 \pi }{3}\right)+A_{2} \cos \left(2 \phi +\frac{\pi }{3}\right)+A_{3} \cos \left(3 \phi -\frac{\pi }{2}\right)\right] = -A_{1} \sin \left(\frac{1}{6} (\pi -6 \phi )\right)+A_{2} \cos \left(\frac{1}{3} (6 \phi +\pi )\right)+A_{3} \sin (3 \phi ) $$TrigFactor$$ \text{TrigFactor}\left[A_{1} \cos \left(\phi -\frac{2 \pi }{3}\right)+A_{2} \cos \left(2 \phi +\frac{\pi }{3}\right)+A_{3} \cos \left(3 \phi -\frac{\pi }{2}\right)\right] = -\frac{1}{2} \sqrt[3]{-1} \left(\left((-1)^{5/6} A_{1}+i A_{1}\right) \sin (\phi )+\left(A_{1}-\sqrt[3]{-1} A_{1}\right) \cos (\phi )+\left(-(-1)^{5/6} A_{2}-i A_{2}\right) \sin (2 \phi )+\left(\sqrt[3]{-1} A_{2}-A_{2}\right) \cos (2 \phi )+2 (-1)^{2/3} A_{3} \sin (3 \phi )\right) $$The trick is to decide which of these forms to work with and use
FullForm. For example $$ \text{FullForm}\left[A_{1} Cos\left[\phi - \frac{2}{3} \pi\right]\right] = \text{Times}[\underbrace{A_{1}}_{amplitude},\text{Cos}[\underbrace{\text{Plus}[\phi ,\text{Times}[-1,\text{Times}[\text{Times}[2,\text{Power}[3,-1]],\text{Pi}]]]}_{angle}]] $$ExtractThis problem seems better suited for the crowd at [Mathematica Stack Exchange][2]
Solution