How do I force Simplify to use half angle identities?
Suppose I have (x is in the Reals)
f = ArcTan[1/x^2]; expr = Cos[f/2]; notice that
Cos[f] == 1/Sqrt[1 + 1/x^4]
True
and using the half-angle identity $$\cos\frac{\vartheta}{2} = \pm \sqrt{\frac{1+\cos\vartheta}{2}}$$
we can write (I only need the positive root; expr>0 for all real x):
FullSimplify[expr == Sqrt[(1 + Cos[f])/2]]
True
How can I get Simplify[expr] to output Sqrt[(1 + Cos[f])/2] (with f expanded out) instead of Cos[1/2 ArcTan[1/x^2]]?
My suspicion is that this is because the LeafCount of Sqrt[(1 + Cos[f])/2] (with f expanded out) would be higher than Cos[1/2 ArcTan[1/x^2]]. Is there maybe a way to modify the ComplexityFunction so that it is rewarded for using these half angle formulas?
Right now I am doing the half-angle substitutions with functions I wrote and replacement rules, but I'd rather Simplify just do it for me.
Add-on
Maybe it's not relevant, but I probably should've at least posted the replacement rule I am doing for now so others can see it. I have a long formula compEx and I find everywhere that I see something like Cos[1/2___(something)], and there I use the half angle formula for cosine:
fun = ArcTan[(1 - x)/Sqrt[-I - x^2]]/Sqrt[-I - x^2]; compEx = Simplify[ComplexExpand[Re[fun], TargetFunctions -> {Re, Im}], 1/2 < x < 1]; halfAngleCos[k_] = Sqrt[(1 + Cos[2 k])/2]; subbed = compEx /. Cos[1/2 k__] -> halfAngleCos[1/2 k]; I do the same thing with half angle formula for Sin also.
expr=Cos[f/2]; expr/.Cos[x_/2]:> Sqrt[(1+Cos[x])/2]!Mathematica graphics or do you need to use Simplify only? $\endgroup$Simplifyto do it for me. Now that I think about it though, the way I'm doing it is pretty clean. So maybe I shouldn't worry about how to do this withSimplify? $\endgroup$