# Solve can't solve my trigonometric equation—why?

I have the following equation for epsilon

$$2 |\alpha_{n,ch}|=\epsilon+\cos^{-1}(\tan(\frac{\pi}{4}-\frac{\epsilon}{2}))$$, where $$\alpha_{n,ch}$$ is a negative constant (e.g. -0.769)

I tried to solve it using both Solve and NSolve:

Solve[{-2 anch == eps + ArcCos[Tan[Pi/4 - eps/2]]}, eps]


but some error occurred:

Solve::inex: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help.

And

NSolve[{-2 anch == eps + ArcCos[Tan[Pi/4 - eps/2]]}, eps]


just returns itself as a result

So, what can I do, to solve this equation?

• To symbolic solvers apply exact numbers and we have to restrict eps, e.g. With[{anch = -769/1000}, Solve[{-2 anch == eps + ArcCos[Tan[Pi/4 - eps/2]], -3 < eps < 3}, eps] // Quiet] yields an exact solution. Mar 19 '20 at 17:59
• While using exact values is often a good idea, it is not necessary in this case. The key is putting bounds on eps as @Artes did; either Solve or NSolve will work with an inexact value for anch. Mar 19 '20 at 18:22
• @Artes maybe I put it not quite correctly, anch is not a constant that I can define just for this equation, I obtain it from another math expression and therefore I can't predict good restriction for epsilon. And I can't believe that Mathematica can't solve it without any restrictions on epsilon Mar 19 '20 at 18:23
• @BobHanlon I'm using version 11.2, it seems that since version 12.0 Solve automatically switches to NSolve. Even though they are internally related, Solve usually did not work with numerical input before version 12.0, as in my case here. Am I right? Mar 19 '20 at 22:08
• @Artes - I do not have access to any versions prior to 12.0; however, I would expect Solve to rationalize the input if it could not solve with the inexact input (with the appropriate warning). The bounds on eps would be needed. You should be able to determine with your version. Mar 19 '20 at 22:49

## 1 Answer

Solve, NSolve as well as FindRoot can solve this equation, one should only remember several issues which may appear to be critical in different cases.

First let's define two different functions, they are equivalent on appropriate subsets of the space of variables {anch, eps}.

 eqs[anch_]:= -2 anch == eps + ArcCos[Tan[π/4 - eps/2]]
eqsC[anch_]:= Cos[-2 anch - eps] ==  Tan[π/4 - eps/2]


NSolve may be regarded a numerical counterpart of Solve, and so it is natural to restrict the variable eps.

NSolve[{eqs[-0.769], -3 < eps < 3}, eps]

{{eps -> 0.556395}}


in case of FindRoot one has to set an appropriate starting point:

FindRoot[eqs[-0.769], {eps, 0}]

{eps -> 0.556395}

With[{anch = -(769/1000)},
Plot[2 anch + eps + ArcCos[Tan[π/4 - eps/2]], {eps, -6, 6}]]


It is a good habit to use exact numbers in symbolic solvers using e.g. Rationalize on inexact numbers. Another issue is using ArcCos (it has a bounded domain) in Solve what necessarily implies certain problems, see e.g. . One can restrict eps e.g. How to solve this system of trigonometric trancendental equations over the reals?

 Solve[{eqs[-769/1000], -3 < eps < 3}, eps] // Quiet

 {{eps -> Root[{-(769/500) + ArcCos[Tan[π/4 - #1/2]] + #1 &,
0.556395249766362049415258676637}]}}


Alternatively we can rewrite the equation, then there are inifintely many solutions, even in the real domain:

eps /. Solve[eqsC[-769/1000], eps, Reals]


With[{anch = -769/1000},
Plot[-Cos[-2 anch - eps] + Tan[π/4 - eps/2], {eps, -10, 14}]]


If we change anch we should also enlarge the range where we are going to search for solutions, e.g.

 Solve[{eqs[-3149/1000], -8 < eps < 8}, eps] // Quiet

  {{eps -> Root[{-(3149/500) + ArcCos[Tan[π/4 - #1/2]] + #1 &,
6.28329345234967439849595819061}]}}


We can also demonstrate solutions of our equations for various values of anch with ContourPlot what can be used when searching for exact solutions with Solve (or Reduce) or aprropriate starting point in FindRoot:

GraphicsRow[
ContourPlot[#, {anch, -16, 8}, {eps, -15, 15},
AspectRatio -> Automatic, ContourStyle -> Thick] & /@
{eqsC[anch], eqs[anch]}]


• ok, it works for anch = -769 / 1000, but I can't get result for anch = -3149 / 1000 (too long evaluation, i aborted it). Mar 19 '20 at 18:43
• maybe there is some bug in my Mathematica version, but the last example stops working(very long evaluation) if I change eps range, for example, to -13<eps<13. Or it is normal? Mar 19 '20 at 19:06
• @timbars In case -13 < eps < 13 it is better to use eqsC defined in my answer because Solve doesn't work seemlessly with functions like ArcCos, see e.g. this answer How to solve this system of trigonometric trancendental equations over the reals? Mar 19 '20 at 19:29
• ok, thanks for your detailed answer Mar 19 '20 at 19:32