2

The result of

FullSimplify[RotationMatrix[θ, {Cos[ψ], Sin[ψ], 0}], ψ > 0].{0, 0, 1}

in Mathematica 11 is

{Sign[Sec[ψ]]^2 Sin[θ] Sin[ψ], -Cos[ψ] Sin[θ], Cos[θ]}

instead of the nicer result given by

EulerMatrix[{ψ, θ, 0}, {3, 1, 3}].{0, 0, 1}

which is

{Sin[θ] Sin[ψ], -Cos[ψ] Sin[θ], Cos[θ]}

Using just Simplify instead of FullSimplify gives an even more complex result: (yes I know this is expected, I've just put it here for completeness)

{(Sec[ψ] Sin[θ] Tan[ψ])/Abs[Sec[ψ]]^2, -((Sec[ψ] Sin[θ])/Abs[Sec[ψ]]^2), Cos[θ]}

How does one generically get around this simplification issue with RotationMatrix?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
typesanitizer
  • 374
  • 1
  • 11
  • You could help the system out with assumptions such as Sec[\[Psi]] > 0 || Sec[\[Psi]] < 0 – Szabolcs Aug 30 '17 at 19:27
  • Yes but that's specific to this problem -- it's very much like simplifying by hand. I'm looking for a more generic solution. I've emphasized the generic now. – typesanitizer Aug 30 '17 at 19:36
  • Well, you need to help it out somehow; surely you don't need the angles to span more than $[0,2\pi)$, no? – J. M.'s missing motivation Aug 30 '17 at 23:11
  • I think any useful solution will make use of some of the specific characteristics of your problem. Perhaps you can add more details on the class of problems you need to handle. – Szabolcs Aug 31 '17 at 12:59
  • There seem to be two points on which Mathematica stumbles: 1. Understand that Sec[z] != 0 for any z 2. Understand that Sign[x]^2 == 1 if x!=0 (it can only do this we specify x>0 || x<0 instead of the equivalent x!=0). You'll have to help it through these two somehow. – Szabolcs Aug 31 '17 at 13:01
  • @Szabolcs, actually I don't have a more complex problem at the moment (but I anticipate I may have one in the future). I just asked this question as it might be useful to someone else (including possibly future me). Should I delete the question? – typesanitizer Sep 02 '17 at 20:42
  • No need to delete, I think ... – Szabolcs Sep 02 '17 at 20:43

1 Answers1

2

To work around the lack of simplification of the Sign term, you could try adding ComplexExpand as a transformation function (this will tacitly assume that all variables are real):

FullSimplify[
    RotationMatrix[θ, {Cos[ψ],Sin[ψ],0}],
    TransformationFunctions->{Automatic,ComplexExpand[#,TargetFunctions->{Re,Im}]&}
] . {0,0,1}

{Sin[θ] Sin[ψ], -Cos[ψ] Sin[θ], Cos[θ]}

Carl Woll
  • 130,679
  • 6
  • 243
  • 355