# How to automate this solution?

The Mathematica solver is strong. Of course, there is a room to improve it. Here is an example. The command

Reduce[x + 1/6*ArcCos[Cos[15*x] + 2*Cos[4 x]*Sin[2 x]] == Pi/12, x, Reals]


is running without any output for hours and the same issue with Solve. However, Mathematica is able to solve the equation under consideration. Taking into account the domain of ArcCos over the reals, one draws the bounds x >= Pi/12 - Pi/6 && x <= Pi/12 for the solutions. Now we transform the equation by

FunctionExpand[Cos[Pi/2 - 6*x] == Cos[ArcCos[Cos[15*x] + 2*Cos[4 x]*Sin[2 x]]]]


Sin[6 x] == Cos[15 x] + 2 Cos[4 x] Sin[2 x]

. Then

Reduce[% && x >= Pi/12 - Pi/6 && x <= Pi/12, x, Reals]


x == 2 ArcTan[ Root[1 + 12 #1 - 90 #1^2 - 196 #1^3 + 911 #1^4 + 376 #1^5 - 2092 #1^6 + 376 #1^7 + 911 #1^8 - 196 #1^9 - 90 #1^10 + 12 #1^11 + #1^12 &, 6]] || x == 2 ArcTan[ Root[1 - 16 #1 - 152 #1^2 + 528 #1^3 + 2908 #1^4 - 3280 #1^5 - 15656 #1^6 + 3792 #1^7 + 28102 #1^8 + 3792 #1^9 - 15656 #1^10 - 3280 #1^11 + 2908 #1^12 + 528 #1^13 - 152 #1^14 - 16 #1^15 + #1^16 &, 9]]

 N[%]


x==-0.12083||x==0.0923998

does the job. But the complicated result can be simplified in such a way

Cos[15 x] + 2 Cos[4 x] Sin[2 x] == Sin[6 x] // FullSimplify


Cos[15 x] == Sin[2 x]

The rest is clear and we come to the explicit solutions

x == [Pi]/34||x == - [Pi]/26

You can add a RootApproximant transformation to Simplify:

eq = FunctionExpand[Cos[π/2 - 6 x] == Cos[ArcCos[Cos[15 x] + 2 Cos[4 x] Sin[2 x]]]];

Simplify[Solve[eq && x >= π/12 - π/6 && x <= π/12, x, Reals],
TransformationFunctions -> {Automatic, RootApproximant[#/π] π &}]


$$\left\{\left\{x\to -\frac{\pi }{26}\right\},\left\{x\to \frac{\pi }{34}\right\}\right\}$$

Using the following transformation still doesn't guarantee exactness, but it might work better.

If[Rationalize[#/π, 10^(-10)] === Rationalize[#/π, 10^(-1000)],
π Rationalize[#/π, 10^(-10)], #] &

• +1 Or use RootApproximant with NSolve on the original equation Pi*RootApproximant[(x /. NSolve[{x + 1/6*ArcCos[Cos[15*x] + 2*Cos[4 x]*Sin[2 x]] == Pi/12, -Pi <= x <= Pi}, x, Reals])/Pi] Nov 18, 2018 at 16:30
• Thank you. Unfortunately, this trick does not guarantee exact solutions. You are lucky. Nov 18, 2018 at 16:32
• It is easy to verify that the RootApproximant solution is exact in this case x + 1/6*ArcCos[Cos[15*x] + 2*Cos[4 x]*Sin[2 x]] == Pi/12 /. Thread[x -> sol] // FullSimplify Nov 18, 2018 at 16:37
• Can you kindly elaborate your "It is easy to verify..."? I clearly understand the verification confirms the solutions obtained by RootApproximant. I repeat this approach does not guarantee exact solutions. Nov 18, 2018 at 16:44
• Select[NSolve[{eq, -Pi < x <= Pi}, x, Reals] /. n_Real :> Pi*RootApproximant[n/Pi], FullSimplify[eq /. #] &] is guaranteed to only return exact solutions. For different equations you would in general have to adjust the interval of interest and/or the form of the RootApproximant. But this works as is for other equations such as eq2 = x + 1/6*ArcCos[Cos[17*x] + 2*Cos[4 x]*Sin[2 x]] == Pi/12; Nov 18, 2018 at 17:17