Solving simple transcendental equation [duplicate]

This question already has an answer here:

Roots of a characteristic equation. Can Mathematica solve it?

6 answers

I would like to solve

Tan[x] == 1/x

Solve[] does not work, suggesting that there is no nice analytical solution for x.

Surprisingly, NSolve[] does not work either:

NSolve[Tan[x] == 1/x, x, Reals]

returns: ‘This system cannot be solved with the methods available to NSolve’

However, plotting these two functions shows that they cross around x=0.86:

This looks suspiciously close to Cos[Pi/6] = 0.866025 but it isn’t. It’s about 0.86028 (obtained by expanding the graph).

Am I missing something really obvious??

Thanks

=================

=================

2 Answers
2

=================

Instead of finding the intersection, you can also look for the root of Tan[x]-1/x, which yields the desired result

FindRoot[Tan[x] – 1/x == 0, {x, 0.5}]
{x -> 0.860334}

Greetings,
Jürgen

  

 

Right! Yes it works, thank you. I had forgotten about that function 🙂
– pdini
Mar 31 at 16:52

NSolve is primarily meant for polynomial equations, or equations that can be transformed into a polynomial.

For equations like this, we usually have two choices:

FindRoot to find a single solution numerically, based on a starting guess
Reduce can often find an “exact” solution (in some sense), but to succeed it typically requires specifying an interval in which to look.

This equation has an infinite number of real solutions.

Plot[{Tan[x], 1/x}, {x, -3 Pi, 3 Pi}]

Use FindRoot to find one:

FindRoot[Tan[x] == 1/x, {x, 1}]
(* {x -> 0.860334} *)

Use Reduce to find all solutions in a given interval:

Reduce[Tan[x] == 1/x && -2 Pi < x < 2 Pi, x, Reals] (* x == Root[{-1 + #1 Tan[#1] &, -3.4256184594817281465}] || x == Root[{-1 + #1 Tan[#1] &, -0.86033358901937976248}] || x == Root[{-1 + #1 Tan[#1] &, 0.86033358901937976248}] || x == Root[{-1 + #1 Tan[#1] &, 3.4256184594817281465}] *) Note that Reduce[Tan[x] == 1/x, x, Reals] does not return any solution. Specifying the interval was essential. This latter solution is exact in the following sense: When Reduce succeeds, it is guaranteed to find all solutions in the given interval The Root objects, while based on a numerical approximation, represent an exact solution, and can be used as any other exact number in Mathematica (e.g. can be computed to arbitrary precision). This interesting and useful feature of Reduce is discussed in this Wolfram Blog post.      Thank you very much, very clear answer. – pdini Mar 31 at 17:04