3
$\begingroup$

This question already has an answer here:

Why doesn't Mathematica solve x == Cos[x] properly?

Both Solve and NSolve fail with the message:

Solve::nsmet: This system cannot be solved with the methods available to Solve. >>

$\endgroup$

marked as duplicate by Artes, Sjoerd C. de Vries, bobthechemist, rm -rf Dec 30 '13 at 15:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

8
$\begingroup$

In this case you might use:

InverseFunction[Cos]
ArcCos

One can see that this is valid only over the interval (-1, 1) which is probably why Solve does not give an answer:

Plot[{Cos@x, ArcCos@x}, {x, -Pi, Pi}, PlotStyle -> Thick]

Mathematica graphics

A few methods to find the intersection in the illustration:

N @ FindInstance[x == Cos[x], x]

N @ Reduce[{x == Cos[x], -1 < x < 1}, x]

FindRoot[x == Cos[x], {x, 0}]
{{x -> 0.739085}}

x == 0.739085

{x -> 0.739085}

I would be remiss not to point out that my plot above is only looking at real values. One can see that as implemented ArcCos does handle the full circle:

Plot[{Cos @ ArcCos @ x, x + 1}, {x, -20, 20}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thx, I just wanted to know why Mathematica didn't know to use arccos... $\endgroup$ – Tom Wellington Oct 22 '12 at 7:09
  • $\begingroup$ Of note is that Reduce[] returns a Root[] object, which can then be evaluated to arbitrary precision. $\endgroup$ – J. M. is away Oct 22 '12 at 7:19
  • $\begingroup$ @J.M. I get x == Root[{-Cos[#1] + #1 &, 0.73908513321516064165}] where the "Dottie number" has 20.6 digits of precision. How can that be accurately evaluated to arbitrary precision? (Assuming that you mean arbitrary in the general sense.) $\endgroup$ – Mr.Wizard Oct 22 '12 at 7:31
  • 1
    $\begingroup$ @Mr.Wizard The 0.739... in the argument is not used to compute the value of the root, only to isolate it from any other potential roots. In this sense, it is similar to the index for normal polynomial Root objects, as returned by say, Solve[x^5 -x-1 == 0, x]. Of course, the root can be computed to arbitrary precision using the -Cos[#1] + #1 &. $\endgroup$ – Mark McClure Oct 22 '12 at 10:32
  • 1
    $\begingroup$ @TomWellington This answer gives more detailed discussion of the issue mathematica.stackexchange.com/questions/4694/… $\endgroup$ – Artes Oct 22 '12 at 10:35
6
$\begingroup$

Another possibility :

FixedPoint[Cos[#] &, 0.5]

(* 0.739085 *)
$\endgroup$
  • 3
    $\begingroup$ You don't need &: FixedPoint[Cos, 0.5] $\endgroup$ – Mr.Wizard Oct 22 '12 at 7:06
  • 1
    $\begingroup$ @Mr.Wizard Thanks, I was aware of this but thought to make the answer easier to generalize. $\endgroup$ – b.gates.you.know.what Oct 22 '12 at 7:11

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