This MitPY comes from frequent commenter, John Friend:

*Dear Colleagues,*

*I gave a CAS-FREE question to my Specialist students whose first part was to solve (exactly) the equation *. *I solved it two different ways and got two different answers that are equivalent. I’ve attached my calculations.*

*I checked my answers using Mathematica, which lead to my question: Mathematica gives a third different but equivalent answer **(scroll down to real solutions). How has Mathematica got this answer?*

*It may be that Mathematica ‘used’ my Method 2, got my tan answer and then for some arcane reason ‘manipulated’ this answer into the one it finally gives. If so, I can ascribe the answer to a Mathematica quirk. But it may be that Mathematica is using a method unclear to me that leads to its answer. If so, I’m curious.*

*Any thoughts are appreciated.*

Hmmm. When I click the Alpha link, Mathematica is giving me only two (real) answers, not three.

The method it appears to be using is the half-angle substitution, which a human would never do, because it results in a fifth order polynomial (fourth order after simplifying). To solve the polynomial, the

substitution is used. This turns it into a quadratic, which mathematica completes as a square. Taking square roots gives the pair of solutions, and then undoing the definitions the final answer.

Cheers, Glen. Much obliged.

I figured it must have involved first finding x/2 somehow but what you’ve said would not have occurred to me. I wonder if Mathematica just ‘brute forces’ a rigid algorithm onto everything (being a machine, brute force is its forte).

(By third I meant I found two forms of answers and Mathematica gave a third form of answer).

Oh! Now I understand the “third” comment.

The coolest thing about Mathematica’s solution IMO is that substitution to turn the polynomial you get out of it into a quadratic. That can’t be generic, I wonder if it is expected in problems like these though?

Mathematica likely just tries this half angle strategy on everything, and then tries a laundry list of subs when solving polynomials. So it is easy to explain away.

Nevertheless I still found it rather nifty.

lol! Nifty is one word for it. If a student made that substitution I’d call him/her a bonehead! For this question I think the substitution is , although I concede that leads to a polynomial more directly albeit you then have to make another non-trivial substitution to get the roots.

If you’re really interested in how Mathematica does certain tasks, there’s a page on how various methods are roughly implemented here: https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.html

Some of the solving stuff takes over 500 pages… Really tells you how many people have been working on this programming language.

And while we’re at it, I remember my teacher calling me out for using a nuclear solution for a trigonometric problem on a test. Funny times, because that sort of complex trick I pulled out of nowhere could also be used for solving certain integrals with trigonometric terms.

Edit: I just checked the question and remembered exactly what I did, and its even more amazing that I managed to use two silly identities and still somehow get the question right. Stupidity finds a way I suppose… If anyone is interested, I managed to use the identity

followed by

instead of simply factorising.

Smart teacher. I’d do exactly the same …

You don’t bring a nuclear bomb to a knife-fight – while you’re fumbling around with the bomb the other guy’s already won the fight.

For those keeping score, I’ve attached a calculation that gives the Mathematica answer. “Nifty” indeed …!

Calculation of the Mathematica answer

So this has been more rewarding than I expected. I’ve only thought of and used the Weierstrass substitution in the context of integration (we’re all victims of our experience), but obviously it’s a very useful technique for solving trigonometric equations since it always transforms a trigonometric equation into a polynomial equation. For example, I’ve always solved equations of the form

by first converting into one of the forms or using the compound angle formulae (we’re all victims of our experience). But clearly the Weierstrass substitution can be used to transform the above equation into a quadratic equation and is a ‘nifty’ alternative method. For example:

where

.

Case 1:

, ()

.

Case 2:

etc.

Indeed, Wolfram Alpha gives the same solutions rather than the ‘obvious’ solution involving arcsin or arccos:

https://www.wolframalpha.com/input/?i=solve+Sin%5Bx%5D+%2B+2+Cos%5Bx%5D+%3D+1

It looks like Mathematica solves all trig equations in this way (although I haven’t found any documentation to support this) which makes good sense because the problem is then reduced to the well-known problem of solving a polynomial equation.

With this insight, the Mathematica solution to is obvious and inevitable.

It is interesting. I guess if the trig problem leads to a sufficiently awful polynomial, then Mathematica may become unstuck. I find the possibility of a trig problem like this that has a nice “by hand” solution that doesn’t involve the half-angle sub quite interesting; I wonder what Mathematica would do with it.

I’ve checked what Mathematica does when the polynomial is ‘awful’ and, unsurprisingly, Mathematica gives decimal approximations rather than surds.

I say unsurprising because the roots of cubic and quartic polynomials can be calculated exactly using the cubic and quartic formulae and this is what Mathematica does. However, when the degree of the polynomial is greater than 4 there is no general formula and so a numerical approximation of the roots is all that can be done. (I find that such impossibilities surprise many students (and even some teachers), particularly when it comes to integration).

As for “a trig problem … that has a nice “by hand” solution”, it’s hard to tell because the answers come out ‘nicely’. I suspect that Mathematica would still use the Weiertstrass substitution (why change its computational spots?)

For example, to solve :

.

So or

and Mathematica has no trouble solving to get the exact value of .

For very simple trig equations like Mathematica does give an answer involving the expected arcsin rather than the ‘unexpected’ .

Maybe Sai could shed some light on how Mathematica solves trigonometric equations if he’s not too busy reminiscing about the good old days of being a knucklehead.

This may be of interest.

Adrian, Y.E.O. (2007). “Trig or treat: An encyclopedia of trigonometric identity proofs.” World Scientific.