How can I solve $x+\sin(x)=b$ for $x \in [0,π]$?

We take $b \in [0,π]$. I don't know how to find the solution.

  • 4
    $\begingroup$ This is a transcendental equation. In general you have to use numerical methods to solve (to within some given accuracy). $\endgroup$ – user137731 Sep 24 '16 at 15:47
  • $\begingroup$ @amWhy - OP specifically says "solve for $x$". $\endgroup$ – Myridium Sep 24 '16 at 15:48
  • $\begingroup$ @Myri...Yes, and when we take $b=0\in [0,\pi]$, we can, as I did, solve for $x$: x=0 $\endgroup$ – Namaste Sep 24 '16 at 15:51
  • $\begingroup$ @amWhy But that's a trivial solution. For most $b$, the solution will not be trivial. $\endgroup$ – Simply Beautiful Art Sep 24 '16 at 18:11
  • $\begingroup$ Of course, @SimpleArt $\endgroup$ – Namaste Sep 24 '16 at 18:16

You can't actually solve it, but you can approximate.

Here is the expansion for $\require{cancel}\sin(x)$ around $x=\pi/2$:


To give a crude estimate,


So let us solve the approximate problem:



$$x\approx1+\frac\pi2\pm\sqrt{3+\pi-2b}\tag{Quadratic Formula}$$

Given some guessing, you could determine if the $+\sqrt{}$ or the $-\sqrt{}$ is the one you are looking for.

Use longer expansions of sine for better approximations.

For example, if $b=1$, then


See that $x\cancel\approx4.6059$, and so the other root is the correct approximation. Plugging it in gives $1.0462$, a decent approximation to start with.

You could also use numerical methods like Newton's method, as mentioned above in the comments.

Applying Newton's method gives the following algorithm:


For $b=1$ and initial guess being $x_0=0.5357$, we get

$$\begin{align} x_0 & =0.5357 \\ x_1 & =0.5109 \\ x_2 & =0.5110 \\ x_3 & =0.510973429\dots \end{align}$$

Indeed, taking that final value for $x$ gives $x_3+\sin(x_3)=1$ for as many digits my calculator takes.


Here is an approach, if you need a numerical approximation.

The function $x\to x+\sin x$ is continuous and increasing on $[0,\pi]$, hence it defines a bijection. Let $f(y)$ be the unique solution on $[0,\pi]$ of the equation $y=x+\sin x$, for $y\in[0,\pi]$.

Here is a plot of $x+\sin x$:

enter image description here

You may use series reversion around a point to find an approximation of the solution. Either it's enough, or you can use it to get the initial value of an iterative (Newton's method or Halley's method for instance).

With the help of a computer algebra system (here, Maxima) you get, around $y=0$,


Around $\pi$, the function is flat so it's less simple, but you get




With this, you get a absolute error less than $2\cdot10^{-6}$ for any $y$ between $0$ and $\pi$, if you take the first approximation for $y<1.73714$, and the second approximation for $y\geq1.73714$.

With one step of Newton's method starting from this value, you should get a precision of the order of $10^{-12}$.

Of course, there are other ways, this is only a simple and relatively naive approach. You could split the interval $[0,\pi]$ in more than two intervals (using other expansions of the solution), and you could find optimal polynomial approximation, or rational approximation (the latter is probably what would be used in a more robust implementation). It's better, because instead of having a good approximation around one point, getting worse and worse as you move away from it, you obtain instead an approximation that has almost the same precision everywhere in some range.

  • $\begingroup$ Scared me for a moment when you said "bijection". Thought you were going to attempt "bisection", which is horrible. XD $\endgroup$ – Simply Beautiful Art Sep 24 '16 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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