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.


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?

  • 2
    $\begingroup$ 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. $\endgroup$
    – Artes
    Mar 19, 2020 at 17:59
  • 1
    $\begingroup$ 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. $\endgroup$
    – Bob Hanlon
    Mar 19, 2020 at 18:22
  • $\begingroup$ @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 $\endgroup$
    – Eikthyrnir
    Mar 19, 2020 at 18:23
  • $\begingroup$ @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? $\endgroup$
    – Artes
    Mar 19, 2020 at 22:08
  • $\begingroup$ @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. $\endgroup$
    – Bob Hanlon
    Mar 19, 2020 at 22:49

1 Answer 1


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}]]

enter image description here

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 &, 

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

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

enter image description here

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

enter image description here

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 &, 

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:

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

enter image description here

  • $\begingroup$ ok, it works for anch = -769 / 1000, but I can't get result for anch = -3149 / 1000 (too long evaluation, i aborted it). $\endgroup$
    – Eikthyrnir
    Mar 19, 2020 at 18:43
  • $\begingroup$ 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? $\endgroup$
    – Eikthyrnir
    Mar 19, 2020 at 19:06
  • $\begingroup$ @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? $\endgroup$
    – Artes
    Mar 19, 2020 at 19:29
  • $\begingroup$ ok, thanks for your detailed answer $\endgroup$
    – Eikthyrnir
    Mar 19, 2020 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.