Solving $\cos x=x$

This question already has an answer here:

  • What is the solution of cos(x)=x?

    8 answers

Solutions Collecting From Web of "Solving $\cos x=x$"

You are asking when $$x=\cos{x}=\sum_{k=0}^{\infty}\frac{(-1)^kx^{2k}}{(2k)!}.$$ In general, the solution will not have a closed form, but you can solve,

$$x=1-\frac{x^2}{2}+\frac{x^4}{4!}-\frac{x^6}{6!}+\dots+\frac{(-1)^kx^{2k}}{(2k)!}$$ to get approximations.

Taking $k=1$ we get,

$$x=1-\frac{x^2}{2} \iff x^2+2x-2=0$$

Which has two roots, and one which we are interested in within the given domain $[0,2\pi)$. Namely, $x=-1+\sqrt{3}=0.73205080756887729352744634\dots$.

Taking larger values of $k$ will give you a more accurate solution. But may not generally help, since you will be finding roots of polynomials of higher and higher degree.

If you don’t know, the polynomial on the RHS above is a Taylor polynomial for cosine of degree $2k$. You can read up on such polynomials in pretty much any introductory calculus book, Spivak’s Calculus does a good treatment.

Exact Solution

You request for an “exact” solution is the problem. The problem is with the exact definition of “exact”. You try to explain this by

Is there any real expression in finite terms [perhaps we call that closed form, I am not sure]

Algebraic Closed Form

The Abel-Ruffini Theorem says that there is no general closed form solution for even fifth degree (or higher) polynomial equations. Here closed form means using rational constants, the four elementary operations: +, −, ×, ÷ as well as radicals $\sqrt[p]{q}$ (the $p$-th root of $q$).

Closed Form

The term Closed Form is defined by wikipedia is

In mathematics, an expression is said to be a closed-form expression if it can be expressed analytically in terms of a finite number of certain “well-known” functions. Typically, these well-known functions are defined to be elementary functions—constants, one variable $x$, elementary operations of arithmetic (+ − × ÷), nth roots, exponent and logarithm (which thus also include trigonometric functions and inverse trigonometric functions)

Even this extended definition does not suffice to solve high degree polynomials. And we are looking for a solution to an infinite degree polynomial (infinite series). So you might get lucky, but more likely is that you will not.

Why closed form?

But what exactly is achieved by this closed form “exact”-ness. We can write $\sqrt2$ or $\pi$ as a closed form expression, but these closed form expressions suffer from all the problems you are complaining about. If you ask Wolfram Alpha for any number of digits for $\sqrt2$, it will only be an approximation and not exact. There any any number of very fast ways to get as many digits as you want for $\sqrt2$ or $\pi$ but then the same can be said about $x=\cos x$.

The point is that there is a single unique number that represents the solution to your question (an easily proved fact). That number becomes no more exact by giving it a special greek letter (like we did for $\pi$). There is an exact solution, and that solution can be found to as many digits as desired, without much effort.

Analytic Expression

A more general concept that the closed form is that of an analytic expression, which allows a potentially infinite number of basic arithmetic operations and common functions. This opens the door for infinite series, and the common functions are extended to include many special functions. In that sense, your question is finding the zero of analytic expression $$0 = x – \cos x$$

There is no analytical solution to this equation. The approximate solution is what Wolfram Alpha gave you. Taylor series are not a solution since, even for a very few terms, they will lead to the solution of high degree polynomials; but, as approximation, in your case, they do not lead to bad results : for example, developing at the first order and solving leads to a solution $x=1.00$. At the second and third orders, $x=0.732$. At the fourth and fifth order, $x=0.739$.

A better way for approximating the solution is Newton method, which means iterating according to

$x_{\text{new}} = x_{\text{old}} – \dfrac{f(x_{\text{old}})}{f'(x_{\text{old}})}$

In your case $f(x) = x – \cos(x)$ and $f'(x) = 1 + \sin(x)$. So, starting at $x=0$, the following iterates will be found : $1.000000$ , $0.750364$ , $0.739113$ , $0.739085$ , $0.739085$. You could continue until you reach the desired accuracy.