4
$\begingroup$

This question already has an answer here:

I am writing a code to compute some matrix quantities. The result involves Sec andCsc functions, and I want a form displayng only Sinand Cos. I have already seen this question, but the solution suggested does not solve my problem, since I get the following:

    Ef = {{-Sin[ζ], 0, 0, 0, 0, 0, 0, 0}, {0, Cos[ζ], 0, 0, 0,
 0, 0, 0}, {0, 0, Cos[ζ], 0, 0, 0, 
0, γ Cos[ζ]}, {0, 0, 0, Sin[ζ], 0, 
0, -γ Sin[ζ], 0}, {0, 0, 0, 0, -1/Sin[ζ], 0, 0,
 0}, {0, 0, 0, 0, 0, 1/Cos[ζ], 0, 0}, {0, 0, 0, 0, 0, 
0, (1/Cos[ζ]), 0}, {0, 0, 0, 0, 0, 0, 0, 1/Sin[ζ]}};

    G = Transpose[Ef].Ef;
    MatrixForm[G]

    ginv = Table[G[[i]][[j]], {i, 5, 8}, {j, 5, 8}];
    g = Inverse[ginv];
    MatrixForm[g] // FullSimplify

$$g= \begin{pmatrix} \sin ^2(\zeta ) & 0 & 0 & 0 \\ 0 & \cos ^2(\zeta ) & 0 & 0 \\ 0 & 0 & \frac{\csc ^2(\zeta )}{\gamma ^2+4 \csc ^2(2 \zeta )} & 0 \\ 0 & 0 & 0 & \frac{\sec ^2(\zeta )}{\gamma ^2+4 \csc ^2(2 \zeta )}\end{pmatrix}$$

But I would like the equivalent form (but easier to cope with),

$$g = \begin{pmatrix} \sin ^2(\zeta ) & 0 & 0 & 0 \\ 0 & \cos ^2(\zeta ) & 0 & 0 \\ 0 & 0 & \frac{\cos ^2(\zeta )}{1+\gamma ^2 \sin^2 (\zeta) \cos^2 (\zeta)} & 0 \\ 0 & 0 & 0 & \frac{\sin ^2(\zeta )}{1+\gamma ^2 \sin^2 (\zeta) \cos^2 (\zeta)}\end{pmatrix}$$

Using

    $PrePrint = # /. {Csc[z_] :> 1/Defer@Sin[z], 
 Sec[z_] :> 1/Defer@Cos[z]} &;

I just manage to obtain terms like $$ \frac{1}{\cos^2 (\zeta) \left( \gamma^2 + \frac{4}{\sin^2(2\zeta)}\right)}$$

and further TrigExpand does not have any effect. Someone has any suggestion?

$\endgroup$

marked as duplicate by Jens, m_goldberg, bbgodfrey, ciao, Bob Hanlon Mar 17 '15 at 0:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ I feel your pain, but I'm afraid, no amount of TrigExpand will ever convert the last expression. It is a case of a/a != 1 as it may be the case, that a == 0. $\endgroup$ – LLlAMnYP Mar 16 '15 at 12:03
  • $\begingroup$ Although the goal here is a little different, I think the main issue is the same as in Mathematica Sec and Csc, and there probably isn't a better solution - I would love to be wrong, though. $\endgroup$ – Jens Mar 16 '15 at 16:07
1
$\begingroup$

You might have some success with specifying a different complexity function for FullSimplify. The following statement e.g. will avoid introducing Sec and Csc:

FullSimplify[g, ComplexityFunction->(Count[{#}, (Sec|Csc)[__]]&)]

Alas, the output might still not be exactly what you are after:

$$\left( \begin{array}{cccc} \sin ^2(\zeta ) & 0 & 0 & 0 \\ 0 & \cos ^2(\zeta ) & 0 & 0 \\ 0 & 0 & \frac{8 \cos ^2(\zeta )}{-\cos (4 \zeta ) \gamma ^2+\gamma ^2+8} & 0 \\ 0 & 0 & 0 & \frac{8 \sin ^2(\zeta )}{-\cos (4 \zeta ) \gamma ^2+\gamma ^2+8} \\ \end{array} \right)$$

$\endgroup$

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