How do I solve $y=x+B\sin(x+A)$ for $x$

52 Views Asked by At

I have a code that converts x into y using the formula: $y=x+B\sin(x+A)$

with $x, A$ and $B$ known values. $B$ is also very small so that $B\sin(x+A) < 0.035$.

The problem is that in another system I need to revert this operation. So given y, I need to get the original x.

I tried to do: $n=y-B\sin(y+A)$

which provides a good approximation (since y is close to x) but I was wondering if there is a way to get the exact value so that n==x.

I also tried wolframalpha but it didn't help.

2

There are 2 best solutions below

5
On BEST ANSWER

Get rid of $a$ with $$y+a=x+a+b\sin(x+a)$$

which is

$$y=x+b\sin(x)$$

after redefinition of the variables.

As $b$ is tiny (in fact it suffices that $|b|<1$), the RHS is monotonic and there is a single solution

$$x\approx y.$$

You can refine it by Newton, and the next approximation is

$$x\approx y-\frac{b\sin(y)}{1+b\cos(y)}.$$

7
On

I don't think there is an analytic solution. the function seems 1-to-1 on the plots, have you considered programming a root-finder?

You use, for example, either Bisection or Newton's method to do so. It should converge quite fast.


UPDATE

Indeed, as pointed out by @Jakobian in the comment, since $|B| < 1$, we have $$ f'(x) = 1 + B \cos(x+A) > 0 $$ hence the function is always increasing, and so must be 1-to-1, so there is a unique solution for the root finder to converge to.