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]}]
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$eps
as @Artes did; eitherSolve
orNSolve
will work with an inexact value foranch
. $\endgroup$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$11.2
, it seems that since version12.0
Solve
automatically switches toNSolve
. Even though they are internally related,Solve
usually did not work with numerical input before version12.0
, as in my case here. Am I right? $\endgroup$Solve
to rationalize the input if it could not solve with the inexact input (with the appropriate warning). The bounds oneps
would be needed. You should be able to determine with your version. $\endgroup$